qubes-core-admin-linux/qubes-rpc/qubes.repos.Enable
Marek Marczykowski-Górecki 9962fab124
repos rpc: use dnf native method of writing repository configuration
Since we have new enough dnf version, native write_raw_configfile() can
be used, instead of external iniparse module.

QubesOS/qubes-issues#4550
2019-08-28 16:40:13 +02:00

25 lines
469 B
Python
Executable File

#!/usr/bin/python3
# `ok` on stdout indicates success; any stderr output indicates an error
# (probably an exception)
import dnf
import os
import sys
os.umask(0o022)
base = dnf.Base()
base.read_all_repos()
reponame = sys.argv[1]
repo = base.repos[reponame]
base.conf.write_raw_configfile(repo.repofile,
repo.id,
base.conf.substitutions,
{'enabled': '1'})
print('ok')