#755: small refactoring

This commit is contained in:
Vokhmin Alexey V 2012-12-13 16:30:37 +04:00
parent 1bebdb34db
commit 4e1aa466fd
6 changed files with 21 additions and 21 deletions

View File

@ -427,7 +427,7 @@ class BuildList < ActiveRecord::Base
end
if save_to_platform.personal?
include_repos_hash["#{save_to_platform.name}_release"] = save_to_platform.
urpmi_list(nil, nil, false)["#{build_for_platform.name}"]["#{arch.name}"]
urpmi_list(nil, nil, false, save_to_repository.name)["#{build_for_platform.name}"]["#{arch.name}"]
end
# mdv example:
# https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git

View File

@ -58,7 +58,7 @@ class Platform < ActiveRecord::Base
system("rm -Rf #{ APP_CONFIG['root_path'] }/platforms/#{ self.name }/repository/*")
end
def urpmi_list(host = nil, pair = nil, add_commands = true)
def urpmi_list(host = nil, pair = nil, add_commands = true, repository_name = 'main')
host ||= default_host
blank_pair = {:login => 'login', :pass => 'password'}
pair = blank_pair if pair.blank?
@ -69,7 +69,7 @@ class Platform < ActiveRecord::Base
local_pair = pl.id != self.id ? blank_pair : pair
head = hidden? ? "http://#{local_pair[:login]}@#{local_pair[:pass]}:#{host}/private/" : "http://#{host}/downloads/"
Arch.all.each do |arch|
tail = "/#{arch.name}/main/release"
tail = "/#{arch.name}/#{repository_name}/release"
command = add_commands ? "urpmi.addmedia #{name} " : ''
command << "#{head}#{name}/repository/#{pl.name}#{tail}"
urpmi_commands[pl.name][arch.name] = command

View File

@ -1,10 +1,10 @@
module AbfWorker
class BaseObserver
BUILD_COMPLETED = 0
BUILD_FAILED = 1
BUILD_PENDING = 2
BUILD_STARTED = 3
BUILD_CANCELED = 4
COMPLETED = 0
FAILED = 1
PENDING = 2
STARTED = 3
CANCELED = 4
def self.update_results(subject, options)
results = (subject.results || []) + options['results']

View File

@ -6,16 +6,16 @@ module AbfWorker
status = options['status'].to_i
pbl = ProductBuildList.find options['id']
case status
when BUILD_COMPLETED
when COMPLETED
pbl.build_success
when BUILD_FAILED
when FAILED
pbl.build_error
when BUILD_STARTED
when STARTED
pbl.start_build
when BUILD_CANCELED
when CANCELED
pbl.build_canceled
end
if status != BUILD_STARTED
if status != STARTED
update_results(pbl, options)
end
end

View File

@ -6,13 +6,13 @@ module AbfWorker
bl = BuildList.find options['id']
status = options['status'].to_i
case status
when BUILD_COMPLETED
when COMPLETED
bl.published
update_results(bl, options)
when BUILD_FAILED
when FAILED
bl.fail_publish
update_results(bl, options)
when BUILD_CANCELED
when CANCELED
bl.fail_publish
update_results(bl, options)
end

View File

@ -7,21 +7,21 @@ module AbfWorker
status = options['status'].to_i
item = find_or_create_item(bl)
fill_container_data(bl, options) if status != BUILD_STARTED
fill_container_data(bl, options) if status != STARTED
case status
when BUILD_COMPLETED
when COMPLETED
bl.build_success
item.update_attributes({:status => BuildServer::SUCCESS})
bl.now_publish if bl.auto_publish?
when BUILD_FAILED
when FAILED
bl.build_error
item.update_attributes({:status => BuildServer::BUILD_ERROR})
when BUILD_STARTED
when STARTED
bl.bs_id = bl.id
bl.save!
bl.start_build
when BUILD_CANCELED
when CANCELED
bl.build_canceled
item.update_attributes({:status => BuildList::BUILD_CANCELED})
end