Sign. Part 1
This commit is contained in:
@@ -82,4 +82,12 @@ class IniConfig
|
||||
30
|
||||
end
|
||||
end
|
||||
|
||||
def get_keys_path()
|
||||
unless @config["sign"]["path"].nil?
|
||||
@config["sign"]["path"].to_s
|
||||
else
|
||||
"keys"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -145,11 +145,15 @@ class DBase
|
||||
Projects[id]
|
||||
end
|
||||
|
||||
def proj_create(proj_name, proj_descr)
|
||||
def proj_create(proj_name, proj_descr, nopublic)
|
||||
@error = nil
|
||||
data = Projects.where(projname: proj_name).first
|
||||
if data.nil?
|
||||
id = Projects.insert(projname: proj_name, descr: proj_descr, public: 1)
|
||||
public_proj = 1
|
||||
unless nopublic.nil?
|
||||
public_proj = 0
|
||||
end
|
||||
id = Projects.insert(projname: proj_name, descr: proj_descr, public: public_proj)
|
||||
@last_id = id
|
||||
else
|
||||
@error = "Данный проект уже существует"
|
||||
@@ -256,8 +260,8 @@ class DBase
|
||||
$DDB = Sequel.connect(@cfg.get_db)
|
||||
end
|
||||
|
||||
def save_rpm(build_id, path_to_rpm, rpm_name, git_id)
|
||||
id = Rpms.insert(savepath: path_to_rpm, rpmname: rpm_name, sign: 0, signpath: "", repo_id: git_id.to_i)
|
||||
def save_rpm(build_id, path_to_rpm, rpm_name, git_id, sha256)
|
||||
id = Rpms.insert(savepath: path_to_rpm, rpmname: rpm_name, sign: 0, signpath: "", repo_id: git_id.to_i, filehash: sha256)
|
||||
@last_id = id
|
||||
BuildRpms.insert(build_id: build_id.to_i, rpm_id: id)
|
||||
end
|
||||
@@ -344,11 +348,12 @@ class DBase
|
||||
ReposProjects.where(proj_id: prj_id.to_i).delete
|
||||
ProjectsReposSpec.where(proj_id: prj_id.to_i).delete
|
||||
builds = BuildTask.where(proj_id: prj_id.to_i)
|
||||
build.each do |item|
|
||||
builds.each do |item|
|
||||
rpms = BuildRpms.where(build_id: item[:id])
|
||||
Rpms.where(id: rpms[:rpm_id]).delete
|
||||
end
|
||||
BuildTask.where(proj_id: prj_id.to_i).delete
|
||||
Projects.where(id: prj_id.to_i).delete
|
||||
end
|
||||
|
||||
def projects_with_current_as_link(prj_id)
|
||||
|
||||
@@ -3,6 +3,7 @@ require_relative "runner"
|
||||
require "fileutils"
|
||||
require "logger"
|
||||
require_relative "repomanage"
|
||||
require "digest"
|
||||
|
||||
BUILD_STRUCTURE = {
|
||||
:SRC => "src",
|
||||
@@ -206,12 +207,25 @@ class MockManager
|
||||
File.open(@repo_lock, File::RDWR | File::CREAT) do |f|
|
||||
f.flock(File::LOCK_EX)
|
||||
# выклдака пакетов и пересоздание repodata
|
||||
packages_uniq = true
|
||||
prep_rpms.each do |item|
|
||||
FileUtils.mkdir_p(File.dirname(item[:dst]))
|
||||
FileUtils.cp_r(item[:src], item[:dst], verbose: true, remove_destination: true)
|
||||
@db.save_rpm(@build_id, item[:dst], item[:name], @git_id)
|
||||
@log.info("Копируется пакет #{item[:src]} в репозиторий #{item[:dst]}")
|
||||
if File.exist?(item[:dst])
|
||||
packages_uniq = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if packages_uniq
|
||||
prep_rpms.each do |item|
|
||||
@log.info("Копируется пакет #{item[:src]} в репозиторий #{item[:dst]}")
|
||||
FileUtils.mkdir_p(File.dirname(item[:dst]))
|
||||
FileUtils.cp_r(item[:src], item[:dst], verbose: true, remove_destination: true)
|
||||
sha256 = Digest::SHA256.file(item[:dst])
|
||||
@db.save_rpm(@build_id, item[:dst], item[:name], @git_id, sha256.hexdigest)
|
||||
end
|
||||
repo.create_repo
|
||||
else
|
||||
@error = true
|
||||
@log.error("Такие пакеты уже существуют в репозитории. Поднимите версию пакета")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -144,7 +144,7 @@ class ProjectsActions
|
||||
generate_linked_repos(id, proj_path, proj_name, prj_incl_path)
|
||||
end
|
||||
|
||||
def create_project(name, description, configuration)
|
||||
def create_project(name, description, configuration, nopublic)
|
||||
@error = nil
|
||||
ret_val = 0
|
||||
project_name = sanitize_rcptname(name)
|
||||
@@ -162,7 +162,7 @@ class ProjectsActions
|
||||
end
|
||||
if File.exist?(configuration)
|
||||
generate_config(nil, configuration, fname, project_name)
|
||||
@error = @db.proj_create(project_name, description)
|
||||
@error = @db.proj_create(project_name, description, nopublic)
|
||||
if @error.nil?
|
||||
created = true
|
||||
end
|
||||
@@ -361,10 +361,10 @@ class ProjectsActions
|
||||
@error = "Нельзя удалить git репозиторий с незавершенными сборками"
|
||||
else
|
||||
linked = @db.projects_with_current_as_link(prj_id)
|
||||
if linked.nil?
|
||||
if linked.nil? || linked.length == 0
|
||||
proj_path = get_project_path(prj_id)
|
||||
FileUtils.rm_rf(proj_path, secure: true)
|
||||
@db.delete_project(prj_id, git_id)
|
||||
@db.delete_project(prj_id)
|
||||
else
|
||||
@error = "На текущий проект ссылаются другие проекты. Удаление запрещено"
|
||||
end
|
||||
|
||||
@@ -17,6 +17,22 @@ class RPMReader
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user