#!/usr/bin/python import sys, getopt, os (args, extra) = getopt.getopt(sys.argv[1:], 'p:gTtdr:', [ 'gui', 'text', 'test', 'force', 'debug', 'rootpath=', 'testpath=' ]) mode = None test = 0 force = 0 debug = 0 rootPath = None for n in args: (str, arg) = n if (str == '-g' or str == '--gui'): mode = 'g' elif (str == '-T' or str == '--text'): mode = 't' elif (str == '-t' or str == '--test'): test = 1 elif (str == '-d' or str == '--debug'): debug = 1 elif (str == '-r' or str == '--rootpath'): rootPath = arg elif (str == '-p' or str == '--testpath'): testPath = arg elif (str == '--force'): force = 1 if (debug): import pdb pdb.set_trace() if (not test and os.getpid() > 10 and not force): print "you're running me on a live system! that's incredibly stupid." sys.exit(1) if (test): sys.path.append('balkan') sys.path.append('rpmmodule') elif (mode == None): try: f = open('/dev/fb0', 'r') f.close() mode = 'g' except: mode = 't' # imports after setting up the path from image import InstallMethod from comps import ComponentSet import rpm def cb(what, amount, total, key, data): if (what == rpm.RPMCALLBACK_INST_OPEN_FILE): (h, method) = key data.setPackage(h[rpm.RPMTAG_NAME]) data.setPackageScale(0, 1) fn = method.getFilename(h) d = os.open(fn, os.O_RDONLY) return d elif (what == rpm.RPMCALLBACK_INST_PROGRESS): data.setPackageScale(amount, total) if (mode == 'g' and not os.environ.has_key('DISPLAY')): os.environ['DISPLAY'] = ':0' server = os.fork() if (not server): os.execv('/usr/X11R6/bin/XF86_FBDev', ['/usr/X11R6/bin/XF86_FBDev']) child = os.fork() if (child): os.waitpid(child, 0) os.kill(server, 15) sys.exit(0) if (mode == 'g'): from gui import InstallInterface elif (mode == 't'): from text import InstallInterface else: print "No mode was specified" sys.exit(1) method = InstallMethod(testPath) intf = InstallInterface() w = intf.waitWindow("Reading", "Reading package information...") hdlist = method.readHeaders() comps = ComponentSet('i386', 'comps', hdlist) intf.popWaitWindow(w) intf.run(hdlist, rootPath) comps['Base'].select(1) try: os.mkdir(rootPath + '/var') os.mkdir(rootPath + '/var/lib') os.mkdir(rootPath + '/var/lib/rpm') except: print "error creating directory" db = rpm.opendb(1, rootPath) ts = rpm.TransactionSet(rootPath, db) for p in comps.selected(): ts.add(p.h, (p.h, method)) ts.order() p = intf.packageProgessWindow() print "run", ts.run(0, 0, cb, p)