Skip to content

Commit 17d9cb0

Browse files
committed
Add dnf wrapper
to query the XCP-ng and XS8 repositories Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent df77075 commit 17d9cb0

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

scripts/repo_status/dnf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#! /usr/bin/env python3
2+
3+
import logging
4+
import sys
5+
import tempfile
6+
7+
import repoquery
8+
9+
ARCH = "x86_64"
10+
XCP_VERSION = "8.3"
11+
12+
# Use `dnf` on xs8 and xcpng8.3 repos
13+
def main() -> int:
14+
logging.basicConfig(format='[%(levelname)s] %(message)s', level=logging.INFO)
15+
16+
args = sys.argv[1:]
17+
18+
with (tempfile.NamedTemporaryFile() as dnfconf,
19+
tempfile.TemporaryDirectory() as yumrepod):
20+
21+
repoquery.setup_xcpng_yum_repos(yum_repo_d=yumrepod,
22+
sections=['base', 'updates'],
23+
bin_arch=ARCH,
24+
version=XCP_VERSION)
25+
repoquery.setup_xs8_yum_repos(yum_repo_d=yumrepod,
26+
sections=['base', 'normal', 'earlyaccess'],
27+
)
28+
repoquery.dnf_setup(dnf_conf=dnfconf.name, yum_repo_d=yumrepod)
29+
30+
print(repoquery.run_dnf(args, split=False))
31+
32+
return 0
33+
34+
if __name__ == "__main__":
35+
sys.exit(main())

scripts/repo_status/repoquery.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,17 @@ def rpm_source_package(rpmname: str, **kwargs) -> str:
9595
return BINRPM_SOURCE_CACHE.get(rpmname, kwargs['default'])
9696
return BINRPM_SOURCE_CACHE[rpmname]
9797

98-
def run_repoquery(args: list[str], split: bool = True) -> str | Sequence[str]:
98+
def run_dnf(args: list[str], split: bool = True) -> str | Sequence[str]:
9999
assert DNF_BASE_CMD is not None
100-
cmd = DNF_BASE_CMD + ['repoquery'] + args
100+
cmd = DNF_BASE_CMD + args
101101
logging.debug('$ %s', ' '.join(cmd))
102102
output = subprocess.check_output(cmd, universal_newlines=True).strip()
103103
logging.debug('> %s', output)
104104
return output.split() if split else output
105105

106+
def run_repoquery(args: list[str], split: bool = True) -> str | Sequence[str]:
107+
return run_dnf(['repoquery'] + args, split)
108+
106109
SRPM_BINRPMS_CACHE: dict[str, set[str]] = {} # binrpm-nevr -> srpm-nevr
107110
def fill_srpm_binrpms_cache() -> None:
108111
# HACK: get nevr for what dnf outputs as %{sourcerpm}

0 commit comments

Comments
 (0)