#373: added use_cached_chroot field to MassBuild

This commit is contained in:
Vokhmin Alexey V 2014-05-12 23:55:13 +04:00
parent b90aa0f50e
commit 44cbfe6191
9 changed files with 52 additions and 24 deletions

View File

@ -2,36 +2,48 @@ class MassBuild < ActiveRecord::Base
belongs_to :build_for_platform, -> { where(platform_type: 'main') }, class_name: 'Platform' belongs_to :build_for_platform, -> { where(platform_type: 'main') }, class_name: 'Platform'
belongs_to :save_to_platform, class_name: 'Platform' belongs_to :save_to_platform, class_name: 'Platform'
belongs_to :user belongs_to :user
has_many :build_lists, dependent: :destroy has_many :build_lists, dependent: :destroy
serialize :extra_repositories, Array serialize :extra_repositories, Array
serialize :extra_build_lists, Array serialize :extra_build_lists, Array
scope :recent, -> { order(created_at: :desc) } scope :recent, -> { order(created_at: :desc) }
scope :by_platform, ->(platform) { where(save_to_platform_id: platform.id) } scope :by_platform, -> (platform) { where(save_to_platform_id: platform.id) }
scope :outdated, -> { where("#{table_name}.created_at < ?", Time.now + 1.day - BuildList::MAX_LIVE_TIME) } scope :outdated, -> { where("#{table_name}.created_at < ?", Time.now + 1.day - BuildList::MAX_LIVE_TIME) }
attr_accessor :arches attr_accessor :arches
attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id, attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id,
:extra_repositories, :extra_build_lists, :increase_release_tag :extra_repositories, :extra_build_lists, :increase_release_tag,
:use_cached_chroot
validates :save_to_platform_id, :build_for_platform_id, :arch_names, :name, :user_id, presence: true validates :save_to_platform_id,
validates :projects_list, length: {maximum: 500_000}, presence: true :build_for_platform_id,
validates_inclusion_of :auto_publish, :increase_release_tag, in: [true, false] :arch_names,
:name,
:user_id, presence: true
validates :projects_list,
presence: true,
length: { maximum: 500_000 }
validates :auto_publish,
:increase_release_tag,
:use_cached_chroot,
inclusion: { in: [true, false] }
after_commit :build_all, on: :create after_commit :build_all, on: :create
before_validation :set_data, on: :create before_validation :set_data, on: :create
COUNT_STATUSES = [ COUNT_STATUSES = %i(
:build_lists, build_lists
:build_published, build_published
:build_pending, build_pending
:build_started, build_started
:build_publish, build_publish
:build_error, build_error
:success, success
:build_canceled build_canceled
] )
def build_all def build_all
# later with resque # later with resque
@ -47,7 +59,7 @@ class MassBuild < ActiveRecord::Base
increase_rt = increase_release_tag? increase_rt = increase_release_tag?
arches_list.each do |arch| arches_list.each do |arch|
rep_id = (project.repository_ids & save_to_platform.repository_ids).first rep_id = (project.repository_ids & save_to_platform.repository_ids).first
project.build_for self, rep_id, arch, 0, increase_rt project.build_for(self, rep_id, arch, 0, increase_rt, use_cached_chroot)
increase_rt = false increase_rt = false
end end
rescue RuntimeError, Exception rescue RuntimeError, Exception

View File

@ -166,7 +166,7 @@ class Project < ActiveRecord::Base
#path #share by NFS #path #share by NFS
end end
def build_for(mass_build, repository_id, arch = Arch.find_by(name: 'i586'), priority = 0, increase_rt = false) def build_for(mass_build, repository_id, arch = Arch.find_by(name: 'i586'), priority = 0, increase_rt = false, use_cached_chroot = false)
build_for_platform = mass_build.build_for_platform build_for_platform = mass_build.build_for_platform
save_to_platform = mass_build.save_to_platform save_to_platform = mass_build.save_to_platform
user = mass_build.user user = mass_build.user
@ -194,6 +194,7 @@ class Project < ActiveRecord::Base
bl.priority = priority bl.priority = priority
bl.mass_build_id = mass_build.id bl.mass_build_id = mass_build.id
bl.save_to_repository_id = repository_id bl.save_to_repository_id = repository_id
bl.use_cached_chroot = use_cached_chroot
end end
build_list.save build_list.save
end end

