summaryrefslogtreecommitdiffstats
path: root/anaconda
blob: c0a4c387b65e509795c27a0e593195e7504461d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/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, key) = key
	data.setPackage(h[rpm.RPMTAG_NAME])
	d = os.open("/mnt/redhat/test/6.0/i386/RedHat/RPMS/" + key, os.O_RDONLY)
	return d

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)
db = rpm.opendb(1, rootPath)
ts = rpm.TransactionSet(rootPath, db)

for p in comps.selected():
    ts.add(p.h, (p.h, p.h[1000000]))

ts.order()
p = intf.packageProgessWindow()
print "run", ts.run(0, 0, cb, p)