[ostree] Set each repo to point to current compose
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
e6079e4c85
commit
46ab1cb6f6
@ -94,10 +94,16 @@ class OSTreeThread(WorkerThread):
|
||||
|
||||
|
||||
def tweak_file(path, source_repo):
|
||||
"""Replace mirrorlist line in repo file with baseurl pointing to source_repo."""
|
||||
"""
|
||||
Ensure a given .repo file points to `source_repo`.
|
||||
|
||||
This function replaces all lines starting with `mirrorlist`, `metalink` or
|
||||
`baseurl` with `baseurl` set to requested repository.
|
||||
"""
|
||||
with open(path, 'r') as f:
|
||||
contents = f.read()
|
||||
replacement = 'baseurl={}'.format(source_repo)
|
||||
contents = re.sub(r'^mirrorlist=.*$', replacement, contents, flags=re.MULTILINE)
|
||||
contents = re.sub(r'^(mirrorlist|metalink|baseurl)=.*$',
|
||||
replacement, contents, flags=re.MULTILINE)
|
||||
with open(path, 'w') as f:
|
||||
f.write(contents)
|
||||
|
@ -78,6 +78,10 @@ class OSTreeThreadTest(helpers.PungiTestCase):
|
||||
helpers.touch(os.path.join(target, 'fedora-atomic-docker-host.json'))
|
||||
helpers.touch(os.path.join(target, 'fedora-rawhide.repo'),
|
||||
'mirrorlist=mirror-mirror-on-the-wall')
|
||||
helpers.touch(os.path.join(target, 'fedora-24.repo'),
|
||||
'metalink=who-is-the-fairest-of-them-all')
|
||||
helpers.touch(os.path.join(target, 'fedora-23.repo'),
|
||||
'baseurl=why-not-zoidberg?')
|
||||
|
||||
@mock.patch('pungi.wrappers.scm.get_dir_from_scm')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
@ -131,6 +135,12 @@ class OSTreeThreadTest(helpers.PungiTestCase):
|
||||
with open(self.topdir + '/work/ostree/config_repo/fedora-rawhide.repo') as f:
|
||||
self.assertIn('baseurl=http://example.com/Everything/x86_64/os'.format(self.topdir),
|
||||
f.read())
|
||||
with open(self.topdir + '/work/ostree/config_repo/fedora-24.repo') as f:
|
||||
self.assertIn('baseurl=http://example.com/Everything/x86_64/os'.format(self.topdir),
|
||||
f.read())
|
||||
with open(self.topdir + '/work/ostree/config_repo/fedora-23.repo') as f:
|
||||
self.assertIn('baseurl=http://example.com/Everything/x86_64/os'.format(self.topdir),
|
||||
f.read())
|
||||
|
||||
@mock.patch('pungi.wrappers.scm.get_dir_from_scm')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
|
Loading…
Reference in New Issue
Block a user