Use strict=False when reading repo files

In some cases they may contain duplicate sections. With it set to False
the last one wins instead of causing a traceback.

Related: rhbz#1678937
This commit is contained in:
Brian C. Lane 2019-04-04 13:51:43 -07:00
parent a30afe6e5c
commit e85174abce
2 changed files with 25 additions and 2 deletions

View File

@ -553,7 +553,7 @@ def get_source_ids(source_path):
if not os.path.exists(source_path):
return []
cfg = ConfigParser()
cfg = ConfigParser(strict=False)
cfg.read(source_path)
return cfg.sections()
@ -587,7 +587,7 @@ def delete_repo_source(source_glob, source_name):
found = False
for f in glob(source_glob):
try:
cfg = ConfigParser()
cfg = ConfigParser(strict=False)
cfg.read(f)
if source_name in cfg.sections():
found = True

View File

@ -0,0 +1,23 @@
[duplicate-repo]
name=Duplicate repo #1
failovermethod=priority
baseurl=file:///tmp/lorax-empty-repo/
enabled=1
metadata_expire=7d
repo_gpgcheck=0
type=rpm
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
[duplicate-repo]
name=Duplicate repo #2
failovermethod=priority
baseurl=file:///tmp/lorax-empty-repo/
enabled=1
metadata_expire=7d
repo_gpgcheck=0
type=rpm
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False