| |
@@ -5,7 +5,7 @@
|
| |
import string
|
| |
|
| |
from six import with_metaclass
|
| |
- from six.moves.urllib.parse import urljoin, urlparse
|
| |
+ from six.moves.urllib.parse import urljoin, urlparse, parse_qs
|
| |
from textwrap import dedent
|
| |
import re
|
| |
|
| |
@@ -571,6 +571,27 @@
|
| |
return repo_url
|
| |
|
| |
|
| |
+ def parse_repo_params(repo, supported_keys=None):
|
| |
+ """
|
| |
+ :param repo: str repo from Copr/CoprChroot/Build/...
|
| |
+ :param supported_keys list of supported optional parameters
|
| |
+ :return: dict of optional parameters parsed from the repo URL
|
| |
+ """
|
| |
+ supported_keys = supported_keys or ["priority"]
|
| |
+ if not repo.startswith("copr://"):
|
| |
+ return {}
|
| |
+
|
| |
+ params = {}
|
| |
+ qs = parse_qs(urlparse(repo).query)
|
| |
+ for k, v in qs.items():
|
| |
+ if k in supported_keys:
|
| |
+ # parse_qs returns values as lists, but we allow setting the param only once,
|
| |
+ # so we can take just first value from it
|
| |
+ value = int(v[0]) if v[0].isnumeric() else v[0]
|
| |
+ params[k] = value
|
| |
+ return params
|
| |
+
|
| |
+
|
| |
def generate_build_config(copr, chroot_id):
|
| |
""" Return dict with proper build config contents """
|
| |
chroot = None
|
| |
@@ -595,20 +616,21 @@
|
| |
"name": "Copr buildroot",
|
| |
})
|
| |
|
| |
- for repo in copr.repos_list:
|
| |
- repo_view = {
|
| |
- "id": generate_repo_name(repo),
|
| |
- "url": pre_process_repo_url(chroot_id, repo),
|
| |
- "name": "Additional repo " + generate_repo_name(repo),
|
| |
- }
|
| |
- repos.append(repo_view)
|
| |
- for repo in chroot.repos_list:
|
| |
- repo_view = {
|
| |
- "id": generate_repo_name(repo),
|
| |
- "url": pre_process_repo_url(chroot_id, repo),
|
| |
- "name": "Additional repo " + generate_repo_name(repo),
|
| |
- }
|
| |
- repos.append(repo_view)
|
| |
+ def get_additional_repo_views(repos_list):
|
| |
+ repos = []
|
| |
+ for repo in repos_list:
|
| |
+ params = parse_repo_params(repo)
|
| |
+ repo_view = {
|
| |
+ "id": generate_repo_name(repo),
|
| |
+ "url": pre_process_repo_url(chroot_id, repo),
|
| |
+ "name": "Additional repo " + generate_repo_name(repo),
|
| |
+ }
|
| |
+ repo_view.update(params)
|
| |
+ repos.append(repo_view)
|
| |
+ return repos
|
| |
+
|
| |
+ repos.extend(get_additional_repo_views(copr.repos_list))
|
| |
+ repos.extend(get_additional_repo_views(chroot.repos_list))
|
| |
|
| |
return {
|
| |
'project_id': copr.repo_id,
|
| |
The code is not finished yet, I am putting it here for discussion purpose.
As I understood from #97, it is not required for the described use case to allow a user to specify the integer value of the priority. Therefore, I would prefer to select if the priority should be lower or higher than normal. I think that it is far more user-friendly than describing the integer range and how it is evaluated. Do you agree?Also, I want to discuss, how to put the priority value into the repofile. See the project overview, ... We provide one repofile pername_release
but we want to set priority per chroot ... that means that e.g. I can set low priority forfedora-rawhide-i386
and high priority forfedora-rawhide-x86_64
... and which one of those should be in the Fedora Rawhide repo?The only thing that comes to my mind is having the[modified]
tag ini386 [modified] (0)*, x86_64 [modified] (0)*
as a link to an arch-specific repofile. I just don't like that in such case the currently linked repo will not set the priority and it would be something unexpected by a regular user.What do you think? Do you have a better idea how to solve it?