#118: Use all arches on publish

This commit is contained in:
Vokhmin Alexey V 2013-05-31 15:48:57 +04:00
parent 62f612d87c
commit 720aa5b20d
1 changed files with 13 additions and 10 deletions

View File

@ -73,6 +73,12 @@ module AbfWorker
redis.lrem LOCKED_REP_AND_PLATFORMS, 0, lock_str redis.lrem LOCKED_REP_AND_PLATFORMS, 0, lock_str
end end
def packages_structure
structure = {:sources => [], :binaries => {}}
Arch.pluck(:name).each{ |name| structure[:binaries][name.to_sym] = [] }
structure
end
def redis def redis
Resque.redis Resque.redis
end end
@ -81,7 +87,7 @@ module AbfWorker
platform_path = "#{build_list.save_to_platform.path}/container/#{build_list.id}" platform_path = "#{build_list.save_to_platform.path}/container/#{build_list.id}"
system "rm -rf #{platform_path} && mkdir -p #{platform_path}" system "rm -rf #{platform_path} && mkdir -p #{platform_path}"
packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}} packages = packages_structure
packages[:sources] = build_list.packages.by_package_type('source').pluck(:sha1).compact packages[:sources] = build_list.packages.by_package_type('source').pluck(:sha1).compact
packages[:binaries][build_list.arch.name.to_sym] = build_list.packages.by_package_type('binary').pluck(:sha1).compact packages[:binaries][build_list.arch.name.to_sym] = build_list.packages.by_package_type('binary').pluck(:sha1).compact
@ -109,7 +115,7 @@ module AbfWorker
:type => :publish, :type => :publish,
:time_living => 9600, # 160 min :time_living => 9600, # 160 min
:packages => packages, :packages => packages,
:old_packages => {:sources => [], :binaries => {:x86_64 => [], :i586 => []}}, :old_packages => packages_structure,
:build_list_ids => [build_list.id], :build_list_ids => [build_list.id],
:projects_for_cleanup => [], :projects_for_cleanup => [],
:extra => {:create_container => true} :extra => {:create_container => true}
@ -129,7 +135,7 @@ module AbfWorker
build_lists_for_cleanup << bl if bl build_lists_for_cleanup << bl if bl
end end
old_packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}} old_packages = packages_structure
build_lists_for_cleanup.each do |bl| build_lists_for_cleanup.each do |bl|
bl.last_published.includes(:packages).limit(2).each{ |old_bl| bl.last_published.includes(:packages).limit(2).each{ |old_bl|
fill_packages(old_bl, old_packages, :fullname) fill_packages(old_bl, old_packages, :fullname)
@ -248,7 +254,7 @@ module AbfWorker
build_lists = build_lists.where('build_lists.id NOT IN (?)', locked_ids) unless locked_ids.empty? build_lists = build_lists.where('build_lists.id NOT IN (?)', locked_ids) unless locked_ids.empty?
build_lists = build_lists.limit(150) build_lists = build_lists.limit(150)
old_packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}} old_packages = packages_structure
projects_for_cleanup.each do |key| projects_for_cleanup.each do |key|
@redis.lrem PROJECTS_FOR_CLEANUP, 0, key @redis.lrem PROJECTS_FOR_CLEANUP, 0, key
@ -256,8 +262,8 @@ module AbfWorker
next unless packages next unless packages
packages = JSON.parse packages packages = JSON.parse packages
old_packages[:sources] |= packages['sources'] old_packages[:sources] |= packages['sources']
[:x86_64, :i586].each do |arch| Arch.pluck(:name).each do |arch|
old_packages[:binaries][arch] |= packages['binaries'][arch.to_s] old_packages[:binaries][arch.to_sym] |= packages['binaries'][arch]
end end
end end
@ -295,10 +301,7 @@ module AbfWorker
:extra => {:lock_str => lock_str} :extra => {:lock_str => lock_str}
} }
packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}} packages, build_list_ids, new_sources = packages_structure, [], {}
build_list_ids = []
new_sources = {}
build_lists.each do |bl| build_lists.each do |bl|
# remove duplicates of sources for different arches # remove duplicates of sources for different arches
bl.packages.by_package_type('source').each{ |s| new_sources["#{s.fullname}"] = s.sha1 } bl.packages.by_package_type('source').each{ |s| new_sources["#{s.fullname}"] = s.sha1 }