#416: Handle ExcludeArch and ExclusiveArch tags

This commit is contained in:
Vokhmin Alexey V 2014-07-23 02:43:50 +04:00
parent 88a852b4c8
commit 6f97b8dc15
5 changed files with 50 additions and 4 deletions

View File

@ -105,7 +105,8 @@ class BuildList < ActiveRecord::Base
%w(TESTS_FAILED 11000),
%w(BUILD_PUBLISHED_INTO_TESTING 12000),
%w(BUILD_PUBLISH_INTO_TESTING 13000),
%w(FAILED_PUBLISH_INTO_TESTING 14000)
%w(FAILED_PUBLISH_INTO_TESTING 14000),
%w(UNPERMITTED_ARCH 15000)
].each do |kind, value|
value = value.to_i
const_set kind, value
@ -189,6 +190,10 @@ class BuildList < ActiveRecord::Base
transition waiting_for_response: :build_pending
end
event :unpermitted_arch do
transition build_pending: :unpermitted_arch
end
event :rerun_tests do
transition %i(success tests_failed) => :rerun_tests
end
@ -622,8 +627,41 @@ class BuildList < ActiveRecord::Base
end
end
def add_job_to_abf_worker_queue
if permitted_arch?
super
else
unpermitted_arch
end
end
protected
def permitted_arch?
blob, raw = project.find_blob_and_raw_of_spec_file(commit_hash)
return true unless blob
permitted = true
file = Tempfile.new(blob.name, File.join(Rails.root, 'tmp'))
filename = file.path
begin
file.puts raw.content
file.rewind
exclusivearch = `rpm -q --qf="[%{EXCLUSIVEARCH}\n]" --specfile #{file.path}`
exitstatus = $?.exitstatus
permitted = false if exitstatus == 0 && exclusivearch.present? && exclusivearch !~ /^#{arch.name}$/
excludearch = `rpm -q --qf="[%{EXCLUDEARCH}\n]" --specfile #{file.path}`
exitstatus = $?.exitstatus
permitted = false if exitstatus == 0 && excludearch.present? && excludearch =~ /^#{arch.name}$/
ensure
file.close
file.unlink # deletes the temp file
end
permitted
end
def create_container
Resque.enqueue(BuildLists::CreateContainerJob, id)
end

View File

@ -32,6 +32,14 @@ module Git
repo.tags.map(&:name) + repo.branches.map(&:name)
end
def find_blob_and_raw_of_spec_file(project_version)
blob = repo.tree(project_version).contents.find{ |n| n.is_a?(Grit::Blob) && n.name =~ /.spec$/ }
return unless blob
raw = Grit::GitRuby::Repository.new(repo.path).get_raw_object_by_sha1(blob.id)
[blob, raw]
end
def create_branch(new_ref, from_ref, user)
return false if new_ref.blank? || from_ref.blank? || !(from_commit = repo.commit(from_ref))
status, out, err = repo.git.native(:branch, {process_info: true}, new_ref, from_commit.id)

View File

@ -337,10 +337,9 @@ class Project < ActiveRecord::Base
end
def increase_release_tag(project_version, user, message)
blob = repo.tree(project_version).contents.find{ |n| n.is_a?(Grit::Blob) && n.name =~ /.spec$/ }
blob, raw = find_blob_and_raw_of_spec_file(project_version)
return unless blob
raw = Grit::GitRuby::Repository.new(repo.path).get_raw_object_by_sha1(blob.id)
content = self.class.replace_release_tag raw.content
return if content == raw.content

View File

@ -173,6 +173,7 @@ en:
build_published_into_testing: '[testing] Build has been published'
build_publish_into_testing: '[testing] Build is being published'
failed_publish_into_testing: '[testing] Publishing error'
unpermitted_arch: Unpermitted architecture
log:
build_log: Build Log

View File

@ -172,7 +172,7 @@ ru:
build_published_into_testing: '[testing] опубликован'
build_publish_into_testing: '[testing] публикуется'
failed_publish_into_testing: '[testing] ошибка публикации'
unpermitted_arch: Недопустимая архитектура
log:
build_log: Лог сборки