#!/usr/bin/env python import pacman, os, sys from optparse import OptionParser # since we're in chroot, we no longer have to check for up to date libs. libs = [] packages = ['parted', 'pacman-g2', 'bash', 'kernel', 'busybox', 'dhcpcd', 'dialog', 'e2fsprogs', 'eject', 'frugalware', 'glibc', 'kbd', 'module-init-tools', 'ncurses', 'netkit-base', 'udev', 'util-linux-ng', 'mdadm', 'xfsprogs', 'ppp', 'rp-pppoe', 'glib2', 'bzip2', 'libarchive', 'zlib', 'frugalwareutils', 'wireless_tools', 'dropbear', 'bastet', 'readline', 'shadow', 'device-mapper', 'lvm2', 'wpa_supplicant', 'openssl', 'pciutils', 'b43-fwcutter'] if os.uname()[-1] in ['i686', 'x86_64']: packages.extend(['reiserfsprogs', 'ipw2200-firmware', 'acx100', 'madwifi', 'rt2500']) elif os.uname()[-1] == 'ppc': packages.extend(['mac-fdisk']) # when releasing a new setup, please update this. version = "0.9.6" # parse our options parser = OptionParser(version="configure for Frugalware Setup v%s" % (version)) parser.set_defaults(debug=False) parser.set_defaults(usb=False) parser.set_defaults(tftp=False) parser.set_defaults(repo="current") parser.set_defaults(prefix="/usr/local") parser.add_option("--with-debug", action="store", dest="debug", help="Build setup with debug options. Can be no (default), gdb or valgrind") parser.add_option("--enable-usb", action="store_true", dest="usb", help="Build usb installer image") parser.add_option("--disable-usb", action="store_false", dest="usb", help="Don't build usb installer image (default)") parser.add_option("--enable-tftp", action="store_true", dest="tftp", help="Build tftp installer image") parser.add_option("--disable-tftp", action="store_false", dest="tftp", help="Don't build tftp installer image (default)") parser.add_option("--repo", action="store", dest="repo", help="Select the repo to build for. Can be current (default), testing or stable") parser.add_option("--prefix", action="store", dest="prefix", help="Select the install prefix (defaults to /usr/local)") (options, args) = parser.parse_args() # if we want debug then we should add gdb and it's dependencies sys.stdout.write("checking for debug support... ") sys.stdout.flush() if options.debug == "gdb": sys.stdout.write("gdb.\n") sys.stdout.flush() packages.append('gdb') packages.append('expat') elif options.debug == "valgrind": sys.stdout.write("valgrind.\n") sys.stdout.flush() packages.append('valgrind') else: sys.stdout.write("no.\n") sys.stdout.flush() sys.stdout.write("checking for usb support... ") if options.usb: sys.stdout.write("yes.\n") sys.stdout.flush() else: sys.stdout.write("no.\n") sys.stdout.flush() sys.stdout.write("checking for tftp support... ") if options.tftp: sys.stdout.write("yes.\n") sys.stdout.flush() else: sys.stdout.write("no.\n") sys.stdout.flush() def pkgGetVers(db, names, ret={}): lp = pacman.db_getpkgcache(db) while lp: pkg = pacman.void_to_PM_PKG(pacman.list_getdata(lp)) pkgname = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_NAME)) if pkgname in names and pkgname not in ret: ret[pkgname] = pkgname = pacman.void_to_char(pacman.pkg_getinfo(pkg, pacman.PKG_VERSION)) lp = pacman.list_next(lp) return ret try: os.unlink('config.mak') except OSError: pass if pacman.initialize("/") == -1: raise "failed to init the pacman lib" if options.repo == "stable": remote = pacman.db_register("frugalware") else: remote = pacman.db_register("frugalware-current") local = pacman.db_register("local") sys.stdout.write("reading the remote database... ") sys.stdout.flush() remotevers = pkgGetVers(remote, libs) sys.stdout.write("done.\nreading the local database... ") sys.stdout.flush() localvers = pkgGetVers(local, libs) sys.stdout.write("done.\n") sys.stdout.flush() for k, v in remotevers.items(): sys.stdout.write("checking for host %s... " % k) if remotevers[k] != localvers[k]: sys.stdout.write("failed, please do a 'pacman-g2 -S %s'\n" % k) sys.exit(1) else: sys.stdout.write("done.\n") remotevers = pkgGetVers(remote, packages, remotevers) socket = open("config.mak", "w") # write out our required options socket.write("VERSION = %s\n" % version) if options.debug: socket.write("DEBUG = %s\n" % options.debug) else: socket.write("DEBUG = false\n") if options.usb: socket.write("USB = true\n") else: socket.write("USB = false\n") if options.tftp: socket.write("TFTP = true\n") else: socket.write("TFTP = false\n") socket.write("PREFIX = %s\n" % options.prefix) # check whether stable or testing was requested sys.stdout.write("checking which repo to build for... ") sys.stdout.flush() if options.repo == "current": sys.stdout.write("current\n") socket.write("STABLE = false\nTESTING = false\n\n") elif options.repo == "testing": sys.stdout.write("testing\n") socket.write("STABLE = false\nTESTING = true\n\n") elif options.repo == "stable": sys.stdout.write("stable\n") socket.write("STABLE = true\nTESTING = false\n\n") else: sys.stdout.write("invalid repo specified!\n") sys.exit(1) # write the package versions for k, v in localvers.items(): print "checking for %s... %s" % (k, v) socket.write("%sVER = %s\n" % (k.upper(), v)) socket.write("\n") # write the package and source arrays socket.write("packages = \\\n") for k, v in localvers.items(): socket.write("\t %s \\\n" % k) socket.write("\t \n") socket.write("sources = \\\n") for k, v in localvers.items(): socket.write("\t %s-$(%sVER)-$(CARCH).fpm \\\n" % (k, k.upper())) socket.write("\t \n") socket.close()