/[smeserver]/rpms/booty/sme7/raid-bootloader.patch
ViewVC logotype

Annotation of /rpms/booty/sme7/raid-bootloader.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Tue Jun 12 14:52:50 2007 UTC (17 years, 1 month ago) by slords
Branch: MAIN
CVS Tags: booty-0_44_4-1_el4_sme
Import on branch sme7 of package booty-0.44.4-1.el4.sme.src.rpm

1 slords 1.1 diff -Nur -x '*.orig' -x '*.rej' booty-0.44.4/bootloaderInfo.py mezzanine_patched_booty-0.44.4/bootloaderInfo.py
2     --- booty-0.44.4/bootloaderInfo.py 2006-04-19 14:37:24.000000000 -0600
3     +++ mezzanine_patched_booty-0.44.4/bootloaderInfo.py 2007-05-17 22:24:05.000000000 -0600
4     @@ -16,6 +16,7 @@
5     #
6    
7     import os, sys
8     +import isys
9     import crypt
10     import whrandom
11     import butil
12     @@ -419,6 +420,7 @@
13     return args
14    
15     args.append("--location=%s" % (self.defaultDevice,))
16     + args.append("--driveorder=%s" % (",".join(self.drivelist)))
17    
18     if self.args.get():
19     args.append("--append=\"%s\"" %(self.args.get()))
20     @@ -642,6 +644,28 @@
21     def setUseGrub(self, val):
22     self.useGrubVal = val
23    
24     + def getPhysicalDevices(self, device):
25     + # This finds a list of devices on which the given device name resides.
26     + # Accepted values for "device" are raid1 md devices (i.e. "md0"),
27     + # physical disks ("hda"), and real partitions on physical disks
28     + # ("hda1"). Volume groups/logical volumes are not accepted.
29     + #
30     + # XXX this has internal anaconda-ish knowledge. ick.
31     + import isys
32     + import lvm
33     +
34     + if string.split(device, '/', 1)[0] in map (lambda vg: vg[0],
35     + lvm.vglist()):
36     + return []
37     +
38     + if device.startswith('md'):
39     + bootable = 0
40     + parts = checkbootloader.getRaidDisks(device, 1, stripPart=0)
41     + parts.sort()
42     + return parts
43     +
44     + return [device]
45     +
46     def writeGrub(self, instRoot, fsset, bl, langs, kernelList, chainList,
47     defaultDev, justConfigFile):
48     if len(kernelList) < 1:
49     @@ -663,10 +687,12 @@
50     instRoot + cf + '.rpmsave')
51    
52     grubTarget = bl.getDevice()
53     - # XXX wouldn't it be nice if grub really understood raid? :)
54     - if grubTarget.startswith('md'):
55     - ent = fsset.getEntryByDeviceName(grubTarget)
56     - grubTarget = ent.device.members[0]
57     + target = "mbr"
58     + if (grubTarget.startswith('rd/') or grubTarget.startswith('ida/') or grubTarget.startswith('cciss/')):
59     + if grubTarget[-2] == 'p' or grubTarget[-3] == 'p':
60     + target = "partition"
61     + elif grubTarget[-1].isdigit() and not grubTarget.startswith('md'):
62     + target = "partition"
63    
64     f = open(instRoot + cf, "w+")
65    
66     @@ -692,9 +718,10 @@
67     f.write("# all kernel and initrd paths are relative "
68     "to /boot/, eg.\n")
69    
70     - bootDev = bootDev.device.getDevice(asBoot = 1)
71     + bootDevs = self.getPhysicalDevices(bootDev.device.getDevice())
72     + bootDev = bootDev.device.getDevice()
73    
74     - f.write('# root %s\n' % self.grubbyPartitionName(bootDev))
75     + f.write('# root %s\n' % self.grubbyPartitionName(bootDevs[0]))
76     f.write("# kernel %svmlinuz-version ro "
77     "root=/dev/%s\n" % (cfPath, rootDev))
78     f.write("# initrd %sinitrd-version.img\n" % (cfPath))
79     @@ -741,11 +768,11 @@
80     # we only want splashimage if they're not using a serial console
81     if os.access("%s/boot/grub/splash.xpm.gz" %(instRoot,), os.R_OK):
82     f.write('splashimage=%s%sgrub/splash.xpm.gz\n'
83     - % (self.grubbyPartitionName(bootDev), cfPath))
84     + % (self.grubbyPartitionName(bootDevs[0]), cfPath))
85     f.write("hiddenmenu\n")
86    
87     - usedDevs[bootDev] = 1
88     - usedDevs[grubTarget] = 1
89     + for dev in self.getPhysicalDevices(grubTarget):
90     + usedDevs[dev] = 1
91    
92     if self.password:
93     f.write('password --md5 %s\n' %(self.password))
94     @@ -757,7 +784,7 @@
95     initrd = booty.makeInitrd (kernelTag, instRoot)
96    
97     f.write('title %s (%s)\n' % (longlabel, version))
98     - f.write('\troot %s\n' % self.grubbyPartitionName(bootDev))
99     + f.write('\troot %s\n' % self.grubbyPartitionName(bootDevs[0]))
100    
101     realroot = getRootDevName(initrd, fsset, rootDev, instRoot)
102     realroot = " root=%s" %(realroot,)
103     @@ -801,21 +828,31 @@
104     except:
105     pass
106    
107     + for dev in self.getPhysicalDevices(rootDev):
108     + usedDevs[dev] = 1
109     +
110     + for dev in bootDevs:
111     + usedDevs[dev] = 1
112    
113     if not os.access(instRoot + "/boot/grub/device.map", os.R_OK):
114     f = open(instRoot + "/boot/grub/device.map", "w+")
115     f.write("# this device map was generated by anaconda\n")
116     f.write("(fd0) /dev/fd0\n")
117     devs = usedDevs.keys()
118     - devs.sort()
119     usedDevs = {}
120     for dev in devs:
121     drive = getDiskPart(dev)[0]
122     if usedDevs.has_key(drive):
123     continue
124     - f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive),
125     - drive))
126     usedDevs[drive] = 1
127     + devs = usedDevs.keys()
128     + devs.sort()
129     + for drive in devs:
130     + # XXX hack city. If they're not the sort of thing that'll
131     + # be in the device map, they shouldn't still be in the list.
132     + if not drive.startswith('md'):
133     + f.write("(%s) /dev/%s\n" % (self.grubbyDiskName(drive),
134     + drive))
135     f.close()
136    
137     if self.forceLBA32:
138     @@ -841,14 +878,22 @@
139     f.write("forcelba=0\n")
140     f.close()
141    
142     - part = self.grubbyPartitionName(bootDev)
143     - prefix = "%s/%s" % (self.grubbyPartitionName(bootDev), grubPath)
144     - cmd = "root %s\ninstall %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \
145     - (part, forcelba, grubPath, self.grubbyPartitionName(grubTarget),
146     - grubPath, part, grubPath)
147     + cmds = []
148     + for bootDev in bootDevs:
149     + gtDisk = self.grubbyPartitionName(getDiskPart(bootDev)[0])
150     + bPart = self.grubbyPartitionName(bootDev)
151     +
152     + stage1Target = gtDisk
153     + if target == "partition":
154     + stage1Target = self.grubbyPartitionName(bootDev)
155     +
156     + cmd = "root %s\nsetup %s" % (bPart, stage1Target)
157     + cmds.append(cmd)
158    
159     if not justConfigFile:
160     - log("GRUB command %s", cmd)
161     + log("GRUB commands:")
162     + for cmd in cmds:
163     + log("\t%s\n", cmd)
164    
165     # copy the stage files over into /boot
166     rhpl.executil.execWithRedirect( "/sbin/grub-install",
167     @@ -866,7 +911,8 @@
168    
169     # really install the bootloader
170     p = os.pipe()
171     - os.write(p[1], cmd + '\n')
172     + for cmd in cmds:
173     + os.write(p[1], cmd + '\n')
174     os.close(p[1])
175     rhpl.executil.execWithRedirect('/sbin/grub' ,
176     [ "grub", "--batch", "--no-floppy",
177     @@ -1045,40 +1091,64 @@
178     bootDev = fsset.getEntryByMountPoint("/")
179     grubPath = "/boot/grub"
180     cfPath = "/boot/"
181     - bootDev = bootDev.device.getDevice(asBoot = 1)
182    
183     - part = self.grubbyPartitionName(bootDev)
184     - prefix = "%s/%s" % (self.grubbyPartitionName(bootDev), grubPath)
185     - cmd = "root %s\ninstall %s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \
186     - (part, grubPath, self.grubbyPartitionName(theDev[5:]),
187     - grubPath, part, grubPath)
188     -
189     - if not justConfigFile:
190     - log("GRUB command %s", cmd)
191     + masterBootDev = bootDev.device.getDevice(asBoot = 0)
192     + if masterBootDev[0:2] == 'md':
193     + rootDevs = checkbootloader.getRaidDisks(masterBootDev, raidLevel=1,
194     + stripPart = 0)
195     + else:
196     + rootDevs = [masterBootDev]
197    
198     - # copy the stage files over into /boot
199     - rhpl.executil.execWithRedirect( "/sbin/grub-install",
200     + if theDev[5:7] == 'md':
201     + stage1Devs = checkbootloader.getRaidDisks(theDev[5:], raidLevel=1)
202     + else:
203     + stage1Devs = [theDev[5:]]
204     +
205     + for stage1Dev in stage1Devs:
206     + # cross fingers; if we can't find a root device on the same
207     + # hardware as this boot device, we just blindly hope the first
208     + # thing in the list works.
209     +
210     + grubbyStage1Dev = self.grubbyPartitionName(stage1Dev)
211     +
212     + grubbyRootPart = self.grubbyPartitionName(rootDevs[0])
213     +
214     + for rootDev in rootDevs:
215     + testGrubbyRootDev = getDiskPart(rootDev)[0]
216     + testGrubbyRootDev = self.grubbyPartitionName(testGrubbyRootDev)
217     +
218     + if grubbyStage1Dev == testGrubbyRootDev:
219     + grubbyRootPart = self.grubbyPartitionName(rootDev)
220     + break
221     +
222     + cmd = "root %s\nsetup %s" % (grubbyRootPart, grubbyStage1Dev)
223     +
224     + if not justConfigFile:
225     + log("GRUB command %s", cmd)
226     +
227     + # copy the stage files over into /boot
228     + rhpl.executil.execWithRedirect( "/sbin/grub-install",
229     ["/sbin/grub-install", "--just-copy"],
230     stdout = "/dev/tty5", stderr = "/dev/tty5",
231     root = instRoot)
232    
233     - # get the stage files synced to disk
234     - import isys
235     - isys.sync()
236     - isys.sync()
237     - isys.sync()
238     + # get the stage files synced to disk
239     + import isys
240     + isys.sync()
241     + isys.sync()
242     + isys.sync()
243    
244     - # really install the bootloader
245     - p = os.pipe()
246     - os.write(p[1], cmd + '\n')
247     - os.close(p[1])
248     - rhpl.executil.execWithRedirect('/sbin/grub' ,
249     + # really install the bootloader
250     + p = os.pipe()
251     + os.write(p[1], cmd + '\n')
252     + os.close(p[1])
253     + rhpl.executil.execWithRedirect('/sbin/grub' ,
254     [ "grub", "--batch", "--no-floppy",
255     "--device-map=/boot/grub/device.map" ],
256     stdin = p[0],
257     stdout = "/dev/tty5", stderr = "/dev/tty5",
258     root = instRoot)
259     - os.close(p[0])
260     + os.close(p[0])
261    
262     return ""
263    
264     diff -Nur -x '*.orig' -x '*.rej' booty-0.44.4/checkbootloader.py mezzanine_patched_booty-0.44.4/checkbootloader.py
265     --- booty-0.44.4/checkbootloader.py 2003-03-04 17:11:48.000000000 -0700
266     +++ mezzanine_patched_booty-0.44.4/checkbootloader.py 2007-05-17 22:23:10.000000000 -0600
267     @@ -56,8 +56,13 @@
268     return (name, partNum)
269    
270    
271     -def getRaidDisks(raidDevice):
272     +def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
273     rc = []
274     + if raidLevel is not None:
275     + try:
276     + raidLevel = "raid%d" % (int(raidLevel),)
277     + except ValueError:
278     + pass
279    
280     try:
281     f = open("/proc/mdstat", "r")
282     @@ -69,14 +74,19 @@
283     for line in lines:
284     fields = string.split(line, ' ')
285     if fields[0] == raidDevice:
286     + if raidLevel is not None and fields[3] != raidLevel:
287     + continue
288     for field in fields[4:]:
289     if string.find(field, "[") == -1:
290     continue
291     dev = string.split(field, '[')[0]
292     if len(dev) == 0:
293     continue
294     - disk = getDiskPart(dev)[0]
295     - rc.append(disk)
296     + if stripPart:
297     + disk = getDiskPart(dev)[0]
298     + rc.append(disk)
299     + else:
300     + rc.append(dev)
301    
302     return rc
303    

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed