Merge lp:~nuclearbob/utah/desktop-kernel-detect into lp:utah

Proposed by Max Brustkern
Status: Merged
Merged at revision: 742
Proposed branch: lp:~nuclearbob/utah/desktop-kernel-detect
Merge into: lp:utah
Diff against target: 44 lines (+26/-1)
1 file modified
utah/provisioning/provisioning.py (+26/-1)
To merge this branch: bzr merge lp:~nuclearbob/utah/desktop-kernel-detect
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Review via email: mp+134188@code.launchpad.net

Description of the change

This branch checks the bootloader configuration files on a desktop image and chooses the kernel that is most referenced by those (but not the memtest kernel.) This should fix the raring-desktop-amd64 image problems.

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/provisioning/provisioning.py'
2--- utah/provisioning/provisioning.py 2012-10-25 20:07:44 +0000
3+++ utah/provisioning/provisioning.py 2012-11-13 20:12:25 +0000
4@@ -821,7 +821,31 @@
5 kernelpath = 'linux'
6 elif self.installtype == 'desktop':
7 self.logger.debug('Desktop image detected')
8- kernelpath = './casper/vmlinuz'
9+ # Setup the old default kernel path in case none are found
10+ kernels = {'casper/vmlinuz':0}
11+ # Scan bootloader config files to find kernel images
12+ cfgfiles = ['isolinux/txt.cfg', 'isolinux/rqtxt.cfg',
13+ 'boot/grub/grub.cfg', 'boot/grub/loopback.cfg']
14+ for cfgfile in cfgfiles:
15+ if cfgfile in self.image.listfiles(returnlist=True):
16+ stdout = self.image.dump(cfgfile).communicate()[0]
17+ for line in stdout.splitlines():
18+ if 'kernel' in line or 'linux' in line:
19+ newkernel = line.split()[1].strip('./')
20+ if 'mt86plus' in newkernel:
21+ self.logger.debug('Rejecting '
22+ 'memtest kernel')
23+ else:
24+ self.logger.debug('Found kernel: '
25+ + newkernel)
26+ if newkernel in kernels:
27+ kernels[newkernel] += 1
28+ else:
29+ kernels[newkernel] = 1
30+ # Now we have a list of kernel paths and the number of times
31+ # each once occurs. We'll use the one that occurs most.
32+ kernelpath = sorted([[kernels[kernel], kernel]
33+ for kernel in kernels], reverse=True)[0][1]
34 kernel = os.path.join(tmpdir, 'kernel')
35 self.image.extract(kernelpath, outfile=kernel)
36 else:
37@@ -847,6 +871,7 @@
38 initrdpath = 'initrd.gz'
39 elif self.installtype == 'desktop':
40 self.logger.debug('Desktop image detected')
41+ # TODO: scan for this like desktop
42 initrdpath = './casper/initrd.lz'
43 initrd = os.path.join(tmpdir, os.path.basename(initrdpath))
44 self.image.extract(initrdpath, outfile=initrd)

Subscribers

People subscribed via source and target branches