You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.4 KiB

$LOAD_PATH.unshift File.expand_path(".", "locallibs/ruby-rpm-ffi/lib")
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 RepoManagerKeys
attr :path, :error
def initialize(path)
@error = nil
@path = path
end
def check_key_exists()
key_file = File.join(@path, "public", "mockgui-gpg-key")
File.exist?(key_file)
end
end
#rpm --define "_gpg_sign_cmd_extra_args --pinentry-mode loopback --passphrase 1234" --addsign bayrepo-neuro-farm-0.1-2.x86_64.rpm
class RepoManager
attr :path, :error, :last_status, :last_pid
def initialize(path)
@error = nil
unless File.exist? (path)
Dir.mkdir(path)
end
@path = path
@reader = RPMReader.new
end
def create_repo
repo_path = File.join(@path, "repodata")
cmd_args = %Q(/usr/bin/createrepo_c --database --workers 1 "#{@path}")
if File.exist?(repo_path)
cmd_args = %Q(/usr/bin/createrepo_c --database --workers 1 --update "#{@path}")
end
cmd = Runner.new(cmd_args)
cmd.run
@last_status = cmd.exit_status
@last_pid = cmd.pid
end
def get_rpm_info(path_to_rpm)
@reader.get_rpm_info(path_to_rpm)
end
end