On Sun, 2008-11-16 at 11:15 -0600, Callum Lerwick wrote: > On Fri, 2008-11-14 at 13:32 -0600, Les Mikesell wrote: > > I'm still conviced that what is needed is a simple way to export a > > complete installed list from any working machine along with repo and > > version information that the machine repeating the install can use or > > ignore. That way there is no guesswork in the installer and it works > > the same for a spin providing some extra stuff in an additional repo > > and a local shop with local packages in a local repo. > > So develop one. You can start with: > > rpm -qa --queryformat %{NAME}-%{version}-%{release}.%{arch}\\n | sort > packagelist.txt > > Then on the destination: > > xargs yum install < packagelist.txt > > There, you're 90% there with just two trivial lines of shellscript. <snip> Here's a little python script I wrote that will give you a minimum package list based on the current install's yum setup. The idea is that you can use this to work out a kickstart file based on your current setup. (Please note that despite the name, it doesn't actually *build* the kickstart file; just the packages section. Also note that it requires yum-utils.) Jonathan
#!/usr/bin/python -tt import os import sys import yum import yum.comps from optparse import OptionParser version = "0.0.1" def unique(list): result = [] found = {} for item in list: if item in found: continue result.append(item) found[item] = True return result rpmlist = [] leaflist = [] man_removed = [] installed_groups = [] parser = OptionParser(version = "Kickstart-builder version %s" % version) parser.add_option("-b", "--blacklist", action="append", dest="blacklist", help="File containing groups you don't want in the kickstart file") (opts, regexs) = parser.parse_args() ym = yum.YumBase() ym.doConfigSetup(init_plugins=False) ym.doRepoSetup() ym.doSackSetup() ym.doTsSetup() ym.doRpmDBSetup() # Build list of installed rpms for pkg in ym.rpmdb.simplePkgList(): rpmlist.append(pkg[0]) rpmlist = unique(rpmlist) rpmlist.sort() # Build list of leaves x = os.popen("package-cleanup --leaves --all | grep -v gpg-pubkey | grep -v \"Setting up yum\" | grep -v \"Excluding Packages in global exclude list\" | grep -v Finished | xargs rpm -q --qf=\"%{NAME}\n\"", "r") leaflist = x.read() leaflist = leaflist.split("\n") x.close() leaflist.sort() while '' in leaflist: leaflist.remove('') leaflist = unique(leaflist) leaflist.sort() # Remove blacklisted groups grouplist = unique(ym.comps.get_groups()) if opts.blacklist: for blfile in opts.blacklist: try: f = open(blfile, "r") except: print "Unable to open blacklist file %s" % blfile sys.exit(1) blgroup = f.readline() while blgroup: blgroup = blgroup[:-1] for group in grouplist: if blgroup == group.name: grouplist.remove(group) break blgroup = f.readline() # Work out which packages were installed for group in grouplist: installed = True # Check for mandatory packages for pkg in group.mandatory_packages: if pkg not in rpmlist and ym.pkgSack.contains(pkg): installed = False break if not installed: continue # Check for conditional packages found = False for pkg in group.conditional_packages.keys(): cond_pkg = group.conditional_packages[pkg] if cond_pkg in rpmlist and pkg not in rpmlist: installed = False break if cond_pkg in rpmlist and pkg in rpmlist: found = True # Check whether most of the default packages have been selected. # The default cutoff is 75% of mandatory + default packages have # been installed. cutoff = int(((len(group.mandatory_packages) + len(group.default_packages)) * 0.75) + 0.5) count = len(group.mandatory_packages) for pkg in group.default_packages: if pkg in rpmlist: count +=1 if count >= cutoff: break if count < cutoff: installed = False # No mandatory packages and no conditional packages installed if not found and len(group.mandatory_packages) == 0 and len(group.default_packages) == 0: installed = False if not installed: continue # Add mandatory packages to default install set for pkg in group.mandatory_packages: if pkg in leaflist: leaflist.remove(pkg) # Add appropriate conditional packages to default install set for pkg in group.conditional_packages.keys(): cond_pkg = group.conditional_packages[pkg] if cond_pkg in rpmlist and pkg in leaflist: # If this is true, pkg is in rpmlist leaflist.remove(pkg) # Remove appropriate default packages for pkg in group.default_packages: if pkg in rpmlist: if pkg in leaflist: leaflist.remove(pkg) else: man_removed.append(pkg) installed_groups.append(group.name) man_removed = unique(man_removed) man_removed.sort() installed_groups.sort() # Print groups for group in installed_groups: print "@%s" % group # Print added packages for pkg in leaflist: print "%s" % pkg # Print removed packages for pkg in man_removed: print "-%s" % pkg
Attachment:
signature.asc
Description: This is a digitally signed message part
-- fedora-devel-list mailing list fedora-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-devel-list