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
1=== modified file 'lava/actions/deploy.py'
2--- lava/actions/deploy.py 2011-03-22 19:48:41 +0000
3+++ lava/actions/deploy.py 2011-03-24 17:54:55 +0000
4@@ -11,14 +11,15 @@
5
6 class cmd_deploy_linaro_image(BaseAction):
7 def run(self, hwpack, rootfs):
8- print "deploying on %s" % self.client.hostname
9+ client = self.client
10+ print "deploying on %s" % client.hostname
11 print " hwpack: %s" % hwpack
12 print " rootfs: %s" % rootfs
13 print "Booting master image"
14- self.client.boot_master_image()
15+ client.boot_master_image()
16
17 print "Waiting for network to come up"
18- self.client.wait_network_up()
19+ client.wait_network_up()
20 boot_tgz, root_tgz = self.generate_tarballs(hwpack, rootfs)
21 boot_tarball = boot_tgz.replace(LAVA_IMAGE_TMPDIR, '')
22 root_tarball = root_tgz.replace(LAVA_IMAGE_TMPDIR, '')
23@@ -34,13 +35,14 @@
24 raise
25
26 def _get_partition_offset(self, image, partno):
27- cmd = 'parted %s -s unit b p' % image
28+ cmd = 'parted %s -m -s unit b print' % image
29 part_data = getoutput(cmd)
30- pattern = re.compile(' %d\s+([0-9]+)' % partno)
31+ pattern = re.compile('%d:([0-9]+)B:' % partno)
32 for line in part_data.splitlines():
33 found = re.match(pattern, line)
34 if found:
35 return found.group(1)
36+ return None
37
38 def _extract_partition(self, image, offset, tarfile):
39 """Mount a partition and produce a tarball of it
40@@ -90,73 +92,71 @@
41 :param rootfs_url: url of the Linaro image to download
42 """
43 self.tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)
44- os.chmod(self.tarball_dir, 0755)
45- hwpack_path = self._download(hwpack_url, self.tarball_dir)
46- rootfs_path = self._download(rootfs_url, self.tarball_dir)
47- image_file = os.path.join(self.tarball_dir, "lava.img")
48+ tarball_dir = self.tarball_dir
49+ os.chmod(tarball_dir, 0755)
50+ hwpack_path = self._download(hwpack_url, tarball_dir)
51+ rootfs_path = self._download(rootfs_url, tarball_dir)
52+ image_file = os.path.join(tarball_dir, "lava.img")
53+ board = self.client.board
54 cmd = ("linaro-media-create --hwpack-force-yes --dev %s "
55 "--image_file %s --binary %s --hwpack %s" % (
56- self.client.board.type, image_file, rootfs_path,
57- hwpack_path))
58+ board.type, image_file, rootfs_path, hwpack_path))
59 rc, output = getstatusoutput(cmd)
60 if rc:
61- shutil.rmtree(self.tarball_dir)
62+ shutil.rmtree(tarball_dir)
63 raise RuntimeError("linaro-media-create failed: %s" % output)
64- #mx51evk has a different partition layout
65- if self.client.board.type == "mx51evk":
66- boot_offset = self._get_partition_offset(image_file, 2)
67- root_offset = self._get_partition_offset(image_file, 3)
68- else:
69- boot_offset = self._get_partition_offset(image_file, 1)
70- root_offset = self._get_partition_offset(image_file, 2)
71- boot_tgz = os.path.join(self.tarball_dir, "boot.tgz")
72- root_tgz = os.path.join(self.tarball_dir, "root.tgz")
73+ boot_offset = self._get_partition_offset(image_file, board.boot_part)
74+ root_offset = self._get_partition_offset(image_file, board.root_part)
75+ boot_tgz = os.path.join(tarball_dir, "boot.tgz")
76+ root_tgz = os.path.join(tarball_dir, "root.tgz")
77 try:
78 self._extract_partition(image_file, boot_offset, boot_tgz)
79 self._extract_partition(image_file, root_offset, root_tgz)
80 except:
81- shutil.rmtree(self.tarball_dir)
82+ shutil.rmtree(tarball_dir)
83 raise
84 return boot_tgz, root_tgz
85
86 def deploy_linaro_rootfs(self, rootfs):
87+ client = self.client
88 print "Deploying linaro image"
89- self.client.run_shell_command(
90+ client.run_shell_command(
91 'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs',
92 response = MASTER_STR)
93- self.client.run_shell_command(
94+ client.run_shell_command(
95 'udevadm trigger',
96 response = MASTER_STR)
97- self.client.run_shell_command(
98+ client.run_shell_command(
99 'mkdir -p /mnt/root',
100 response = MASTER_STR)
101- self.client.run_shell_command(
102+ client.run_shell_command(
103 'mount /dev/disk/by-label/testrootfs /mnt/root',
104 response = MASTER_STR)
105- self.client.run_shell_command(
106+ client.run_shell_command(
107 'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs,
108 response = MASTER_STR, timeout = 600)
109- self.client.run_shell_command(
110+ client.run_shell_command(
111 'umount /mnt/root',
112 response = MASTER_STR)
113
114 def deploy_linaro_bootfs(self, bootfs):
115- self.client.run_shell_command(
116+ client = self.client
117+ client.run_shell_command(
118 'mkfs.vfat /dev/disk/by-label/testboot -n testboot',
119 response = MASTER_STR)
120- self.client.run_shell_command(
121+ client.run_shell_command(
122 'udevadm trigger',
123 response = MASTER_STR)
124- self.client.run_shell_command(
125+ client.run_shell_command(
126 'mkdir -p /mnt/boot',
127 response = MASTER_STR)
128- self.client.run_shell_command(
129+ client.run_shell_command(
130 'mount /dev/disk/by-label/testboot /mnt/boot',
131 response = MASTER_STR)
132- self.client.run_shell_command(
133+ client.run_shell_command(
134 'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs,
135 response = MASTER_STR)
136- self.client.run_shell_command(
137+ client.run_shell_command(
138 'umount /mnt/boot',
139 response = MASTER_STR)
140
141
142=== modified file 'lava/config.py'
143--- lava/config.py 2011-03-22 19:48:41 +0000
144+++ lava/config.py 2011-03-24 17:54:55 +0000
145@@ -6,7 +6,12 @@
146 """
147
148 class Board:
149- pass
150+ uboot_cmds = None
151+ type = None
152+ # boot partition number, counting from 1
153+ boot_part = 1
154+ # root partition number, counting from 1
155+ root_part = 2
156
157 class BeagleBoard(Board):
158 uboot_cmds = ["mmc init",
159@@ -29,6 +34,8 @@
160 type = "panda"
161
162 class Mx51evkBoard(Board):
163+ boot_part = 2
164+ root_part = 3
165 uboot_cmds = ["mmc init",
166 "setenv bootcmd 'fatload mmc 0:5 0x90800000 uImage; fatload mmc "
167 "0:5 0x90800000 uInitrd; bootm 0x90000000 0x90800000'",

Subscribers

People subscribed via source and target branches