From e6aebb1c3d008c8ec8a36e785511b1e39996b5b0 Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Sat, 4 Oct 2008 20:52:17 -1000 Subject: [PATCH] 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. --- src/pylorax/instroot.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/pylorax/instroot.py b/src/pylorax/instroot.py index c3595e46..8d9cf982 100644 --- a/src/pylorax/instroot.py +++ b/src/pylorax/instroot.py @@ -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)