View File

@ -53,7 +53,7 @@
.toggle{id: "toggle_#{ mass_build.id }"} .toggle{id: "toggle_#{ mass_build.id }"}
= t('activerecord.attributes.mass_build.user') + ": " = t('activerecord.attributes.mass_build.user') + ": "
= link_to mass_build.user.fullname, mass_build.user = link_to mass_build.user.fullname, mass_build.user
- [:arch_names, :auto_publish, :increase_release_tag, :created_at].each do |field| - %i(arch_names auto_publish increase_release_tag use_cached_chroot created_at).each do |field|
.both .both
= t("activerecord.attributes.mass_build.#{field}") + ": " = t("activerecord.attributes.mass_build.#{field}") + ": "
= mass_build.send field = mass_build.send field

View File

@ -40,7 +40,7 @@
subject: @mass_build, subject: @mass_build,
autocomplete_path: autocomplete_extra_build_list_autocompletes_path autocomplete_path: autocomplete_extra_build_list_autocompletes_path
%h3= t("activerecord.attributes.build_list.preferences") %h3= t("activerecord.attributes.build_list.preferences")
- [:auto_publish, :increase_release_tag].each do |field| - %i(auto_publish increase_release_tag use_cached_chroot).each do |field|
.both .both
= f.check_box field = f.check_box field
= f.label field = f.label field

View File

@ -27,5 +27,6 @@ en:
user: User user: User
auto_publish: Automated publishing auto_publish: Automated publishing
increase_release_tag: Increase release tag increase_release_tag: Increase release tag
use_cached_chroot: Use cached chroot
repositories: Repositories repositories: Repositories
projects_list: Projects list projects_list: Projects list

View File

@ -27,5 +27,6 @@ ru:
user: Пользователь user: Пользователь
auto_publish: Автоматическая публикация auto_publish: Автоматическая публикация
increase_release_tag: Увеличить release тег increase_release_tag: Увеличить release тег
use_cached_chroot: Использовать кэшированный chroot
repositories: Репозитории repositories: Репозитории
projects_list: Список проектов projects_list: Список проектов

View File

@ -1,5 +1,5 @@
class AddUseCachedChrootToBuildList < ActiveRecord::Migration class AddUseCachedChrootToBuildList < ActiveRecord::Migration
def change def up
# Make existing build_lists 'false', but default to 'true' in the future. # Make existing build_lists 'false', but default to 'true' in the future.
add_column :build_lists, :use_cached_chroot, :boolean, null: false, default: false add_column :build_lists, :use_cached_chroot, :boolean, null: false, default: false
change_column :build_lists, :use_cached_chroot, :boolean, null: false, default: true change_column :build_lists, :use_cached_chroot, :boolean, null: false, default: true

View File

@ -0,0 +1,12 @@
class AddUseCachedChrootToMassBuild < ActiveRecord::Migration
def up
# Make existing mass_builds 'false', but default to 'true' in the future.
add_column :mass_builds, :use_cached_chroot, :boolean, null: false, default: false
change_column :mass_builds, :use_cached_chroot, :boolean, null: false, default: true
end
def down
remove_column :mass_builds, :use_cached_chroot
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140512091135) do ActiveRecord::Schema.define(version: 20140512183926) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -323,6 +323,7 @@ ActiveRecord::Schema.define(version: 20140512091135) do
t.text "extra_repositories" t.text "extra_repositories"
t.text "extra_build_lists" t.text "extra_build_lists"
t.boolean "increase_release_tag", default: false, null: false t.boolean "increase_release_tag", default: false, null: false
t.boolean "use_cached_chroot", default: true, null: false
end end
create_table "users", force: true do |t| create_table "users", force: true do |t|