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):
f = open(pfile, 'r')
for line in f.readlines():
line = line.strip()
if line.startswith('#') or line == '':
continue
if line.startswith('-'):
try:
packages.remove(line[1:].strip())
packages.remove(line[1:])
except KeyError:
pass
else:
packages.add(line.strip())
packages.add(line)
f.close()
packages = list(packages).sort()
packages = list(packages)
packages.sort()
# install the packages to the instroot
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 == []:
return False
arglist = ['-c', yumconf, '-y']
arglist = ['-c', yumconf, '-v']
arglist.append("--installroot=%s" % (destdir,))
arglist.append('install')
pkgs = ''
for package in packages:
pkgs += ' ' + package
arglist.append(pkgs.strip())
arglist += ['install', '-y'] + packages
return yummain.user_main(arglist, exit_code=False)