You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
require_relative "spork"
|
|
require_relative "runner"
|
|
require "fileutils"
|
|
|
|
#
|
|
#mock -r /home/alexey/workspace/ruby-projects/mock-gui/projects/prjt1.prj/configs/prjt1.cfg --buildsrpm --spec srcprp/bayrepo_neuro_farm.spec --sources srcprp/ --resultdir result/ --isolation=simple --disable-plugin=ccache
|
|
#mock -r /home/alexey/workspace/ruby-projects/mock-gui/projects/prjt1.prj/configs/prjt1.cfg result/bayrepo-neuro-farm-0.1-2.src.rpm --resultdir result2/ --isolation simple
|
|
|
|
class MockManager
|
|
attr :path, :config, :error, :last_status, :last_pid, :prep_dir, :db, :resultpath, :process_log, :repo_path
|
|
|
|
def initialize(path, config, cfg_counter_path, db, result_path, repo_path)
|
|
@error = nil
|
|
unless File.exist? (path)
|
|
Dir.mkdir(path)
|
|
end
|
|
@path = path
|
|
@config = config
|
|
cntr = 0
|
|
@db = db
|
|
@resultpath = result_path
|
|
@repo_path = repo_path
|
|
|
|
File.open(cfg_counter_path, "r+") do |f|
|
|
f.flock(File::LOCK_EX)
|
|
counter = f.gets.strip
|
|
i_counter = counter.to_i
|
|
i_counter = i_counter + 1
|
|
f.puts("#{i_counter}")
|
|
cnt = i_counter
|
|
end
|
|
tmp_name = (0...10).map { ("a".."z").to_a[rand(26)] }.join
|
|
@prep_dir = File.join(path, "#{cntr}_#{tmp_name}")
|
|
@process_log = File.join(@prep_dir, "process.log")
|
|
Dir.mkdir(@prep_dir)
|
|
FileUtils.touch(@process_log)
|
|
end
|
|
|
|
def get_build_process_log()
|
|
@process_log
|
|
end
|
|
|
|
def finalize_build_task()
|
|
FileUtils.rm_rf(@path)
|
|
end
|
|
|
|
def build_task()
|
|
finalize_build_task
|
|
end
|
|
end
|