From 41ae79eb4675e92c79dfd9cea475da507f2d682c Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 8 Mar 2012 01:25:17 +0200 Subject: [PATCH 1/2] Add configurable arch parameter to project build_for method. Write rake task for projects build. Refs #282 --- app/models/project.rb | 5 +++-- lib/tasks/build.rake | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 lib/tasks/build.rake diff --git a/app/models/project.rb b/app/models/project.rb index 08e487864..edc3d9a8e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -61,12 +61,13 @@ class Project < ActiveRecord::Base end end - def build_for(platform, user) + def build_for(platform, user, arch = 'x86_64') # Return i586 after mass rebuild + arch = Arch.find_by_name(arch) if arch.acts_like?(:string) build_lists.create do |bl| bl.pl = platform bl.bpl = platform bl.update_type = 'newpackage' - bl.arch = Arch.find_by_name('x86_64') # Return i586 after mass rebuild + bl.arch = arch bl.project_version = "latest_#{platform.name}" # "latest_import_mandriva2011" bl.build_requires = false # already set as db default bl.user = user diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake new file mode 100644 index 000000000..c1b057ed0 --- /dev/null +++ b/lib/tasks/build.rake @@ -0,0 +1,25 @@ +require 'highline/import' +require 'open-uri' + +namespace :build do + desc "Build projects from list" + task :projects => :environment do + source = ENV['SOURCE'] || 'http://dl.dropbox.com/u/984976/rebuild_list.txt' + user = User.find_by_uname(ENV['USER'] || 'warpc') + platform = Platform.find_by_name(ENV['PLATFORM'] || 'rosa2012lts') + arch = Arch.find_by_name(ENV['ARCH'] || 'i586') + + say "START build projects from #{source} for platform=#{platform.name}, user=#{user.uname}, arch=#{arch.name}" + open(source).readlines.each do |name| + name.chomp!; name.strip! #; name.downcase! + if p = Project.joins(:repositories).where('repositories.id IN (?)', platform.repositories).find_by_name(name) + p.build_for(platform, user, arch) + say "== Build #{p.name} ==" + else + say "== Not found #{name} ==" + end + sleep 0.2 + end + say 'DONE' + end +end From f6a91ec006ffe9d641b4a6307adcf20e496f07cd Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 8 Mar 2012 01:47:48 +0200 Subject: [PATCH 2/2] Fix rake task. Refs #282 --- lib/tasks/build.rake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake index c1b057ed0..b431fd2af 100644 --- a/lib/tasks/build.rake +++ b/lib/tasks/build.rake @@ -5,15 +5,15 @@ namespace :build do desc "Build projects from list" task :projects => :environment do source = ENV['SOURCE'] || 'http://dl.dropbox.com/u/984976/rebuild_list.txt' - user = User.find_by_uname(ENV['USER'] || 'warpc') - platform = Platform.find_by_name(ENV['PLATFORM'] || 'rosa2012lts') - arch = Arch.find_by_name(ENV['ARCH'] || 'i586') + owner = User.find_by_uname!(ENV['OWNER'] || 'warpc') + platform = Platform.find_by_name!(ENV['PLATFORM'] || 'rosa2012lts') + arch = Arch.find_by_name!(ENV['ARCH'] || 'i586') - say "START build projects from #{source} for platform=#{platform.name}, user=#{user.uname}, arch=#{arch.name}" + say "START build projects from #{source} for platform=#{platform.name}, owner=#{owner.uname}, arch=#{arch.name}" open(source).readlines.each do |name| name.chomp!; name.strip! #; name.downcase! if p = Project.joins(:repositories).where('repositories.id IN (?)', platform.repositories).find_by_name(name) - p.build_for(platform, user, arch) + p.build_for(platform, owner, arch) say "== Build #{p.name} ==" else say "== Not found #{name} =="