diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 16f8ca298..97bf9437d 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -190,12 +190,12 @@ class Projects::BuildListsController < Projects::BaseController def create_from_build_list return if params[:build_list_id].blank? - build_list = BuildList.find(params[:build_list_id]) + @build_list = @project.build_lists.find(params[:build_list_id]) params[:build_list] ||= {} keys = [:save_to_repository_id, :auto_publish_status, :include_repos, :extra_params, :project_version, :update_type, :auto_create_container, - :extra_repositories, :extra_build_lists, :build_for_platform_id] + :extra_repositories, :extra_build_lists, :build_for_platform_id, :use_cached_chroot] keys.each { |key| params[:build_list][key] = build_list.send(key) } params[:arches] = [build_list.arch_id.to_s] [:owner_filter, :status_filter].each { |t| params[t] = 'true' if %w(true undefined).exclude? params[t] } diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 83e10413a..9ac0694ec 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -30,8 +30,15 @@ class BuildList < ActiveRecord::Base AUTO_PUBLISH_STATUS_TESTING = 'testing' AUTO_PUBLISH_STATUSES = [AUTO_PUBLISH_STATUS_NONE, AUTO_PUBLISH_STATUS_DEFAULT, AUTO_PUBLISH_STATUS_TESTING] - validates :project_id, :project_version, :arch, :include_repos, - :build_for_platform_id, :save_to_platform_id, :save_to_repository_id, presence: true + validates :project_id, + :project_version, + :arch, + :include_repos, + :build_for_platform_id, + :save_to_platform_id, + :use_cached_chroot, + :save_to_repository_id, + presence: true validates_numericality_of :priority, greater_than_or_equal_to: 0 validates :external_nodes, inclusion: { in: EXTERNAL_NODES }, allow_blank: true validates :auto_publish_status, inclusion: { in: AUTO_PUBLISH_STATUSES } @@ -64,7 +71,8 @@ class BuildList < ActiveRecord::Base :arch_id, :project_id, :save_to_repository_id, :update_type, :save_to_platform_id, :project_version, :auto_create_container, :extra_repositories, :extra_build_lists, :extra_params, :external_nodes, - :include_testing_subrepository, :auto_publish_status + :include_testing_subrepository, :auto_publish_status, + :use_cached_chroot LIVE_TIME = 4.week # for unpublished MAX_LIVE_TIME = 3.month # for published @@ -508,6 +516,7 @@ class BuildList < ActiveRecord::Base cmd_params = { 'GIT_PROJECT_ADDRESS' => git_project_address, 'COMMIT_HASH' => commit_hash, + 'USE_CACHED_CHROOT' => use_cached_chroot?, 'EXTRA_CFG_OPTIONS' => extra_params['cfg_options'], 'EXTRA_CFG_URPM_OPTIONS' => extra_params['cfg_urpm_options'], 'EXTRA_BUILD_SRC_RPM_OPTIONS' => extra_params['build_src_rpm'], diff --git a/app/views/api/v1/build_lists/show.json.jbuilder b/app/views/api/v1/build_lists/show.json.jbuilder index 2e7718912..0d8d119c3 100644 --- a/app/views/api/v1/build_lists/show.json.jbuilder +++ b/app/views/api/v1/build_lists/show.json.jbuilder @@ -2,7 +2,7 @@ json.build_list do json.(@build_list, :id, :container_status, :status, :duration) json.(@build_list, :update_type, :priority, :new_core) json.(@build_list, :advisory, :mass_build) - json.(@build_list, :auto_publish_status, :package_version, :commit_hash, :last_published_commit_hash, :auto_create_container) + json.(@build_list, :auto_publish_status, :package_version, :commit_hash, :last_published_commit_hash, :auto_create_container, :use_cached_chroot) json.build_log_url log_build_list_path(@build_list) if @build_list.container_published? diff --git a/app/views/projects/build_lists/_new_form.html.haml b/app/views/projects/build_lists/_new_form.html.haml index 2b60680c1..6e319d2c5 100644 --- a/app/views/projects/build_lists/_new_form.html.haml +++ b/app/views/projects/build_lists/_new_form.html.haml @@ -46,12 +46,9 @@ - selected = params[:build_list].try(:[], :auto_publish_status) ? {selected: params[:build_list][:auto_publish_status]} : {} = f.select :auto_publish_status, auto_publish_statuses, selected = f.label :auto_publish_status - .both - - %i(auto_create_container include_testing_subrepository).each do |kind| + - %i(auto_create_container include_testing_subrepository use_cached_chroot).each do |kind| .both - - checked, field = params[:build_list].try(:[], kind), "build_list[#{kind}]" - = hidden_field_tag field, false, id: nil - = check_box_tag field, true, checked + = f.check_box kind = f.label kind .both - selected = params[:build_list].try(:[], :external_nodes) ? {selected: params[:build_list][:external_nodes]} : {} diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 4215b6d25..fcf3241d1 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -63,6 +63,9 @@ .leftlist= t("activerecord.attributes.build_list.auto_create_container") .rightlist= t("layout.#{@build_list.auto_create_container?}_") .both + .leftlist= t("activerecord.attributes.build_list.use_cached_chroot") + .rightlist= t("layout.#{@build_list.use_cached_chroot?}_") + .both .leftlist= t("activerecord.attributes.build_list.project_version") .rightlist= link_to @build_list.project_version, tree_path(@build_list.project, @build_list.project_version) .both diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 651c6a10d..da920d984 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -10,6 +10,7 @@ en: extra_repositories: Extra repositories extra_build_lists: Extra build lists auto_create_container: Create container automatically + use_cached_chroot: Use cached chroot container_path: Container path status: Status project_id: Project diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index c20f0b33d..4ea7165e5 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -10,6 +10,7 @@ ru: extra_repositories: Дополнительные репозитории extra_build_lists: Дополнительные сборки auto_create_container: Создать контейнер автоматически + use_cached_chroot: Использовать кэшированный chroot container_path: Путь до контейнера status: Статус project_id: Проект diff --git a/db/migrate/20140407181059_add_use_cached_chroot_to_build_list.rb b/db/migrate/20140407181059_add_use_cached_chroot_to_build_list.rb new file mode 100644 index 000000000..8909c5e83 --- /dev/null +++ b/db/migrate/20140407181059_add_use_cached_chroot_to_build_list.rb @@ -0,0 +1,11 @@ +class AddUseCachedChrootToBuildList < ActiveRecord::Migration + def change + # Make existing build_lists 'false', but default to 'true' in the future. + add_column :build_lists, :use_cached_chroot, :boolean, null: false, default: false + change_column :build_lists, :use_cached_chroot, :boolean, null: false, default: true + end + + def down + remove_column :build_lists, :use_cached_chroot + end +end diff --git a/db/schema.rb b/db/schema.rb index f7f7e1d11..59c1f068d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140306102620) do +ActiveRecord::Schema.define(version: 20140407181059) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -140,6 +140,7 @@ ActiveRecord::Schema.define(version: 20140306102620) do t.integer "builder_id" t.boolean "include_testing_subrepository" t.string "auto_publish_status", default: "default", null: false + t.boolean "use_cached_chroot", default: true, null: false t.index ["advisory_id"], :name => "index_build_lists_on_advisory_id" t.index ["arch_id"], :name => "index_build_lists_on_arch_id" t.index ["mass_build_id", "status"], :name => "index_build_lists_on_mass_build_id_and_status"