diff --git a/classes/mock.rb b/classes/mock.rb index eb116f1..2dfa801 100644 --- a/classes/mock.rb +++ b/classes/mock.rb @@ -46,6 +46,7 @@ class MockManager Dir.mkdir(@prep_dir) FileUtils.touch(@process_log) @log = nil + @tmp_src = "" end def get_build_process_log() @@ -70,8 +71,9 @@ class MockManager @log.info("Подготовка исходных файлов проекта к формированию SRPMS") if File.exist?(@git_path) if File.directory?(@git_path) - FileUtils.cp_r(@git_path, File.join(@prep_dir, BUILD_STRUCTURE[:SRC]), verbose: true, remove_destination: true) - FileUtils.rm_rf(File.join(@prep_dir, BUILD_STRUCTURE[:SRC], ".git"), secure: true) + @tmp_src = File.join(@prep_dir, BUILD_STRUCTURE[:SRC], File.basename(@git_path)) + FileUtils.cp_r(@git_path, @tmp_src, verbose: true, remove_destination: true) + FileUtils.rm_rf(File.join(@tmp_src, ".git"), secure: true) else @log.error("Это файл #{@git_path}, а не каталог") @error = true @@ -87,12 +89,13 @@ class MockManager @recips.each_with_index do |item, index| @log.info("Формируем рецепт #{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]) end - Dir.chdir(File.join(@prep_dir, BUILD_STRUCTURE[:SRC])) do - script = File.join(@prep_dir, BUILD_STRUCTURE[:SRC], rcp_name) + Dir.chdir(@tmp_src) do + script = File.join(@tmp_src, rcp_name) cmd_args = %Q(/usr/bin/bash -x "#{script}") + @log.debug(cmd_args) cmd = Runner.new(cmd_args, @log) cmd.run_clean @error = true if cmd.exit_status != 0 @@ -104,10 +107,11 @@ class MockManager def prepare_src_rpm() @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) - Dir.chdir(File.join(@prep_dir, BUILD_STRUCTURE[: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") + Dir.chdir(@tmp_src) do + 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.run_clean @error = true if cmd.exit_status != 0 @@ -128,8 +132,9 @@ class MockManager @log.info("Нечего собирать, нет src.rpm пакетов") else srpm = srpms.first - path_srpm = File.join(@prep_dir, srpm) - cmd_args = %Q(/usr/bin/mock -r #{@config} #{path_srpm} --resultdir #{File.join(@prep_dir, BUILD_STRUCTURE[:RESULT])} --isolation simple) + 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) + @log.debug(cmd_args) cmd = Runner.new(cmd_args, @log) cmd.run_clean @error = true if cmd.exit_status != 0 @@ -202,6 +207,7 @@ class MockManager f.flock(File::LOCK_EX) # выклдака пакетов и пересоздание repodata prep_rpms.each do |item| + FileUtils.mkdir_p(File.dirname(item[:dst])) FileUtils.cp_r(item[:src], item[:dst], verbose: true, remove_destination: true) @db.save_rpm(@build_id, item[:dst], item[:name], @git_id) @log.info("Копируется пакет #{item[:src]} в репозиторий #{item[:dst]}") @@ -222,36 +228,36 @@ class MockManager def build_task() @error = false - #@db.before_fork - #spock = Spork.spork(:logger => log) do - # @db.after_fork - #$stdout = File.open(@process_log, "w") - @log = Logger.new($stdout) - if @spec == "" - @error = true - @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) + @db.before_fork + spock = Spork.spork(:logger => log) do + @db.after_fork + $stdout = File.open(@process_log, "w") + @log = Logger.new($stdout) + if @spec == "" + @error = true + @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 - #@db.after_fork - #spock + @db.after_fork + spock end end diff --git a/classes/projects.rb b/classes/projects.rb index 3aa4a2c..121a89f 100644 --- a/classes/projects.rb +++ b/classes/projects.rb @@ -123,17 +123,17 @@ class ProjectsActions proj_config = <<~PRJ_CFG include("#{configuration_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']['hashdir'] = True config_opts['plugin_conf']['ccache_opts']['debug'] = False config_opts['plugin_conf']['ccache_opts']['show_stats'] = 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']['showrc_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 File.open(proj_conf_path, "w") { |f| f << proj_config } generate_linked_repos(id, proj_path, proj_name, prj_incl_path)