|
|
|
@ -68,7 +68,7 @@ class ProjectsActions
|
|
|
|
|
File.join(proj_path, PROJECTS_STRUCTURE[:SRC], gitname)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def generate_linked_repos(id, proj_path, proj_name)
|
|
|
|
|
def generate_linked_repos(id, proj_path, proj_name, linked_repo_tpl)
|
|
|
|
|
linked_prj = []
|
|
|
|
|
proj_repo_path = File.join(proj_path, PROJECTS_STRUCTURE[:REPO])
|
|
|
|
|
proj_repo = <<~PRJ_CFG
|
|
|
|
@ -99,7 +99,17 @@ class ProjectsActions
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
File.open(prj_incl_path, "w") { |f| f << linked_prj.join("\n\n\n") }
|
|
|
|
|
File.open(linked_repo_tpl, "w") { |f| f << linked_prj.join("\n\n\n") }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def regenerate_linked_repos(id)
|
|
|
|
|
proj_path = get_project_path(id)
|
|
|
|
|
config_path = File.join(proj_path, PROJECTS_STRUCTURE[:CONFIGS])
|
|
|
|
|
prj_incl_path = File.join(config_path, "repos_include.tpl")
|
|
|
|
|
prj_info = get_project(id)
|
|
|
|
|
unless prj_info.nil?
|
|
|
|
|
generate_linked_repos(id, proj_path, prj_info[:projname], prj_incl_path)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def generate_config(id, configuration_path, proj_path, proj_name)
|
|
|
|
@ -107,7 +117,7 @@ class ProjectsActions
|
|
|
|
|
conf_path = File.join(proj_path, PROJECTS_STRUCTURE[:CONFIGS])
|
|
|
|
|
prj_incl_path = File.join(conf_path, "repos_include.tpl")
|
|
|
|
|
proj_config = <<~PRJ_CFG
|
|
|
|
|
include("#{configuration}")
|
|
|
|
|
include("#{configuration_path}")
|
|
|
|
|
include("#{prj_incl_path}")
|
|
|
|
|
config_opts['plugin_conf']['ccache_enable'] = True
|
|
|
|
|
config_opts['plugin_conf']['ccache_opts']['max_cache_size'] = '4G'
|
|
|
|
@ -121,7 +131,7 @@ class ProjectsActions
|
|
|
|
|
config_opts['plugin_conf']['yum_cache_enable'] = True
|
|
|
|
|
PRJ_CFG
|
|
|
|
|
File.open(proj_conf_path, "w") { |f| f << proj_config }
|
|
|
|
|
generate_linked_repos(id, proj_path, proj_name)
|
|
|
|
|
generate_linked_repos(id, proj_path, proj_name, prj_incl_path)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create_project(name, description, configuration)
|
|
|
|
@ -134,29 +144,29 @@ class ProjectsActions
|
|
|
|
|
ret_val = 1
|
|
|
|
|
else
|
|
|
|
|
created = false
|
|
|
|
|
begin
|
|
|
|
|
Dir.mkdir(fname)
|
|
|
|
|
PROJECTS_STRUCTURE.each_pair do |key, value|
|
|
|
|
|
new_path = File.join(fname, value)
|
|
|
|
|
Dir.mkdir(new_path)
|
|
|
|
|
end
|
|
|
|
|
if File.exist?(configuration)
|
|
|
|
|
generate_config(nil, configuration, fname, project_name)
|
|
|
|
|
@error = @db.proj_create(project_name, description)
|
|
|
|
|
if @error.nil?
|
|
|
|
|
created = true
|
|
|
|
|
end
|
|
|
|
|
repo_path = File.join(fname, PROJECTS_STRUCTURE[:REPO])
|
|
|
|
|
repoman = RepoManager.new(repo_path)
|
|
|
|
|
repoman.create_repo
|
|
|
|
|
else
|
|
|
|
|
ret_val = 1
|
|
|
|
|
@error = "Конфигурация #{configuration} не существует"
|
|
|
|
|
#begin
|
|
|
|
|
Dir.mkdir(fname)
|
|
|
|
|
PROJECTS_STRUCTURE.each_pair do |key, value|
|
|
|
|
|
new_path = File.join(fname, value)
|
|
|
|
|
Dir.mkdir(new_path)
|
|
|
|
|
end
|
|
|
|
|
if File.exist?(configuration)
|
|
|
|
|
generate_config(nil, configuration, fname, project_name)
|
|
|
|
|
@error = @db.proj_create(project_name, description)
|
|
|
|
|
if @error.nil?
|
|
|
|
|
created = true
|
|
|
|
|
end
|
|
|
|
|
rescue => e
|
|
|
|
|
repo_path = File.join(fname, PROJECTS_STRUCTURE[:REPO])
|
|
|
|
|
repoman = RepoManager.new(repo_path)
|
|
|
|
|
repoman.create_repo
|
|
|
|
|
else
|
|
|
|
|
ret_val = 1
|
|
|
|
|
@error = e.message
|
|
|
|
|
@error = "Конфигурация #{configuration} не существует"
|
|
|
|
|
end
|
|
|
|
|
#rescue => e
|
|
|
|
|
# ret_val = 1
|
|
|
|
|
# @error = e.message
|
|
|
|
|
#end
|
|
|
|
|
unless created
|
|
|
|
|
FileUtils.rm_rf(fname, secure: true)
|
|
|
|
|
end
|
|
|
|
@ -199,4 +209,33 @@ class ProjectsActions
|
|
|
|
|
end
|
|
|
|
|
err
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def get_related_projects_list(prj_id)
|
|
|
|
|
links_list = []
|
|
|
|
|
links = @db.get_projects_links(prj_id)
|
|
|
|
|
unless links.nil?
|
|
|
|
|
links_list = links.map do |item|
|
|
|
|
|
prj_info = @db.proj(item[:proj_id_repository])
|
|
|
|
|
if prj_info.nil?
|
|
|
|
|
item[:list_state] = false
|
|
|
|
|
else
|
|
|
|
|
item[:list_state] = true
|
|
|
|
|
item[:prj_info] = prj_info
|
|
|
|
|
end
|
|
|
|
|
item
|
|
|
|
|
end.select { |item| item[:list_state] }
|
|
|
|
|
end
|
|
|
|
|
links_list
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def delete_linked_projects(prj_id)
|
|
|
|
|
@db.delete_linked_projects(prj_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def save_linked_projects(prj_id, new_ids, delete_ids)
|
|
|
|
|
delete_ids.each { |item| @db.delete_linked_projects_with_id(prj_id, item) }
|
|
|
|
|
new_ids.each do |item|
|
|
|
|
|
@db.save_linked_projects(prj_id, item)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|