rosa-build/lib/tasks/new_core.rake

54 lines
2.0 KiB
Ruby
Raw Normal View History

namespace :new_core do
desc 'Sets bs_id field for all BuildList which use new_core'
task :update_bs_id => :environment do
say "[#{Time.zone.now}] Starting to update bs_id..."
BuildList.select(:id).
where(:new_core => true, :bs_id => nil).
find_in_batches(:batch_size => 500) do | bls |
puts "[#{Time.zone.now}] - where build_lists.id from #{bls.first.id} to #{bls.last.id}"
BuildList.where(:id => bls.map(&:id), :bs_id => nil).
update_all("bs_id = id")
end
say "[#{Time.zone.now}] done"
end
2012-12-29 16:16:56 +00:00
desc 'Publish mass-build 317'
task :publish_mass_build_317 => :environment do
say "[#{Time.zone.now}] Starting to publish mass-build 317..."
2012-12-29 16:21:25 +00:00
bl = BuildList.where(:mass_build_id => 317).first
2012-12-29 16:27:22 +00:00
repository_path = "#{bl.save_to_platform.path}/repository"
2012-12-29 16:16:56 +00:00
BuildList.where(:mass_build_id => 317).
where("status != #{BuildServer::BUILD_ERROR}").
order(:id).
find_in_batches(:batch_size => 1) do | bls |
bl = bls.first
puts "[#{Time.zone.now}] - where build_lists.id #{bl.id}"
2012-12-29 16:19:11 +00:00
sha1 = bl.results.find{ |r| r['file_name'] =~ /.*\.tar\.gz$/ }['sha1']
2012-12-29 16:16:56 +00:00
2012-12-29 16:33:12 +00:00
system "cd #{repository_path} && curl -L -O http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}"
system "cd #{repository_path} && tar -xzf #{sha1}"
system "rm -f #{repository_path}/#{sha1}"
2012-12-29 16:16:56 +00:00
2012-12-29 16:33:12 +00:00
archive_folder = "#{repository_path}/archives"
2012-12-29 16:16:56 +00:00
system "sudo chown root:root #{archive_folder}/SRC_RPM/*"
system "sudo chmod 0666 #{archive_folder}/SRC_RPM/*"
system "sudo chown root:root #{archive_folder}/RPM/*"
system "sudo chmod 0666 #{archive_folder}/RPM/*"
2012-12-29 16:27:22 +00:00
system "sudo mv #{archive_folder}/SRC_RPM/* #{repository_path}/SRPMS/main/release/"
2012-12-29 16:33:12 +00:00
system "sudo mv #{archive_folder}/RPM/* #{repository_path}/#{bl.arch.name}/main/release/"
2012-12-29 16:16:56 +00:00
system "sudo rm -rf #{archive_folder}"
bl.update_column(:status, BuildList::BUILD_PUBLISH)
end
say "[#{Time.zone.now}] done"
end
end