mock build.Part 2
This commit is contained in:
@@ -46,6 +46,7 @@ class MockManager
|
|||||||
Dir.mkdir(@prep_dir)
|
Dir.mkdir(@prep_dir)
|
||||||
FileUtils.touch(@process_log)
|
FileUtils.touch(@process_log)
|
||||||
@log = nil
|
@log = nil
|
||||||
|
@tmp_src = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_build_process_log()
|
def get_build_process_log()
|
||||||
@@ -70,8 +71,9 @@ class MockManager
|
|||||||
@log.info("Подготовка исходных файлов проекта к формированию SRPMS")
|
@log.info("Подготовка исходных файлов проекта к формированию SRPMS")
|
||||||
if File.exist?(@git_path)
|
if File.exist?(@git_path)
|
||||||
if File.directory?(@git_path)
|
if File.directory?(@git_path)
|
||||||
FileUtils.cp_r(@git_path, File.join(@prep_dir, BUILD_STRUCTURE[:SRC]), verbose: true, remove_destination: true)
|
@tmp_src = File.join(@prep_dir, BUILD_STRUCTURE[:SRC], File.basename(@git_path))
|
||||||
FileUtils.rm_rf(File.join(@prep_dir, BUILD_STRUCTURE[:SRC], ".git"), secure: true)
|
FileUtils.cp_r(@git_path, @tmp_src, verbose: true, remove_destination: true)
|
||||||
|
FileUtils.rm_rf(File.join(@tmp_src, ".git"), secure: true)
|
||||||
else
|
else
|
||||||
@log.error("Это файл #{@git_path}, а не каталог")
|
@log.error("Это файл #{@git_path}, а не каталог")
|
||||||
@error = true
|
@error = true
|
||||||
@@ -87,12 +89,13 @@ class MockManager
|
|||||||
@recips.each_with_index do |item, index|
|
@recips.each_with_index do |item, index|
|
||||||
@log.info("Формируем рецепт #{item[:filepath]}")
|
@log.info("Формируем рецепт #{item[:filepath]}")
|
||||||
rcp_name = "#{index}rcp_#{item[:filepath]}"
|
rcp_name = "#{index}rcp_#{item[:filepath]}"
|
||||||
File.open(File.join(@prep_dir, BUILD_STRUCTURE[:SRC], rcp_name), "w") do |f|
|
File.open(File.join(@tmp_src, rcp_name), "w") do |f|
|
||||||
f.write(item[:content])
|
f.write(item[:content])
|
||||||
end
|
end
|
||||||
Dir.chdir(File.join(@prep_dir, BUILD_STRUCTURE[:SRC])) do
|
Dir.chdir(@tmp_src) do
|
||||||
script = File.join(@prep_dir, BUILD_STRUCTURE[:SRC], rcp_name)
|
script = File.join(@tmp_src, rcp_name)
|
||||||
cmd_args = %Q(/usr/bin/bash -x "#{script}")
|
cmd_args = %Q(/usr/bin/bash -x "#{script}")
|
||||||
|
@log.debug(cmd_args)
|
||||||
cmd = Runner.new(cmd_args, @log)
|
cmd = Runner.new(cmd_args, @log)
|
||||||
cmd.run_clean
|
cmd.run_clean
|
||||||
@error = true if cmd.exit_status != 0
|
@error = true if cmd.exit_status != 0
|
||||||
@@ -104,10 +107,11 @@ class MockManager
|
|||||||
|
|
||||||
def prepare_src_rpm()
|
def prepare_src_rpm()
|
||||||
@log.info("Подготовка SRCRPM")
|
@log.info("Подготовка SRCRPM")
|
||||||
spec_file = File.join(@prep_dir, BUILD_STRUCTURE[:SRC], @spec)
|
spec_file = File.join(@tmp_src, @spec)
|
||||||
if File.exist?(spec_file)
|
if File.exist?(spec_file)
|
||||||
Dir.chdir(File.join(@prep_dir, BUILD_STRUCTURE[:SRC])) do
|
Dir.chdir(@tmp_src) do
|
||||||
cmd_args = %Q(/usr/bin/mock -r #{@config} --buildsrpm --spec #{spec_file} --sources #{File.join(@prep_dir, BUILD_STRUCTURE[:SRC])} --resultdir #{File.join(@prep_dir, BUILD_STRUCTURE[:RESULT_SRPM])} --isolation=simple --disable-plugin=ccache")
|
cmd_args = %Q(/usr/bin/mock -r "#{@config}" --buildsrpm --spec "#{spec_file}" --sources "#{@tmp_src}" --resultdir "#{File.join(@prep_dir, BUILD_STRUCTURE[:RESULT_SRPM])}" --isolation=simple --disable-plugin=ccache)
|
||||||
|
@log.debug(cmd_args)
|
||||||
cmd = Runner.new(cmd_args, @log)
|
cmd = Runner.new(cmd_args, @log)
|
||||||
cmd.run_clean
|
cmd.run_clean
|
||||||
@error = true if cmd.exit_status != 0
|
@error = true if cmd.exit_status != 0
|
||||||
@@ -128,8 +132,9 @@ class MockManager
|
|||||||
@log.info("Нечего собирать, нет src.rpm пакетов")
|
@log.info("Нечего собирать, нет src.rpm пакетов")
|
||||||
else
|
else
|
||||||
srpm = srpms.first
|
srpm = srpms.first
|
||||||
path_srpm = File.join(@prep_dir, srpm)
|
path_srpm = File.join(srpm_result_dir, srpm)
|
||||||
cmd_args = %Q(/usr/bin/mock -r #{@config} #{path_srpm} --resultdir #{File.join(@prep_dir, BUILD_STRUCTURE[:RESULT])} --isolation simple)
|
cmd_args = %Q(/usr/bin/mock -r "#{@config}" "#{path_srpm}" --resultdir "#{File.join(@prep_dir, BUILD_STRUCTURE[:RESULT])}" --isolation simple)
|
||||||
|
@log.debug(cmd_args)
|
||||||
cmd = Runner.new(cmd_args, @log)
|
cmd = Runner.new(cmd_args, @log)
|
||||||
cmd.run_clean
|
cmd.run_clean
|
||||||
@error = true if cmd.exit_status != 0
|
@error = true if cmd.exit_status != 0
|
||||||
@@ -202,6 +207,7 @@ class MockManager
|
|||||||
f.flock(File::LOCK_EX)
|
f.flock(File::LOCK_EX)
|
||||||
# выклдака пакетов и пересоздание repodata
|
# выклдака пакетов и пересоздание repodata
|
||||||
prep_rpms.each do |item|
|
prep_rpms.each do |item|
|
||||||
|
FileUtils.mkdir_p(File.dirname(item[:dst]))
|
||||||
FileUtils.cp_r(item[:src], item[:dst], verbose: true, remove_destination: true)
|
FileUtils.cp_r(item[:src], item[:dst], verbose: true, remove_destination: true)
|
||||||
@db.save_rpm(@build_id, item[:dst], item[:name], @git_id)
|
@db.save_rpm(@build_id, item[:dst], item[:name], @git_id)
|
||||||
@log.info("Копируется пакет #{item[:src]} в репозиторий #{item[:dst]}")
|
@log.info("Копируется пакет #{item[:src]} в репозиторий #{item[:dst]}")
|
||||||
@@ -222,36 +228,36 @@ class MockManager
|
|||||||
|
|
||||||
def build_task()
|
def build_task()
|
||||||
@error = false
|
@error = false
|
||||||
#@db.before_fork
|
@db.before_fork
|
||||||
#spock = Spork.spork(:logger => log) do
|
spock = Spork.spork(:logger => log) do
|
||||||
# @db.after_fork
|
@db.after_fork
|
||||||
#$stdout = File.open(@process_log, "w")
|
$stdout = File.open(@process_log, "w")
|
||||||
@log = Logger.new($stdout)
|
@log = Logger.new($stdout)
|
||||||
if @spec == ""
|
if @spec == ""
|
||||||
@error = true
|
@error = true
|
||||||
@log.error("Не могу найти spec файл")
|
@log.error("Не могу найти spec файл")
|
||||||
|
end
|
||||||
|
begin
|
||||||
|
prepare_structure if @error == false
|
||||||
|
prepare_src if @error == false
|
||||||
|
prepare_source if @error == false
|
||||||
|
prepare_src_rpm if @error == false
|
||||||
|
build_rpm if @error == false
|
||||||
|
save_logs
|
||||||
|
save_rpms if @error == false
|
||||||
|
rescue => e
|
||||||
|
puts e
|
||||||
|
end
|
||||||
|
save_prg_log
|
||||||
|
clean_build
|
||||||
|
@log.close
|
||||||
|
if @error
|
||||||
|
@db.update_build_task_status(@build_id, 1)
|
||||||
|
else
|
||||||
|
@db.update_build_task_status(@build_id, 2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
#begin
|
@db.after_fork
|
||||||
prepare_structure if @error == false
|
spock
|
||||||
prepare_src if @error == false
|
|
||||||
prepare_source if @error == false
|
|
||||||
prepare_src_rpm if @error == false
|
|
||||||
build_rpm if @error == false
|
|
||||||
save_logs
|
|
||||||
save_rpms if @error == false
|
|
||||||
#rescue => e
|
|
||||||
# puts e
|
|
||||||
#end
|
|
||||||
save_prg_log
|
|
||||||
clean_build
|
|
||||||
@log.close
|
|
||||||
if @error
|
|
||||||
@db.update_build_task_status(@build_id, 1)
|
|
||||||
else
|
|
||||||
@db.update_build_task_status(@build_id, 2)
|
|
||||||
end
|
|
||||||
#end
|
|
||||||
#@db.after_fork
|
|
||||||
#spock
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -123,17 +123,17 @@ class ProjectsActions
|
|||||||
proj_config = <<~PRJ_CFG
|
proj_config = <<~PRJ_CFG
|
||||||
include("#{configuration_path}")
|
include("#{configuration_path}")
|
||||||
include("#{prj_incl_path}")
|
include("#{prj_incl_path}")
|
||||||
config_opts['plugin_conf']['ccache_enable'] = True
|
config_opts['plugin_conf']['ccache_enable'] = False
|
||||||
config_opts['plugin_conf']['ccache_opts']['max_cache_size'] = '4G'
|
config_opts['plugin_conf']['ccache_opts']['max_cache_size'] = '4G'
|
||||||
config_opts['plugin_conf']['ccache_opts']['hashdir'] = True
|
config_opts['plugin_conf']['ccache_opts']['hashdir'] = True
|
||||||
config_opts['plugin_conf']['ccache_opts']['debug'] = False
|
config_opts['plugin_conf']['ccache_opts']['debug'] = False
|
||||||
config_opts['plugin_conf']['ccache_opts']['show_stats'] = True
|
config_opts['plugin_conf']['ccache_opts']['show_stats'] = True
|
||||||
config_opts['plugin_conf']['package_state_enable'] = True
|
config_opts['plugin_conf']['package_state_enable'] = True
|
||||||
config_opts['plugin_conf']['procenv_enable'] = True
|
config_opts['plugin_conf']['procenv_enable'] = False
|
||||||
config_opts['plugin_conf']['root_cache_enable'] = True
|
config_opts['plugin_conf']['root_cache_enable'] = True
|
||||||
config_opts['plugin_conf']['showrc_enable'] = True
|
config_opts['plugin_conf']['showrc_enable'] = True
|
||||||
config_opts['plugin_conf']['yum_cache_enable'] = True
|
config_opts['plugin_conf']['yum_cache_enable'] = True
|
||||||
config_opts['chroot_setup_cmd'] += " procenv gcc gcc-c++ make"
|
config_opts['chroot_setup_cmd'] += " gcc gcc-c++ make"
|
||||||
PRJ_CFG
|
PRJ_CFG
|
||||||
File.open(proj_conf_path, "w") { |f| f << proj_config }
|
File.open(proj_conf_path, "w") { |f| f << proj_config }
|
||||||
generate_linked_repos(id, proj_path, proj_name, prj_incl_path)
|
generate_linked_repos(id, proj_path, proj_name, prj_incl_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user