sort() is an inplace operation on lists, correct other errors in instroot.py.

sort() is inplace for lists, so it doesn't return the sorted list.
Make sure to strip each line read from the packages* files.  In the
installPackages() function, concat the packages list on to the
arglist because that's what yummain is expecting.
This commit is contained in:
David Cantrell 2008-10-04 20:52:17 -10:00
parent 725305dd9c
commit e6aebb1c3d

View File

@ -72,20 +72,23 @@ def createInstRoot(yumconf=None, arch=None, treedir=None, updates=None):
if os.path.isfile(pfile): if os.path.isfile(pfile):
f = open(pfile, 'r') f = open(pfile, 'r')
for line in f.readlines(): for line in f.readlines():
line = line.strip()
if line.startswith('#') or line == '': if line.startswith('#') or line == '':
continue continue
if line.startswith('-'): if line.startswith('-'):
try: try:
packages.remove(line[1:].strip()) packages.remove(line[1:])
except KeyError: except KeyError:
pass pass
else: else:
packages.add(line.strip()) packages.add(line)
f.close() f.close()
packages = list(packages).sort() packages = list(packages)
packages.sort()
# install the packages to the instroot # install the packages to the instroot
if not installPackages(yumconf=yumconf, destdir=destdir, packages=packages): if not installPackages(yumconf=yumconf, destdir=destdir, packages=packages):
@ -115,14 +118,8 @@ def installPackages(yumconf=None, destdir=None, packages=None):
if yumconf is None or destdir is None or packages is None or packages == []: if yumconf is None or destdir is None or packages is None or packages == []:
return False return False
arglist = ['-c', yumconf, '-y'] arglist = ['-c', yumconf, '-v']
arglist.append("--installroot=%s" % (destdir,)) arglist.append("--installroot=%s" % (destdir,))
arglist.append('install') arglist += ['install', '-y'] + packages
pkgs = ''
for package in packages:
pkgs += ' ' + package
arglist.append(pkgs.strip())
return yummain.user_main(arglist, exit_code=False) return yummain.user_main(arglist, exit_code=False)