diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 622c528e6..4f237eb93 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -273,7 +273,7 @@ class BuildList < ActiveRecord::Base def publish_container type = build_for_platform.distrib_type - archive = results.select{ |r| r['file_name'] =~ /.*\.tar\.gz$/}[0] + archive = results.find{ |r| r['file_name'] =~ /.*\.tar\.gz$/ } platform_path = "#{save_to_platform.path}/repository" if save_to_platform.personal? diff --git a/lib/tasks/new_core.rake b/lib/tasks/new_core.rake index f61689b96..953e1b251 100644 --- a/lib/tasks/new_core.rake +++ b/lib/tasks/new_core.rake @@ -14,4 +14,44 @@ namespace :new_core do say "[#{Time.zone.now}] done" end + + desc 'Publish mass-build 73' + task :publish_mass_build_73 => :environment do + say "[#{Time.zone.now}] Starting to publish mass-build 317..." + + bl = BuildList.where(:mass_build_id => 73).first + platform_repository_folder = "#{bl.save_to_platform.path}/repository" + BuildList.where(:mass_build_id => 73). + where(:status => [ + BuildServer::SUCCESS, + BuildList::FAILED_PUBLISH + ]). + order(:id). + find_in_batches(:batch_size => 1) do | bls | + + bl = bls.first + puts "[#{Time.zone.now}] - where build_lists.id #{bl.id}" + + sha1 = bl.results.find{ |r| r['file_name'] =~ /.*\.tar\.gz$/ }['sha1'] + + system "cd #{platform_repository_folder} && curl -L -O http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}" + system "cd #{platform_repository_folder} && tar -xzf #{sha1}" + system "rm -f #{platform_repository_folder}/#{sha1}" + + archive_folder = "#{platform_repository_folder}/archives" + 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/*" + + system "sudo mv #{archive_folder}/SRC_RPM/* #{platform_repository_folder}/SRPMS/main/release/" + system "sudo mv #{archive_folder}/RPM/* #{platform_repository_folder}/#{bl.arch.name}/main/release/" + + system "sudo rm -rf #{archive_folder}" + bl.update_column(:status, BuildList::BUILD_PUBLISH) + end + + say "[#{Time.zone.now}] done" + end + end \ No newline at end of file