mock build.Part 4
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user