Merge branch 'master' into 90-pull
Conflicts: db/schema.rb
This commit is contained in:
commit
a316105e9c
|
@ -23,8 +23,11 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@product_build_list.destroy
|
if @product_build_list.destroy
|
||||||
flash[:notice] = t('flash.product.build_list_delete')
|
flash[:notice] = t('flash.product_build_list.delete')
|
||||||
|
else
|
||||||
|
flash[:error] = t('flash.product_build_list.delete_error')
|
||||||
|
end
|
||||||
redirect_to [@platform, @product]
|
redirect_to [@platform, @product]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,11 @@ class Projects::BuildListsController < Projects::BaseController
|
||||||
def create
|
def create
|
||||||
notices, errors = [], []
|
notices, errors = [], []
|
||||||
|
|
||||||
@repository = Repository.find params[:build_list][:save_to_repository_id]
|
@platform = Platform.includes(:repositories).find params[:build_list][:save_to_platform_id]
|
||||||
@platform = @repository.platform
|
|
||||||
params[:build_list][:save_to_platform_id] = @platform.id
|
@repository = @project.repositories.where(:id => @platform.repository_ids).first
|
||||||
|
|
||||||
|
params[:build_list][:save_to_repository_id] = @repository.id
|
||||||
params[:build_list][:auto_publish] = false if @platform.released
|
params[:build_list][:auto_publish] = false if @platform.released
|
||||||
|
|
||||||
Arch.where(:id => params[:arches]).each do |arch|
|
Arch.where(:id => params[:arches]).each do |arch|
|
||||||
|
|
|
@ -27,11 +27,9 @@ class BuildList < ActiveRecord::Base
|
||||||
validate lambda {
|
validate lambda {
|
||||||
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id)
|
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id)
|
||||||
}
|
}
|
||||||
validate lambda {
|
|
||||||
errors.add(:save_to_repository, I18n.t('flash.build_list.cannot_write')) unless current_user.can?(:write, save_to_repository)
|
|
||||||
}
|
|
||||||
|
|
||||||
LIVE_TIME = 3.week
|
LIVE_TIME = 4.week # for unpublished
|
||||||
|
MAX_LIVE_TIME = 3.month # for published
|
||||||
|
|
||||||
# The kernel does not send these statuses directly
|
# The kernel does not send these statuses directly
|
||||||
BUILD_CANCELED = 5000
|
BUILD_CANCELED = 5000
|
||||||
|
@ -100,7 +98,7 @@ class BuildList < ActiveRecord::Base
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
|
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
|
||||||
scope :outdated, where('updated_at < ? AND status <> ?', Time.now - LIVE_TIME, BUILD_PUBLISHED)
|
scope :outdated, where('created_at < ? AND status <> ? OR created_at < ?', Time.now - LIVE_TIME, BUILD_PUBLISHED, Time.now - MAX_LIVE_TIME)
|
||||||
|
|
||||||
serialize :additional_repos
|
serialize :additional_repos
|
||||||
serialize :include_repos
|
serialize :include_repos
|
||||||
|
|
|
@ -4,6 +4,7 @@ class MassBuild < ActiveRecord::Base
|
||||||
has_many :build_lists, :dependent => :destroy
|
has_many :build_lists, :dependent => :destroy
|
||||||
|
|
||||||
scope :by_platform, lambda { |platform| where(:platform_id => platform.id) }
|
scope :by_platform, lambda { |platform| where(:platform_id => platform.id) }
|
||||||
|
scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME)
|
||||||
|
|
||||||
attr_accessor :repositories, :arches
|
attr_accessor :repositories, :arches
|
||||||
attr_accessible :repositories, :arches, :auto_publish
|
attr_accessible :repositories, :arches, :auto_publish
|
||||||
|
|
|
@ -180,7 +180,7 @@ class Platform < ActiveRecord::Base
|
||||||
arches.map(&:name).each do |arch|
|
arches.map(&:name).each do |arch|
|
||||||
begin
|
begin
|
||||||
return if mass_build.reload.stop_build
|
return if mass_build.reload.stop_build
|
||||||
p.build_for(self, user, arch, auto_publish, mass_build_id)
|
p.build_for(self, rep.id, user, arch, auto_publish, mass_build_id)
|
||||||
rescue RuntimeError, Exception
|
rescue RuntimeError, Exception
|
||||||
# p.async(:build_for, self, user, arch, auto_publish, mass_build_id) # TODO need this?
|
# p.async(:build_for, self, user, arch, auto_publish, mass_build_id) # TODO need this?
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,7 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
scope :recent, order("#{table_name}.updated_at DESC")
|
scope :recent, order("#{table_name}.updated_at DESC")
|
||||||
|
|
||||||
after_create :xml_rpc_create
|
after_create :xml_rpc_create
|
||||||
|
before_destroy :can_destroy?
|
||||||
after_destroy :xml_delete_iso_container
|
after_destroy :xml_delete_iso_container
|
||||||
|
|
||||||
def container_path
|
def container_path
|
||||||
|
@ -49,6 +50,10 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
self.class.human_status(status)
|
self.class.human_status(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_destroy?
|
||||||
|
[BUILD_COMPLETED, BUILD_FAILED].include? status
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def xml_rpc_create
|
def xml_rpc_create
|
||||||
|
|
|
@ -24,10 +24,11 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^#{NAME_REGEXP}$/, :message => I18n.t("activerecord.errors.project.uname")}
|
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^#{NAME_REGEXP}$/, :message => I18n.t("activerecord.errors.project.uname")}
|
||||||
validates :owner, :presence => true
|
validates :owner, :presence => true
|
||||||
|
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
|
||||||
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
|
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
|
||||||
|
|
||||||
attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki
|
attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki
|
||||||
attr_readonly :name
|
attr_readonly :name, :owner_id, :owner_type
|
||||||
|
|
||||||
scope :recent, order("name ASC")
|
scope :recent, order("name ASC")
|
||||||
scope :search_order, order("CHAR_LENGTH(name) ASC")
|
scope :search_order, order("CHAR_LENGTH(name) ASC")
|
||||||
|
@ -84,13 +85,13 @@ class Project < ActiveRecord::Base
|
||||||
owner == user
|
owner == user
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_for(platform, user, arch = 'i586', auto_publish = false, mass_build_id = nil, priority = 0)
|
def build_for(platform, repository_id, user, arch = 'i586', auto_publish = false, mass_build_id = nil, priority = 0)
|
||||||
# Select main and project platform repository(contrib, non-free and etc)
|
# Select main and project platform repository(contrib, non-free and etc)
|
||||||
# If main does not exist, will connect only project platform repository
|
# If main does not exist, will connect only project platform repository
|
||||||
# If project platform repository is main, only main will be connect
|
# If project platform repository is main, only main will be connect
|
||||||
build_reps = [platform.repositories.find_by_name('main')]
|
main_rep_id = platform.repositories.find_by_name('main').id
|
||||||
build_reps += platform.repositories.select {|rep| self.repository_ids.include? rep.id}
|
build_reps_ids = [main_rep_id, repository_id].compact.uniq
|
||||||
build_reps_ids = build_reps.compact.map(&:id).uniq
|
|
||||||
arch = Arch.find_by_name(arch) if arch.acts_like?(:string)
|
arch = Arch.find_by_name(arch) if arch.acts_like?(:string)
|
||||||
build_lists.create do |bl|
|
build_lists.create do |bl|
|
||||||
bl.save_to_platform = platform
|
bl.save_to_platform = platform
|
||||||
|
@ -104,6 +105,7 @@ class Project < ActiveRecord::Base
|
||||||
bl.include_repos = build_reps_ids
|
bl.include_repos = build_reps_ids
|
||||||
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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
%td= product_build_list.human_status
|
%td= product_build_list.human_status
|
||||||
%td= link_to nil, product_build_list.container_path
|
%td= link_to nil, product_build_list.container_path
|
||||||
%td= link_to product_build_list.product.name, platform_product_path(product_build_list.product.platform, product_build_list.product)
|
%td= link_to product_build_list.product.name, platform_product_path(product_build_list.product.platform, product_build_list.product)
|
||||||
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(product_build_list.product.platform, product_build_list.product, product_build_list), :method => :delete, :confirm => t("layout.confirm") if can? :destroy, product_build_list
|
- pbl = product_build_list
|
||||||
|
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl), :method => :delete, :confirm => t("layout.confirm") if can?(:destroy, pbl) && pbl.can_destroy?
|
||||||
%td= l(product_build_list.updated_at, :format => :long)
|
%td= l(product_build_list.updated_at, :format => :long)
|
|
@ -3,6 +3,6 @@
|
||||||
%td= build_list.human_status
|
%td= build_list.human_status
|
||||||
%td= link_to build_list.project.name_with_owner, build_list.project
|
%td= link_to build_list.project.name_with_owner, build_list.project
|
||||||
%td= build_list_version_link(build_list)
|
%td= build_list_version_link(build_list)
|
||||||
%td= link_to build_list.save_to_platform.name, build_list.save_to_platform
|
%td= link_to "#{build_list.save_to_platform.name}/#{build_list.save_to_repository.name}", [build_list.save_to_platform, build_list.save_to_repository]
|
||||||
%td= build_list.arch.name
|
%td= build_list.arch.name
|
||||||
%td= link_to build_list.user.try(:fullname), build_list.user
|
%td= link_to build_list.user.try(:fullname), build_list.user
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
%th.lpadding16= t("activerecord.attributes.build_list.status")
|
%th.lpadding16= t("activerecord.attributes.build_list.status")
|
||||||
%th.lpadding16= t("activerecord.attributes.build_list.project")
|
%th.lpadding16= t("activerecord.attributes.build_list.project")
|
||||||
%th.lpadding16= t("activerecord.attributes.build_list.project_version")
|
%th.lpadding16= t("activerecord.attributes.build_list.project_version")
|
||||||
%th.lpadding16= t("activerecord.attributes.build_list.save_to_platform")
|
%th.lpadding16= t("activerecord.attributes.build_list.save_to_repository")
|
||||||
%th.lpadding16= t("activerecord.attributes.build_list.arch")
|
%th.lpadding16= t("activerecord.attributes.build_list.arch")
|
||||||
%th.lpadding16= t("activerecord.attributes.build_list.user")
|
%th.lpadding16= t("activerecord.attributes.build_list.user")
|
||||||
%tbody= render :partial => 'projects/build_lists/build_list', :collection => @build_lists
|
%tbody= render :partial => 'projects/build_lists/build_list', :collection => @build_lists
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
.offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl
|
.offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl
|
||||||
%section.right
|
%section.right
|
||||||
%h3= t("activerecord.attributes.build_list.save_to_platform")
|
%h3= t("activerecord.attributes.build_list.save_to_platform")
|
||||||
.lineForm= f.select :save_to_repository_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.id]}
|
.lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}
|
||||||
%h3= t("activerecord.attributes.build_list.project_version")
|
%h3= t("activerecord.attributes.build_list.project_version")
|
||||||
.lineForm= f.select :project_version, versions_for_group_select(@project), :selected => params[:build_list].try(:fetch, :project_version) || "latest_" + @project.default_branch
|
.lineForm= f.select :project_version, versions_for_group_select(@project), :selected => params[:build_list].try(:fetch, :project_version) || "latest_" + @project.default_branch
|
||||||
%h3= t("activerecord.attributes.build_list.arch")
|
%h3= t("activerecord.attributes.build_list.arch")
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
.leftlist= t("activerecord.attributes.build_list.container_path")
|
.leftlist= t("activerecord.attributes.build_list.container_path")
|
||||||
.rightlist
|
.rightlist
|
||||||
- if @build_list.status == BuildList::BUILD_PUBLISHED
|
- if @build_list.status == BuildList::BUILD_PUBLISHED
|
||||||
= t("layout.build_lists.container_published")
|
= raw "%s %s" % [t("layout.build_lists.container_published"),
|
||||||
|
link_to("#{@build_list.save_to_platform.name}/#{@build_list.save_to_repository.name}",
|
||||||
|
[@build_list.save_to_platform, @build_list.save_to_repository])]
|
||||||
- elsif @build_list.container_path.present?
|
- elsif @build_list.container_path.present?
|
||||||
- container_url = "http://#{request.host_with_port}/downloads#{@build_list.container_path}"
|
- container_url = "http://#{request.host_with_port}/downloads#{@build_list.container_path}"
|
||||||
= link_to container_url, container_url
|
= link_to container_url, container_url
|
||||||
|
@ -26,11 +28,9 @@
|
||||||
.rightlist
|
.rightlist
|
||||||
= link_to @build_list.build_for_platform.name, @build_list.build_for_platform
|
= link_to @build_list.build_for_platform.name, @build_list.build_for_platform
|
||||||
.both
|
.both
|
||||||
.leftlist= t("activerecord.attributes.build_list.save_to_platform")
|
.leftlist= t("activerecord.attributes.build_list.save_to_repository")
|
||||||
.rightlist
|
.rightlist
|
||||||
= link_to @build_list.save_to_platform.name, @build_list.save_to_platform
|
= link_to "#{@build_list.save_to_platform.name}/#{@build_list.save_to_repository.name}", [@build_list.save_to_platform, @build_list.save_to_repository]
|
||||||
\/
|
|
||||||
= link_to @build_list.save_to_repository.name, [@build_list.save_to_platform, @build_list.save_to_repository]
|
|
||||||
.both
|
.both
|
||||||
.leftlist= t("activerecord.attributes.build_list.include_repos")
|
.leftlist= t("activerecord.attributes.build_list.include_repos")
|
||||||
.rightlist= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ')
|
.rightlist= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ')
|
||||||
|
|
|
@ -19,6 +19,7 @@ en:
|
||||||
include_repos: Included repositories
|
include_repos: Included repositories
|
||||||
created_at: Created on
|
created_at: Created on
|
||||||
save_to_platform: Platform
|
save_to_platform: Platform
|
||||||
|
save_to_repository: Repository
|
||||||
build_for_platform: Build for platform
|
build_for_platform: Build for platform
|
||||||
update_type: Update type
|
update_type: Update type
|
||||||
build_requires: Build with all the required packages
|
build_requires: Build with all the required packages
|
||||||
|
|
|
@ -19,6 +19,7 @@ ru:
|
||||||
include_repos: Подключаемые репозитории
|
include_repos: Подключаемые репозитории
|
||||||
created_at: Создан
|
created_at: Создан
|
||||||
save_to_platform: Платформа
|
save_to_platform: Платформа
|
||||||
|
save_to_repository: Репозиторий
|
||||||
build_for_platform: Собрано для платформы
|
build_for_platform: Собрано для платформы
|
||||||
update_type: Критичность обновления
|
update_type: Критичность обновления
|
||||||
build_requires: Пересборка с зависимостями
|
build_requires: Пересборка с зависимостями
|
||||||
|
|
|
@ -33,7 +33,6 @@ en:
|
||||||
save_error: Unable to save product
|
save_error: Unable to save product
|
||||||
build_started: Product build started
|
build_started: Product build started
|
||||||
destroyed: Product deleted
|
destroyed: Product deleted
|
||||||
build_list_delete: Product build list deleted
|
|
||||||
|
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
|
|
@ -33,7 +33,6 @@ ru:
|
||||||
save_error: Не удалось сохранить изменения
|
save_error: Не удалось сохранить изменения
|
||||||
build_started: Запущена сборка продукта
|
build_started: Запущена сборка продукта
|
||||||
destroyed: Продукт удален
|
destroyed: Продукт удален
|
||||||
build_list_delete: Сборочный лист продукта удален
|
|
||||||
|
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
|
|
@ -25,6 +25,10 @@ en:
|
||||||
product: Product
|
product: Product
|
||||||
container_path: Container
|
container_path: Container
|
||||||
status: Status
|
status: Status
|
||||||
notified_at: Notified at
|
|
||||||
user: User
|
user: User
|
||||||
notified_at: Notified at
|
notified_at: Notified at
|
||||||
|
|
||||||
|
flash:
|
||||||
|
product_build_list:
|
||||||
|
delete: Product build list deleted
|
||||||
|
delete_error: Unable to delete product build list
|
|
@ -28,3 +28,8 @@ ru:
|
||||||
user: Пользователь
|
user: Пользователь
|
||||||
notified_at: Информация получена
|
notified_at: Информация получена
|
||||||
|
|
||||||
|
flash:
|
||||||
|
product_build_list:
|
||||||
|
delete: Сборочный лист продукта удален
|
||||||
|
delete_error: Не удалось удалить cборочный лист продукта
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ base_path = "/srv/rosa_build"
|
||||||
|
|
||||||
rails_env = ENV['RAILS_ENV'] || 'production'
|
rails_env = ENV['RAILS_ENV'] || 'production'
|
||||||
|
|
||||||
worker_processes 4
|
worker_processes 8
|
||||||
working_directory File.join(base_path, 'current') # available in 0.94.0+
|
working_directory File.join(base_path, 'current') # available in 0.94.0+
|
||||||
|
|
||||||
# listen File.join(base_path, 'tmp', 'pids', 'unicorn.sock')
|
# listen File.join(base_path, 'tmp', 'pids', 'unicorn.sock')
|
||||||
|
|
|
@ -9,9 +9,11 @@ class AddSaveToRepositoryToBuildLists < ActiveRecord::Migration
|
||||||
platform = bl.save_to_platform
|
platform = bl.save_to_platform
|
||||||
|
|
||||||
rep = (project.repositories.map(&:id) & platform.repositories.map(&:id)).first
|
rep = (project.repositories.map(&:id) & platform.repositories.map(&:id)).first
|
||||||
|
|
||||||
bl.save_to_repository_id = rep
|
bl.save_to_repository_id = rep
|
||||||
bl.save
|
bl.save!
|
||||||
rescue
|
rescue Exception => e
|
||||||
|
puts e.inspect
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,15 +2,19 @@
|
||||||
namespace :buildlist do
|
namespace :buildlist do
|
||||||
|
|
||||||
namespace :clear do
|
namespace :clear do
|
||||||
desc 'Remove outdated unpublished BuildLists'
|
desc 'Remove outdated BuildLists and MassBuilds'
|
||||||
task :outdated => :environment do
|
task :outdated => :environment do
|
||||||
say "Removing outdated BuildLists"
|
say "Removing outdated BuildLists"
|
||||||
outdated = BuildList.outdated
|
outdated = BuildList.outdated
|
||||||
say "There are #{outdated.count} outdated BuildLists at #{Time.now}"
|
say "There are #{outdated.count} outdated BuildLists at #{Time.now}"
|
||||||
|
|
||||||
BuildList.outdated.destroy_all
|
BuildList.outdated.destroy_all
|
||||||
|
|
||||||
say "Outdated BuildLists was successfully removed"
|
say "Removing outdated MassBuilds"
|
||||||
|
outdated = MassBuild.outdated
|
||||||
|
say "There are #{outdated.count} outdated MassBuilds at #{Time.now}"
|
||||||
|
MassBuild.outdated.destroy_all
|
||||||
|
|
||||||
|
say "Outdated BuildLists and MassBuilds was successfully removed"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue