Added projects with tmp builds

This commit is contained in:
Alexey Berezhok
2025-11-07 23:31:30 +03:00
parent 3bb88d104e
commit e354e20f2d
9 changed files with 123 additions and 116 deletions

View File

@@ -146,7 +146,7 @@ class DBase
Projects[id]
end
def proj_create(proj_name, proj_descr, nopublic)
def proj_create(proj_name, proj_descr, nopublic, tmpbld)
@error = nil
data = Projects.where(projname: proj_name).first
if data.nil?
@@ -154,7 +154,11 @@ class DBase
unless nopublic.nil?
public_proj = 0
end
id = Projects.insert(projname: proj_name, descr: proj_descr, public: public_proj)
tmpbld_proj = 1
if tmpbld.nil?
tmpbld_proj = 0
end
id = Projects.insert(projname: proj_name, descr: proj_descr, public: public_proj, tmpstpbuild: tmpbld_proj)
@last_id = id
else
@error = "Данный проект уже существует"

View File

@@ -4,6 +4,7 @@ require "fileutils"
require "logger"
require_relative "repomanage"
require "digest"
require "date"
BUILD_STRUCTURE = {
:SRC => "src",
@@ -13,9 +14,9 @@ BUILD_STRUCTURE = {
}
class MockManager
attr :path, :config, :error, :last_status, :last_pid, :prep_dir, :db, :resultpath, :process_log, :repo_path, :git_path, :build_id, :log, :recips, :spec, :repo_lock, :git_id
attr :path, :config, :error, :last_status, :last_pid, :prep_dir, :db, :resultpath, :process_log, :repo_path, :git_path, :build_id, :log, :recips, :spec, :repo_lock, :git_id, :tmp_bld
def initialize(path, config, cfg_counter_path, db, result_path, repo_path, git_path, build_id, recips, spec_file, repo_lock, git_id)
def initialize(path, config, cfg_counter_path, db, result_path, repo_path, git_path, build_id, recips, spec_file, repo_lock, git_id, tmp_bld)
@error = nil
unless File.exist? (path)
Dir.mkdir(path)
@@ -32,6 +33,7 @@ class MockManager
@spec = spec_file
@repo_lock = repo_lock
@git_id = git_id
@tmp_bld = tmp_bld
File.open(cfg_counter_path, "r+") do |f|
f.flock(File::LOCK_EX)
@@ -110,6 +112,31 @@ class MockManager
@log.info("Подготовка SRCRPM")
spec_file = File.join(@tmp_src, @spec)
if File.exist?(spec_file)
if @tmp_bld
dt = DateTime.now
bld_id = @build_id.to_i
bld_str = "%010d" % bld_id
dt_str = dt.strftime("%Y%m%d_#{bld_str}")
cmd_args = %Q(/usr/bin/rpm -q --specfile #{spec_file} --queryformat "%{RELEASE}")
@log.debug(cmd_args)
cmd = Runner.new(cmd_args, @log)
cmd.run
if cmd.exit_status == 0
res = "#{cmd.stdout}.#{dt_str}"
line_array = []
File.readlines(spec_file).each do |line|
if line =~ /^[\t ]*[Rr]elease:/
line = "Release: #{res}"
end
line_array << line
end
File.open(spec_file, "w") do |f|
line_array.each do |line|
f.puts(line)
end
end
end
end
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)

View File

@@ -145,7 +145,7 @@ class ProjectsActions
generate_linked_repos(id, proj_path, proj_name, prj_incl_path)
end
def create_project(name, description, configuration, nopublic)
def create_project(name, description, configuration, nopublic, tmpbld)
@error = nil
ret_val = 0
project_name = sanitize_rcptname(name)
@@ -163,7 +163,7 @@ class ProjectsActions
end
if File.exist?(configuration)
generate_config(nil, configuration, fname, project_name)
@error = @db.proj_create(project_name, description, nopublic)
@error = @db.proj_create(project_name, description, nopublic, tmpbld)
if @error.nil?
created = true
end
@@ -317,7 +317,10 @@ class ProjectsActions
build_id = @db.last_id
f.puts(build_id)
f.flush
mock = MockManager.new(prepare_path, get_project_config(prj_id), counter_file, @db, build_path, repo_path, git_source, build_id, prep_script, spec_file, repo_lock, git_id)
proj_info = get_project(prj_id)
tmp_bld = false
tmp_bld = true if proj_info[:tmpstpbuild].to_i != 0
mock = MockManager.new(prepare_path, get_project_config(prj_id), counter_file, @db, build_path, repo_path, git_source, build_id, prep_script, spec_file, repo_lock, git_id, tmp_bld)
bld_id = build_id
@db.update_build_task_error_log(build_id, mock.get_build_process_log)
mock.build_task