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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# For an install to proceed, the following todo fields must be filled in
#
# mount list (unless todo.runLive) addMount()
# lilo boot.b installation (may be None) liloLocation()
import rpm, os
import util, isys
from lilo import LiloConfiguration
def instCallback(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)
class ToDo:
def umountFilesystems(self):
self.mounts.sort(mountListCmp)
self.mounts.reverse()
for n in self.mounts:
isys.umount(n)
def makeFilesystems(self):
self.mounts.sort(mountListCmp)
for n in self.mounts:
(device, mntpoint, format) = n
if not format: continue
w = self.intf.waitWindow("Formatting",
"Formatting %s filesystem..." % (mntpoint,))
util.execWithRedirect("mke2fs", [ "mke2fs", device ],
stdout = None, searchPath = 1)
w.pop()
def mountFilesystems(self):
for n in self.mounts:
(device, mntpoint, format) = n
isys.mount(device, self.instPath + mntpoint)
def installSystem(self):
# make sure we have the header list and comps file
self.headerList()
comps = self.compsList()
self.makeFilesystems()
self.mountFilesystems()
#os.mkdir(self.instPath + '/var')
#os.mkdir(self.instPath + '/var/lib')
#os.mkdir(self.instPath + '/var/lib/rpm')
db = rpm.opendb(1, self.instPath)
ts = rpm.TransactionSet(self.instPath, db)
for p in comps.selected():
ts.add(p.h, (p.h, self.method))
ts.order()
#p = self.intf.packageProgessWindow()
#ts.run(0, 0, instCallback, p)
self.installLilo()
def installLilo(self):
if not self.liloDevice: return
# FIXME: make an initrd here
l = LiloConfiguration()
l.addEntry("boot", self.liloDevice)
l.addEntry("map", "/boot/map")
l.addEntry("install", "/boot/boot.b")
l.addEntry("prompt")
l.addEntry("timeout", "50")
sl = LiloConfiguration()
sl.addEntry("label", "linux")
sl.addEntry("root", "/dev/hda8")
sl.addEntry("read-only")
l.addImage("/boot/vmlinuz-2.2.2", sl)
l.write(self.instPath + "/etc/lilo.conf")
def addMount(self, device, location, reformat = 1):
self.mounts.append((device, location, reformat))
def freeHeaders(self):
if (self.hdList):
self.hdList = None
def headerList(self):
if (not self.hdList):
w = self.intf.waitWindow("Reading",
"Reading package information...")
self.hdList = self.method.readHeaders()
w.pop()
return self.hdList
def liloLocation(self, device):
self.liloDevice = device
def compsList(self):
if (not self.comps):
self.headerList()
self.comps = self.method.readComps(self.hdList)
self.comps['Base'].select(1)
return self.comps
def __init__(self, intf, method, rootPath, runLive):
self.intf = intf
self.method = method
self.mounts = []
self.hdList = None
self.comps = None
self.instPath = rootPath
self.runLive = runLive
pass
def mountListCmp(first, second):
mnt1 = first[1]
mnt2 = first[2]
if (first < second):
return -1
elif (first == second):
return 0
return 1
|