Merge lp:~marceloshima/testdrive/grub into lp:testdrive

Proposed by Marcelo Boveto Shima
Status: Needs review
Proposed branch: lp:~marceloshima/testdrive/grub
Merge into: lp:testdrive
Diff against target: 203 lines (+116/-23)
3 files modified
50_testdrive (+71/-0)
testdrive (+34/-20)
testdrive.py (+11/-3)
To merge this branch: bzr merge lp:~marceloshima/testdrive/grub
Reviewer Review Type Date Requested Status
Andres Rodriguez Needs Resubmitting
Review via email: mp+26459@code.launchpad.net

Description of the change

This branch adds the option --grub.
This option uses /var/cache/testdrive as cache dir
and ignores the virtual machine stuff.

Once the iso had been downloaded it invokes update-grub.

The script 50_testdrive should be placed at /etc/grub.d/
When update-grub is invoke it looks for iso files at
/var/cache/testdrive/iso and creates a boot menu for
booting directly into the iso.

To post a comment you must log in.
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

This is a neat idea :-) We need to make sure, though, that it's well documented that this invocation of TestDrive would affect your real system and not a virtual machine.

Andres will need to review this merge proposal, since he has drastically changed TestDrive for the GTK bits.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

HI Marcelo,

This is indeed a nice idea. Sorry for not reviewing it earlier but I've been busy with the GTK.

Anyways, would you please update your branch with the trunk to see if the latest changes of testdrive have affected yours. Once that done, please resubmit for review.

Thank you.

review: Needs Resubmitting
Revision history for this message
Jackson Doak (noskcaj) wrote :

i hope we can get this working now, it's a good idea

Unmerged revisions

243. By Marcelo Boveto Shima <mshima@note1>

