Move/restore ${sysroot}/etc/yum.repos.d to work around yum bug

We really want it to use the *host*'s yum repos, even after the chroot
is constructed.
This commit is contained in:
Colin Walters 2013-12-22 10:59:17 -05:00
parent 02c2e619d7
commit cc0922e655

View File

@ -218,14 +218,23 @@ def _create_rootfs_from_yumroot_content(targetroot, yumroot):
shutil.copy(os.path.join(PKGLIBDIR, 'tmpfiles-ostree-integration.conf'), target_tmpfilesd)
def runyum(argv, yumroot):
yumargs = ['yum', '-y', '--releasever=%s' % (opts.os_version, ), '--nogpg', '--setopt=keepcache=1', '--installroot=' + yumroot, '--disablerepo=*']
yumargs = list(['yum', '-y', '--releasever=%s' % (opts.os_version, ), '--nogpg', '--setopt=keepcache=1', '--installroot=' + yumroot, '--disablerepo=*'])
yumargs.extend(map(lambda x: '--enablerepo=' + x, opts.enablerepo))
yumargs.extend(argv)
print "Running: %s" % (subprocess.list2cmdline(yumargs), )
yum_env = dict(os.environ)
yum_env['KERNEL_INSTALL_NOOP'] = 'yes'
reposdir_path = os.path.join(yumroot, 'etc', 'yum.repos.d')
# Hideous workaround for the fact that as soon as yum.repos.d
# exists in the install root, yum will prefer it.
tmp_reposdir_path = None
if os.path.isdir(reposdir_path):
tmp_reposdir_path = os.path.join(yumroot, 'etc', 'yum.repos.d.tmp')
os.rename(reposdir_path, tmp_reposdir_path)
proc = subprocess.Popen(yumargs, env=yum_env)
rcode = proc.wait()
if tmp_reposdir_path is not None:
os.rename(tmp_reposdir_path, reposdir_path)
if rcode != 0:
raise ValueError("Yum exited with code %d" % (rcode, ))
@ -346,7 +355,7 @@ def main():
plain_packages = []
for package in packages:
if package[0] == '@':
if package.startswith('@'):
yumgroupinstall(yumroot, package)
else:
plain_packages.append(package)