mock build.Part 4

This commit is contained in:
alexey
2025-03-16 18:08:13 +03:00
parent c9ac228ab6
commit f04f926bd8
5 changed files with 206 additions and 12 deletions

View File

@@ -270,4 +270,40 @@ class DBase
def get_rpms_for_git(git_id)
$DDB["select t2.id as rpmid, t2.rpmname, t1.reponame as repoid, t4.id as builid, t4.proj_id as prjid, t4.create_at from repos as t1 join rpms as t2 on t2.repo_id = t1.id join build_rpm as t3 on t3.rpm_id = t2.id join buildtask as t4 on t4.id = t3.build_id where t1.id = ? and t2.savepath not like '%.src.rpm' order by t4.create_at, t2.rpmname", git_id.to_i].all
end
def get_rpm_info(rpm_id)
Rpms[rpm_id.to_i]
end
def get_rpm_build(rpm_id)
bld_info = BuildRpms.where(rpm_id: rpm_id.to_i).first
if bld_info.nil?
nil
else
bld_info[:build_id]
end
end
def get_rpm_srpms(rpm_id)
bld_info = BuildRpms.where(rpm_id: rpm_id.to_i).first
if bld_info.nil?
nil
else
bld_info[:build_id]
result = BuildRpms.where(build_id: bld_info[:build_id].to_i)
if result.nil?
nil
else
result.each do |item|
rpm_p = Rpms[item[:rpm_id].to_i]
unless rpm_p.nil?
if rpm_p[:savepath] =~ /\.src\.rpm$/
return rpm_p
end
end
end
end
nil
end
end
end

View File

@@ -4,6 +4,19 @@ require "rpm"
require_relative "runner"
class RPMReader
def get_rpm_info(path_to_rpm)
res = { :error => nil }
if File.exist?(path_to_rpm)
pkg = RPM::Package.open(path_to_rpm)
res[:pkginfo] = pkg
else
res[:error] = "#{path_to_rpm} не существует"
end
res
end
end
class RepoManager
attr :path, :error, :last_status, :last_pid
@@ -13,6 +26,7 @@ class RepoManager
Dir.mkdir(path)
end
@path = path
@reader = RPMReader.new
end
def create_repo
@@ -28,13 +42,6 @@ class RepoManager
end
def get_rpm_info(path_to_rpm)
res = { :error => nil }
if File.exist?(path_to_rpm)
pkg = RPM::Package.open(path_to_rpm)
res[:pkginfo] = pkg
else
res[:error] = "#{path_to_rpm} не существует"
end
res
@reader.get_rpm_info(path_to_rpm)
end
end