Add grub support to testdrive

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '50_testdrive'
--- 50_testdrive 1970-01-01 00:00:00 +0000
+++ 50_testdrive 2010-06-01 04:14:22 +0000
@@ -0,0 +1,71 @@
1#!/bin/bash -e
2# Created by Robert Wall, 2010-03-07
3# Modified by Marcelo Boveto Shima, 2010-03-07
4
5#DEBUG=0
6# Path to USB stick's current mountpoint
7#boot_disk_mountpoint="`pwd`"
8# path to location of ISOs
9isolocation="/var/cache/testdrive/iso"
10
11# Others options at /usr/share/initramfs-tools/scripts/casper-bottom/ at casper/filesystem.squashfs
12
13OPTIONS="noeject noprompt quiet splash"
14if [ ! -d "${boot_disk_mountpoint}${isolocation}" ]
15then
16 exit 0
17fi
18
19if [ -n "$boot_disk_mountpoint" ]
20then
21 exec > "${boot_disk_mountpoint}/boot/grub/grub.cfg"
22fi
23
24for isofile in ${boot_disk_mountpoint}${isolocation}/*.iso
25do
26 [ x$DEBUG == "x1" ] && echo "Trying $isofile" >&2
27 relative_isofile=${isolocation}/`basename $isofile`
28 TITLE=`isoinfo -R -x "/.disk/info" -i $isofile | sed "s/\"/'/g"`
29 if [ -z "$TITLE" ]
30 then
31 TITLE=`isoinfo -R -d -i $isofile | grep -e "Volume id" | cut -d":" -f2 | sed "s/^ //"`
32 fi
33 if [ -z "$TITLE" ]
34 then
35 TITLE=`isoinfo -R -x "/README.diskdefines" -i $isofile | grep DISKNAME | cut -d' ' -f4- | sed "s/\"/'/g"`
36 fi
37 if [ -z "$TITLE" ]
38 then
39 TITLE=`basename $isofile .iso`
40 fi
41 TITLE="Testdrive: $TITLE"
42 [ x$DEBUG == "x1" ] && echo "Title $TITLE" >&2
43
44 INSTALLER_LANG=`cat /etc/default/locale | grep "LANG=" | cut -d"\"" -f2 | cut -d"." -f1`
45 if [ -n "$INSTALLER_LANG" ]
46 then
47 INSTALLER_LANG="debian-installer/language=$INSTALLER_LANG"
48 fi
49 [ x$DEBUG == "x1" ] && echo "Lang $INSTALLER_LANG" >&2
50
51 INITRD=`isoinfo -R -f -i $isofile | grep initrd | grep -e "\.gz$" -e "\.lz$" -e "\.img" | tail -n1`
52 [ x$DEBUG == "x1" ] && echo "Initrd $INITRD" >&2
53 VMLINUZ=`isoinfo -R -f -i $isofile | grep "vmlinuz" | tail -n1`
54 [ x$DEBUG == "x1" ] && echo "Vmlinuz $VMLINUZ" >&2
55
56 if [ -z "$INITRD" -o -z "$VMLINUZ" ]
57 then
58 echo "File not found skipping" >&2
59 exit 0
60 fi
61
62 echo "Found $TITLE on $isofile" >&2
63 cat <<EOF
64menuentry "$TITLE" {
65 loopback loop $relative_isofile
66 linux (loop)$VMLINUZ boot=casper iso-scan/filename=$relative_isofile $OPTIONS $INSTALLER_LANG --
67 initrd (loop)$INITRD
68}
69EOF
70done
71
072
=== modified file 'testdrive'
--- testdrive 2010-05-20 22:48:26 +0000
+++ testdrive 2010-06-01 04:14:22 +0000
@@ -136,6 +136,8 @@
136 help='try to launch usb-creator for further testing')136 help='try to launch usb-creator for further testing')
137 parser.add_option('-r', '--release', action='store', type='string', dest='release',137 parser.add_option('-r', '--release', action='store', type='string', dest='release',
138 help='hardcode Ubuntu RELEASE codename')138 help='hardcode Ubuntu RELEASE codename')
139 parser.add_option('-g', '--grub', action='store_true', dest='grub', default=False,
140 help='put the iso into a system directory for grub')
139141
140 (opt, args) = parser.parse_args()142 (opt, args) = parser.parse_args()
141 info("version passed: %s" % opt.version)143 info("version passed: %s" % opt.version)
@@ -191,26 +193,35 @@
191 hasOptions = True193 hasOptions = True
192 td.r = opt.release194 td.r = opt.release
193195
194 # Choose the virtualization engine196 if opt.grub:
195 if not td.VIRT:197 grub_script = "/etc/grub.d/50_testdrive"
196 td.VIRT = td.get_virt()198 info("Looking for %s" % grub_script)
197 #NOTICE: Removed from get_virt() and placed here199 if not os.path.exists(grub_script):
198 if td.VIRT == 1:200 error("Grub script not installed.")
199 error("Your CPU supports KVM acceleration; please install KVM:\n\201 td.CACHE = "/var/cache/testdrive"
200 sudo apt-get install qemu-kvm")202 td.CACHE_ISO = "/var/cache/testdrive/iso"
201 if td.VIRT == 0:203 td.GRUB = True
202 error("Your CPU does not support acceleration; run kvm-ok for more information; then please install VirtualBox:\n\204 else:
203 kvm-ok\n\205 # Choose the virtualization engine
204 sudo apt-get install virtualbox-ose")206 if not td.VIRT:
205 if td.VIRT == "kvm":207 td.VIRT = td.get_virt()
206 info("Using KVM for virtual machine hosting...");208 #NOTICE: Removed from get_virt() and placed here
207 virt = kvm.KVM(td)209 if td.VIRT == 1:
208 if td.VIRT == "virtualbox":210 error("Your CPU supports KVM acceleration; please install KVM:\n\
209 info("Using VirtualBox for virtual machine hosting...")211 sudo apt-get install qemu-kvm")
210 virt = virtualbox.VBox(td)212 if td.VIRT == 0:
211 if td.VIRT == "paralels":213 error("Your CPU does not support acceleration; run kvm-ok for more information; then please install VirtualBox:\n\
212 info("Using Parallels Desktop for virtual machine hosting...")214 kvm-ok\n\
213 virt = parallels.Parallels(td)215 sudo apt-get install virtualbox-ose")
216 if td.VIRT == "kvm":
217 info("Using KVM for virtual machine hosting...");
218 virt = kvm.KVM(td)
219 if td.VIRT == "virtualbox":
220 info("Using VirtualBox for virtual machine hosting...")
221 virt = virtualbox.VBox(td)
222 if td.VIRT == "paralels":
223 info("Using Parallels Desktop for virtual machine hosting...")
224 virt = parallels.Parallels(td)
214225
215 # set defaults were undefined226 # set defaults were undefined
216 td.set_defaults()227 td.set_defaults()
@@ -269,6 +280,9 @@
269 if cmd != 0:280 if cmd != 0:
270 run_or_die(cmd)281 run_or_die(cmd)
271282
283 if opt.grub:
284 run_or_die("update-grub")
285 sys.exit(0)
272 # Launch the VM286 # Launch the VM
273 info("Validating Virtualization Method....")287 info("Validating Virtualization Method....")
274 try:288 try:
275289
=== modified file 'testdrive.py'
--- testdrive.py 2010-05-28 19:38:15 +0000
+++ testdrive.py 2010-06-01 04:14:22 +0000
@@ -42,6 +42,7 @@
42 self.r = None42 self.r = None
43 self.PROTO = None43 self.PROTO = None
44 self.m = None44 self.m = None
45 self.GRUB = False
4546
46 def set_values(self, var, value):47 def set_values(self, var, value):
47 if var == 'kvm_args':48 if var == 'kvm_args':
@@ -70,6 +71,8 @@
70 self.u = value71 self.u = value
71 if var == 'm':72 if var == 'm':
72 self.m = [value]73 self.m = [value]
74 if var == 'grub':
75 self.GRUB = [value]
7376
74 def load_config_file(self, config_file):77 def load_config_file(self, config_file):
75 cfg = ConfigParser.ConfigParser()78 cfg = ConfigParser.ConfigParser()
@@ -128,11 +131,11 @@
128131
129 if self.CACHE_IMG is None:132 if self.CACHE_IMG is None:
130 self.CACHE_IMG = '%s/img' % self.CACHE133 self.CACHE_IMG = '%s/img' % self.CACHE
131 if not os.path.exists(self.CACHE_IMG):134 if not self.GRUB and not os.path.exists(self.CACHE_IMG):
132 os.makedirs(self.CACHE_IMG, 0700)135 os.makedirs(self.CACHE_IMG, 0700)
133 # if running the image from /dev/shm, remove the image when done136 # if running the image from /dev/shm, remove the image when done
134 # (unless CLEAN_IMG is set)137 # (unless CLEAN_IMG is set)
135 if self.CLEAN_IMG is None:138 if not self.GRUB and self.CLEAN_IMG is None:
136 if self.CACHE_IMG == '/dev/shm':139 if self.CACHE_IMG == '/dev/shm':
137 self.CLEAN_IMG = True140 self.CLEAN_IMG = True
138 else:141 else:
@@ -141,7 +144,12 @@
141 if self.CACHE_ISO is None:144 if self.CACHE_ISO is None:
142 self.CACHE_ISO = '%s/iso' % self.CACHE145 self.CACHE_ISO = '%s/iso' % self.CACHE
143 if not os.path.exists(self.CACHE_ISO):146 if not os.path.exists(self.CACHE_ISO):
144 os.makedirs(self.CACHE_ISO, 0700)147 if not self.GRUB:
148 os.makedirs(self.CACHE_ISO, 0700)
149 else:
150 os.makedirs(self.CACHE_ISO, 0755)
151 if self.GRUB:
152 return
145153
146 if len(self.SMP) == 0:154 if len(self.SMP) == 0:
147 self.SMP = commands.getoutput("grep -c ^processor /proc/cpuinfo")155 self.SMP = commands.getoutput("grep -c ^processor /proc/cpuinfo")

Subscribers

People subscribed via source and target branches