From 41ae79eb4675e92c79dfd9cea475da507f2d682c Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 8 Mar 2012 01:25:17 +0200 Subject: [PATCH] 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