2018-12-09 01:43:36 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
# Empty output indicates success; any input indicates error (probably an exception)
|
|
|
|
|
|
|
|
import dnf
|
|
|
|
import iniparse
|
2018-12-09 06:46:38 +00:00
|
|
|
import os
|
2018-12-09 01:43:36 +00:00
|
|
|
import sys
|
|
|
|
|
2018-12-09 07:03:17 +00:00
|
|
|
os.umask(0o022)
|
|
|
|
|
2018-12-09 01:43:36 +00:00
|
|
|
base = dnf.Base()
|
|
|
|
|
|
|
|
base.read_all_repos()
|
|
|
|
|
2018-12-09 07:09:46 +00:00
|
|
|
reponame = sys.argv[1]
|
2018-12-09 01:43:36 +00:00
|
|
|
repo = base.repos[reponame]
|
|
|
|
|
|
|
|
# Loosely based on write_raw_configfile() from DNF source code,
|
|
|
|
# because that method was introduced in DNF 2.0 but Qubes dom0 has DNF 1.x.
|
|
|
|
with open(repo.repofile) as fp:
|
2018-12-09 06:42:46 +00:00
|
|
|
ini = iniparse.INIConfig(fp)
|
2018-12-09 01:43:36 +00:00
|
|
|
|
|
|
|
ini[reponame]['enabled'] = 1
|
|
|
|
|
2018-12-09 06:46:38 +00:00
|
|
|
with open(repo.repofile + '.new', 'w') as fp:
|
2018-12-09 06:42:46 +00:00
|
|
|
fp.write(str(ini))
|
2018-12-09 06:46:38 +00:00
|
|
|
|
|
|
|
os.rename(repo.repofile + '.new', repo.repofile)
|