| |
@@ -150,6 +150,11 @@
|
| |
return ComplexLogic.get_copr_safe(owner_name, copr_name, **kwargs)
|
| |
|
| |
@staticmethod
|
| |
+ def get_copr_by_repo_safe(repo_url):
|
| |
+ owner, copr = helpers.copr_repo_fullname(repo_url).split("/")
|
| |
+ return ComplexLogic.get_copr_by_owner_safe(owner, copr)
|
| |
+
|
| |
+ @staticmethod
|
| |
def get_copr_dir_safe(ownername, copr_dirname, **kwargs):
|
| |
try:
|
| |
return CoprDirsLogic.get_by_ownername(ownername, copr_dirname).one()
|
| |
@@ -323,3 +328,75 @@
|
| |
if not name in exclude:
|
| |
arguments[name] = getattr(from_object, name)
|
| |
return clazz(**arguments)
|
| |
+
|
| |
+
|
| |
+ class BuildConfigLogic(object):
|
| |
+
|
| |
+ @classmethod
|
| |
+ def generate_build_config(cls, copr, chroot_id):
|
| |
+ """ Return dict with proper build config contents """
|
| |
+ chroot = None
|
| |
+ for i in copr.copr_chroots:
|
| |
+ if i.mock_chroot.name == chroot_id:
|
| |
+ chroot = i
|
| |
+ if not chroot:
|
| |
+ return {}
|
| |
+
|
| |
+ packages = "" if not chroot.buildroot_pkgs else chroot.buildroot_pkgs
|
| |
+
|
| |
+ repos = [{
|
| |
+ "id": "copr_base",
|
| |
+ "baseurl": copr.repo_url + "/{}/".format(chroot_id),
|
| |
+ "name": "Copr repository",
|
| |
+ }]
|
| |
+
|
| |
+ if copr.module_hotfixes:
|
| |
+ repos[0]["module_hotfixes"] = True
|
| |
+
|
| |
+ if not copr.auto_createrepo:
|
| |
+ repos.append({
|
| |
+ "id": "copr_base_devel",
|
| |
+ "baseurl": copr.repo_url + "/{}/devel/".format(chroot_id),
|
| |
+ "name": "Copr buildroot",
|
| |
+ })
|
| |
+
|
| |
+
|
| |
+ repos.extend(cls.get_additional_repo_views(copr.repos_list, chroot_id))
|
| |
+ repos.extend(cls.get_additional_repo_views(chroot.repos_list, chroot_id))
|
| |
+
|
| |
+ return {
|
| |
+ 'project_id': copr.repo_id,
|
| |
+ 'additional_packages': packages.split(),
|
| |
+ 'repos': repos,
|
| |
+ 'chroot': chroot_id,
|
| |
+ 'use_bootstrap_container': copr.use_bootstrap_container,
|
| |
+ 'with_opts': chroot.with_opts.split(),
|
| |
+ 'without_opts': chroot.without_opts.split(),
|
| |
+ }
|
| |
+
|
| |
+ @classmethod
|
| |
+ def get_additional_repo_views(cls, repos_list, chroot_id):
|
| |
+ repos = []
|
| |
+ for repo in repos_list:
|
| |
+ params = helpers.parse_repo_params(repo)
|
| |
+ repo_view = {
|
| |
+ "id": helpers.generate_repo_name(repo),
|
| |
+ "baseurl": helpers.pre_process_repo_url(chroot_id, repo),
|
| |
+ "name": "Additional repo " + helpers.generate_repo_name(repo),
|
| |
+ }
|
| |
+
|
| |
+ copr = ComplexLogic.get_copr_by_repo_safe(repo)
|
| |
+ if copr and copr.module_hotfixes:
|
| |
+ params["module_hotfixes"] = True
|
| |
+
|
| |
+ repo_view.update(params)
|
| |
+ repos.append(repo_view)
|
| |
+ return repos
|
| |
+
|
| |
+ @classmethod
|
| |
+ def generate_additional_repos(cls, copr_chroot):
|
| |
+ base_repo = "copr://{}".format(copr_chroot.copr.full_name)
|
| |
+ repos = [base_repo] + copr_chroot.repos_list + copr_chroot.copr.repos_list
|
| |
+ if not copr_chroot.copr.auto_createrepo:
|
| |
+ repos.append("copr://{}/devel".format(copr_chroot.copr.full_name))
|
| |
+ return repos
|
| |
Good catch, I've added it here.