-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsacks.py
More file actions
55 lines (45 loc) · 1.73 KB
/
sacks.py
File metadata and controls
55 lines (45 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import functools
import dnf
from utils import CONFIG, log
MULTILIB = {'x86_64': 'i686'} # architectures to exclude in certain queries
@functools.cache
def _base(repo_key):
f"""
Creates a DNF base from repositories defined in CONFIG['repos'], based on the given key.
The sack is filled, which can be extremely slow if not already cached on disk in {CONFIG['cache_dir']['dnf']}.
Cache is never invalidated here, remove the directory manually if needed.
"""
base = dnf.Base()
dnf_conf = base.conf
dnf_conf.arch = CONFIG['architectures']['repoquery']
dnf_conf.cachedir = CONFIG['cache_dir']['dnf']
dnf_conf.substitutions['releasever'] = 'rawhide'
dnf_conf.substitutions['basearch'] = CONFIG['architectures']['repoquery']
for repo in CONFIG['repos'][repo_key]:
base.repos.add_new_repo(conf=dnf_conf, skip_if_unavailable=False, **repo)
log(f'• Filling the DNF {repo_key} sack to/from {CONFIG["cache_dir"]["dnf"]}...', end=' ')
base.fill_sack(load_system_repo=False, load_available_repos=True)
log('done.')
return base
def rawhide_group(group_id):
"""
Return a rawhide comps group of a given id (a.k.a. name)
"""
base = _base('rawhide')
log('• Reading the comps information...', end=' ')
base.read_comps()
log('done.')
for group in base.comps.groups_by_pattern(group_id):
if group.id == group_id:
return group
raise ValueError(f'No such group {group_id}')
def rawhide_sack():
"""
A filled sack to perform rawhide repoquries. See base() for details.
"""
return _base('rawhide').sack
def target_sack():
"""
A filled sack to perform target repoquries. See base() for details.
"""
return _base('target').sack