Merge lp:~lool/lava-dispatcher/part-offset into lp:lava-dispatcher

Proposed by Loïc Minier
Status: Merged
Merged at revision: 21
Proposed branch: lp:~lool/lava-dispatcher/part-offset
Merge into: lp:lava-dispatcher
Diff against target: 167 lines (+42/-35)
2 files modified
lava/actions/deploy.py (+34/-34)
lava/config.py (+8/-1)
To merge this branch: bzr merge lp:~lool/lava-dispatcher/part-offset
Reviewer Review Type Date Requested Status
Paul Larson (community) Approve
Review via email: mp+54748@code.launchpad.net

Description of the change

Main goal was to fix a test for mx51evk in the middle of cmd_deploy_linaro_image but I came across some parted bug on natty and fixed some other small things along the way in separate commits.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

Approve, but oddly enough, abbreviating p for print works just fine for me on natty that has been updated in the last few days.

review: Approve
Revision history for this message
Loïc Minier (lool) wrote :

That's odd indeed; I have parted 2.3-5ubuntu3 here; seems to be around since several weeks and built on all architectures

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lava/actions/deploy.py'
--- lava/actions/deploy.py 2011-03-22 19:48:41 +0000
+++ lava/actions/deploy.py 2011-03-24 17:54:55 +0000
@@ -11,14 +11,15 @@
1111
12class cmd_deploy_linaro_image(BaseAction):12class cmd_deploy_linaro_image(BaseAction):
13 def run(self, hwpack, rootfs):13 def run(self, hwpack, rootfs):
14 print "deploying on %s" % self.client.hostname14 client = self.client
15 print "deploying on %s" % client.hostname
15 print " hwpack: %s" % hwpack16 print " hwpack: %s" % hwpack
16 print " rootfs: %s" % rootfs17 print " rootfs: %s" % rootfs
17 print "Booting master image"18 print "Booting master image"
18 self.client.boot_master_image()19 client.boot_master_image()
1920
20 print "Waiting for network to come up"21 print "Waiting for network to come up"
21 self.client.wait_network_up()22 client.wait_network_up()
22 boot_tgz, root_tgz = self.generate_tarballs(hwpack, rootfs)23 boot_tgz, root_tgz = self.generate_tarballs(hwpack, rootfs)
23 boot_tarball = boot_tgz.replace(LAVA_IMAGE_TMPDIR, '')24 boot_tarball = boot_tgz.replace(LAVA_IMAGE_TMPDIR, '')
24 root_tarball = root_tgz.replace(LAVA_IMAGE_TMPDIR, '')25 root_tarball = root_tgz.replace(LAVA_IMAGE_TMPDIR, '')
@@ -34,13 +35,14 @@
34 raise35 raise
3536
36 def _get_partition_offset(self, image, partno):37 def _get_partition_offset(self, image, partno):
37 cmd = 'parted %s -s unit b p' % image38 cmd = 'parted %s -m -s unit b print' % image
38 part_data = getoutput(cmd)39 part_data = getoutput(cmd)
39 pattern = re.compile(' %d\s+([0-9]+)' % partno)40 pattern = re.compile('%d:([0-9]+)B:' % partno)
40 for line in part_data.splitlines():41 for line in part_data.splitlines():
41 found = re.match(pattern, line)42 found = re.match(pattern, line)
42 if found:43 if found:
43 return found.group(1)44 return found.group(1)
45 return None
4446
45 def _extract_partition(self, image, offset, tarfile):47 def _extract_partition(self, image, offset, tarfile):
46 """Mount a partition and produce a tarball of it48 """Mount a partition and produce a tarball of it
@@ -90,73 +92,71 @@
90 :param rootfs_url: url of the Linaro image to download92 :param rootfs_url: url of the Linaro image to download
91 """93 """
92 self.tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)94 self.tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)
93 os.chmod(self.tarball_dir, 0755)95 tarball_dir = self.tarball_dir
94 hwpack_path = self._download(hwpack_url, self.tarball_dir)96 os.chmod(tarball_dir, 0755)
95 rootfs_path = self._download(rootfs_url, self.tarball_dir)97 hwpack_path = self._download(hwpack_url, tarball_dir)
96 image_file = os.path.join(self.tarball_dir, "lava.img")98 rootfs_path = self._download(rootfs_url, tarball_dir)
99 image_file = os.path.join(tarball_dir, "lava.img")
100 board = self.client.board
97 cmd = ("linaro-media-create --hwpack-force-yes --dev %s "101 cmd = ("linaro-media-create --hwpack-force-yes --dev %s "
98 "--image_file %s --binary %s --hwpack %s" % (102 "--image_file %s --binary %s --hwpack %s" % (
99 self.client.board.type, image_file, rootfs_path,103 board.type, image_file, rootfs_path, hwpack_path))
100 hwpack_path))
101 rc, output = getstatusoutput(cmd)104 rc, output = getstatusoutput(cmd)
102 if rc:105 if rc:
103 shutil.rmtree(self.tarball_dir)106 shutil.rmtree(tarball_dir)
104 raise RuntimeError("linaro-media-create failed: %s" % output)107 raise RuntimeError("linaro-media-create failed: %s" % output)
105 #mx51evk has a different partition layout108 boot_offset = self._get_partition_offset(image_file, board.boot_part)
106 if self.client.board.type == "mx51evk":109 root_offset = self._get_partition_offset(image_file, board.root_part)
107 boot_offset = self._get_partition_offset(image_file, 2)110 boot_tgz = os.path.join(tarball_dir, "boot.tgz")
108 root_offset = self._get_partition_offset(image_file, 3)111 root_tgz = os.path.join(tarball_dir, "root.tgz")
109 else:
110 boot_offset = self._get_partition_offset(image_file, 1)
111 root_offset = self._get_partition_offset(image_file, 2)
112 boot_tgz = os.path.join(self.tarball_dir, "boot.tgz")
113 root_tgz = os.path.join(self.tarball_dir, "root.tgz")
114 try:112 try:
115 self._extract_partition(image_file, boot_offset, boot_tgz)113 self._extract_partition(image_file, boot_offset, boot_tgz)
116 self._extract_partition(image_file, root_offset, root_tgz)114 self._extract_partition(image_file, root_offset, root_tgz)
117 except:115 except:
118 shutil.rmtree(self.tarball_dir)116 shutil.rmtree(tarball_dir)
119 raise117 raise
120 return boot_tgz, root_tgz118 return boot_tgz, root_tgz
121119
122 def deploy_linaro_rootfs(self, rootfs):120 def deploy_linaro_rootfs(self, rootfs):
121 client = self.client
123 print "Deploying linaro image"122 print "Deploying linaro image"
124 self.client.run_shell_command(123 client.run_shell_command(
125 'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs',124 'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs',
126 response = MASTER_STR)125 response = MASTER_STR)
127 self.client.run_shell_command(126 client.run_shell_command(
128 'udevadm trigger',127 'udevadm trigger',
129 response = MASTER_STR)128 response = MASTER_STR)
130 self.client.run_shell_command(129 client.run_shell_command(
131 'mkdir -p /mnt/root',130 'mkdir -p /mnt/root',
132 response = MASTER_STR)131 response = MASTER_STR)
133 self.client.run_shell_command(132 client.run_shell_command(
134 'mount /dev/disk/by-label/testrootfs /mnt/root',133 'mount /dev/disk/by-label/testrootfs /mnt/root',
135 response = MASTER_STR)134 response = MASTER_STR)
136 self.client.run_shell_command(135 client.run_shell_command(
137 'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs,136 'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs,
138 response = MASTER_STR, timeout = 600)137 response = MASTER_STR, timeout = 600)
139 self.client.run_shell_command(138 client.run_shell_command(
140 'umount /mnt/root',139 'umount /mnt/root',
141 response = MASTER_STR)140 response = MASTER_STR)
142141
143 def deploy_linaro_bootfs(self, bootfs):142 def deploy_linaro_bootfs(self, bootfs):
144 self.client.run_shell_command(143 client = self.client
144 client.run_shell_command(
145 'mkfs.vfat /dev/disk/by-label/testboot -n testboot',145 'mkfs.vfat /dev/disk/by-label/testboot -n testboot',
146 response = MASTER_STR)146 response = MASTER_STR)
147 self.client.run_shell_command(147 client.run_shell_command(
148 'udevadm trigger',148 'udevadm trigger',
149 response = MASTER_STR)149 response = MASTER_STR)
150 self.client.run_shell_command(150 client.run_shell_command(
151 'mkdir -p /mnt/boot',151 'mkdir -p /mnt/boot',
152 response = MASTER_STR)152 response = MASTER_STR)
153 self.client.run_shell_command(153 client.run_shell_command(
154 'mount /dev/disk/by-label/testboot /mnt/boot',154 'mount /dev/disk/by-label/testboot /mnt/boot',
155 response = MASTER_STR)155 response = MASTER_STR)
156 self.client.run_shell_command(156 client.run_shell_command(
157 'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs,157 'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs,
158 response = MASTER_STR)158 response = MASTER_STR)
159 self.client.run_shell_command(159 client.run_shell_command(
160 'umount /mnt/boot',160 'umount /mnt/boot',
161 response = MASTER_STR)161 response = MASTER_STR)
162162
163163
=== modified file 'lava/config.py'
--- lava/config.py 2011-03-22 19:48:41 +0000
+++ lava/config.py 2011-03-24 17:54:55 +0000
@@ -6,7 +6,12 @@
6"""6"""
77
8class Board:8class Board:
9 pass9 uboot_cmds = None
10 type = None
11 # boot partition number, counting from 1
12 boot_part = 1
13 # root partition number, counting from 1
14 root_part = 2
1015
11class BeagleBoard(Board):16class BeagleBoard(Board):
12 uboot_cmds = ["mmc init",17 uboot_cmds = ["mmc init",
@@ -29,6 +34,8 @@
29 type = "panda"34 type = "panda"
3035
31class Mx51evkBoard(Board):36class Mx51evkBoard(Board):
37 boot_part = 2
38 root_part = 3
32 uboot_cmds = ["mmc init",39 uboot_cmds = ["mmc init",
33 "setenv bootcmd 'fatload mmc 0:5 0x90800000 uImage; fatload mmc "40 "setenv bootcmd 'fatload mmc 0:5 0x90800000 uImage; fatload mmc "
34 "0:5 0x90800000 uInitrd; bootm 0x90000000 0x90800000'",41 "0:5 0x90800000 uInitrd; bootm 0x90000000 0x90800000'",

Subscribers

People subscribed via source and target branches