Added mock build. Part 5

This commit is contained in:
alexey
2025-03-14 00:06:42 +03:00
parent 2059e19d0d
commit 9cf2aabc65
6 changed files with 207 additions and 14 deletions

View File

@@ -2,6 +2,7 @@ require "fileutils"
require_relative "db"
require_relative "repomanage"
require_relative "mock"
require_relative "utilities"
PROJECTS_STRUCTURE = {
:REPO => "repo",
@@ -243,6 +244,23 @@ class ProjectsActions
end
end
def find_spec_file(prj_id, git_id)
spec_file = ""
proj_path = get_project_path(prj_id)
git_name = @db.get_repo_info_by_id(git_id)
git_source = File.join(proj_path, PROJECTS_STRUCTURE[:SRC], git_name[:reponame])
spec = @db.get_project_repo_spec(prj_id, git_id)
if spec.nil?
spec_files = get_spec_files_in_dir(git_source)
unless spec_files.nil?
spec_file = spec_files.first
end
else
spec_file = spec[:spec_name]
end
spec_file
end
def build_projects_git(prj_id, git_id, counter_file)
bld_id = 0
build_ok = true
@@ -250,6 +268,8 @@ class ProjectsActions
git_name = @db.get_repo_info_by_id(git_id)
prep_script = @db.get_git_recips(git_id)
prepare_path = File.join(proj_path, PROJECTS_STRUCTURE[:SRCPRP], git_name[:reponame])
spec_file = find_spec_file(prj_id, git_id)
repo_lock = File.join(proj_path, PROJECTS_STRUCTURE[:CONFIGS], ".repolock")
if File.exist?(prepare_path)
lockf_path = File.join(prepare_path, "lock")
File.open(lockf_path, File::RDWR | File::CREAT) do |f|
@@ -282,12 +302,15 @@ class ProjectsActions
#Начинаем сборку
build_path = File.join(proj_path, PROJECTS_STRUCTURE[:LOGS], git_name[:reponame])
repo_path = File.join(proj_path, PROJECTS_STRUCTURE[:REPO])
git_source = File.join(proj_path, PROJECTS_STRUCTURE[:SRC], git_name[:reponame])
@db.create_build_task(prj_id, git_id, build_path)
build_id = @db.last_id
mock = MockManager.new(prepare_path, get_project_config(prj_id), counter_file, @db, build_path, repo_path)
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)
bld_id = build_id
@db.update_build_task_error_log(build_id, mock.get_build_process_log)
mock.build_task
mock.finalize_build_task
f.flock(File::LOCK_UN)
end
end
bld_id