Merge lp:~qzhang/lava-dispatcher/another-inject-kernel into lp:lava-dispatcher

Proposed by Spring Zhang
Status: Merged
Merged at revision: 110
Proposed branch: lp:~qzhang/lava-dispatcher/another-inject-kernel
Merge into: lp:lava-dispatcher
Diff against target: 309 lines (+159/-14)
6 files modified
doc/android-new-kernel.json (+37/-0)
doc/lava-new-kernel.json (+30/-0)
lava_dispatcher/actions/android_deploy.py (+28/-7)
lava_dispatcher/actions/deploy.py (+58/-5)
lava_dispatcher/client.py (+1/-1)
lava_dispatcher/utils.py (+5/-1)
To merge this branch: bzr merge lp:~qzhang/lava-dispatcher/another-inject-kernel
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+72927@code.launchpad.net

Description of the change

Another injecting kernel, use l-h-r now.
1. use linaro-hwpack-replace to get a new hwpack with new kernel before deployment.
2. tested once and pass
3. only support new kernel in deb format in normal image and tarball format in Android image.
4. job file like:
  "actions": [
    {
      "command": "deploy_linaro_image",
      "parameters":
        {
          "rootfs":
"http://snapshots.linaro.org/11.05-daily/linaro-nano/20110612/0/images/tar/nano-n-tar-20110612-0.tar.gz",
          "hwpack":
"http://snapshots.linaro.org/11.05-daily/linaro-hwpacks/lt-mx53loco/20110609/0/images/hwpack/hwpack_linaro-lt-mx53loco_20110609-0_armel_supported.tar.gz",
          "kernel_matrix":[
"http://pkgserver/original/linux-image-2.6.38-1000-linaro-lt-mx5_2.6.38-1000.7_armel.deb", "linux-image-2.6.38"]
        }
    },

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

This looks basically OK to me, bet it conflicts with trunk now though.

101. By Spring Zhang

sync with mainline

102. By Spring Zhang

sync with mainline

103. By Spring Zhang

sync with mainline

104. By Spring Zhang

sync with mainline

105. By Spring Zhang

fix another OSError 18 link error

106. By Spring Zhang

fix minor bugs

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'doc/android-new-kernel.json'
2--- doc/android-new-kernel.json 1970-01-01 00:00:00 +0000
3+++ doc/android-new-kernel.json 2011-09-15 07:09:50 +0000
4@@ -0,0 +1,37 @@
5+{
6+ "job_name": "android_new_kernel",
7+ "image_type": "android",
8+ "target": "panda01",
9+ "timeout": 18000,
10+ "actions": [
11+ {
12+ "command": "deploy_linaro_android_image",
13+ "parameters":
14+ {
15+ "boot": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/boot.tar.bz2",
16+ "system": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/system.tar.bz2",
17+ "data": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/61/artifact/build/out/target/product/pandaboard/userdata.tar.bz2",
18+ "pkg": "https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/171/artifact/build/out/target/product/pandaboard/boot.tar.bz2"
19+ },
20+ "metadata":
21+ {
22+ "rootfs.type": "android",
23+ "rootfs.build": "61"
24+ }
25+ },
26+ {
27+ "command": "boot_linaro_android_image"
28+ },
29+ {
30+ "command": "test_android_basic"
31+ },
32+ {
33+ "command": "submit_results_on_host",
34+ "parameters":
35+ {
36+ "server": "http://validation.linaro.org/launch-control",
37+ "stream": "/anonymous/android-panda01-basic/"
38+ }
39+ }
40+ ]
41+}
42
43=== renamed file 'doc/lava-ltp-job' => 'doc/lava-ltp-job.json'
44=== added file 'doc/lava-new-kernel.json'
45--- doc/lava-new-kernel.json 1970-01-01 00:00:00 +0000
46+++ doc/lava-new-kernel.json 2011-09-15 07:09:50 +0000
47@@ -0,0 +1,30 @@
48+{
49+ "job_name": "new-kernel",
50+ "target": "mx53loco01",
51+ "timeout": 6000,
52+ "actions": [
53+ {
54+ "command": "deploy_linaro_image",
55+ "parameters":
56+ {
57+ "rootfs":
58+"http://snapshots.linaro.org/11.05-daily/linaro-nano/20110612/0/images/tar/nano-n-tar-20110612-0.tar.gz",
59+ "hwpack":
60+"http://snapshots.linaro.org/11.05-daily/linaro-hwpacks/lt-mx53loco/20110609/0/images/hwpack/hwpack_linaro-lt-mx53loco_20110609-0_armel_supported.tar.gz",
61+ "kernel_matrix":[
62+"http://pkgserver/original/linux-image-2.6.38-1000-linaro-lt-mx5_2.6.38-1000.7_armel.deb", "linux-image-2.6.38"]
63+ }
64+ },
65+ {
66+ "command": "boot_linaro_image"
67+ },
68+ {
69+ "command": "submit_results",
70+ "parameters":
71+ {
72+ "server": "http://validation.linaro.org/launch-control",
73+ "stream": "/anonymous/testresult/"
74+ }
75+ }
76+ ]
77+}
78
79=== modified file 'lava_dispatcher/actions/android_deploy.py'
80--- lava_dispatcher/actions/android_deploy.py 2011-09-05 22:39:47 +0000
81+++ lava_dispatcher/actions/android_deploy.py 2011-09-15 07:09:50 +0000
82@@ -29,7 +29,7 @@
83 from lava_dispatcher.client import CriticalError
84
85 class cmd_deploy_linaro_android_image(BaseAction):
86- def run(self, boot, system, data, use_cache=True):
87+ def run(self, boot, system, data, pkg=None, use_cache=True):
88 LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir
89 LAVA_IMAGE_URL = self.context.lava_image_url
90 client = self.client
91@@ -49,8 +49,8 @@
92 raise CriticalError("Unable to reach LAVA server, check network")
93
94 try:
95- boot_tbz2, system_tbz2, data_tbz2 = self.download_tarballs(boot,
96- system, data, use_cache)
97+ boot_tbz2, system_tbz2, data_tbz2, pkg_tbz2 = \
98+ self.download_tarballs(boot, system, data, pkg, use_cache)
99 except:
100 tb = traceback.format_exc()
101 client.sio.write(tb)
102@@ -66,9 +66,16 @@
103 LAVA_IMAGE_URL, system_tarball])
104 data_url = '/'.join(u.strip('/') for u in [
105 LAVA_IMAGE_URL, data_tarball])
106+ if pkg_tbz2:
107+ pkg_tarball = pkg_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
108+ pkg_url = '/'.join(u.strip('/') for u in [
109+ LAVA_IMAGE_URL, pkg_tarball])
110
111 try:
112- self.deploy_linaro_android_testboot(boot_url)
113+ if pkg_tbz2:
114+ self.deploy_linaro_android_testboot(boot_url, pkg_url)
115+ else:
116+ self.deploy_linaro_android_testboot(boot_url)
117 self.deploy_linaro_android_testrootfs(system_url)
118 self.purge_linaro_android_sdcard()
119 except:
120@@ -78,12 +85,14 @@
121 finally:
122 shutil.rmtree(self.tarball_dir)
123
124- def download_tarballs(self, boot_url, system_url, data_url, use_cache=True):
125+ def download_tarballs(self, boot_url, system_url, data_url, pkg_url=None,
126+ use_cache=True):
127 """Download tarballs from a boot, system and data tarball url
128
129 :param boot_url: url of the Linaro Android boot tarball to download
130 :param system_url: url of the Linaro Android system tarball to download
131 :param data_url: url of the Linaro Android data tarball to download
132+ :param pkg_url: url of the custom kernel tarball to download
133 :param use_cache: whether or not to use the cached copy (if it exists)
134 """
135 lava_cachedir = self.context.lava_cachedir
136@@ -96,13 +105,21 @@
137 boot_path = download_with_cache(boot_url, tarball_dir, lava_cachedir)
138 system_path = download_with_cache(system_url, tarball_dir, lava_cachedir)
139 data_path = download_with_cache(data_url, tarball_dir, lava_cachedir)
140+ if pkg_url:
141+ pkg_path = download_with_cache(pkg_url, tarball_dir)
142+ else:
143+ pkg_path = None
144 else:
145 boot_path = download(boot_url, tarball_dir)
146 system_path = download(system_url, tarball_dir)
147 data_path = download(data_url, tarball_dir)
148- return boot_path, system_path, data_path
149+ if pkg_url:
150+ pkg_path = download(pkg_url, tarball_dir)
151+ else:
152+ pkg_path = None
153+ return boot_path, system_path, data_path, pkg_path
154
155- def deploy_linaro_android_testboot(self, boottbz2):
156+ def deploy_linaro_android_testboot(self, boottbz2, pkgbz2=None):
157 client = self.client
158 client.run_cmd_master('mkfs.vfat /dev/disk/by-label/testboot '
159 '-n testboot')
160@@ -111,6 +128,10 @@
161 client.run_cmd_master('mount /dev/disk/by-label/testboot '
162 '/mnt/lava/boot')
163 client.run_cmd_master('wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % boottbz2)
164+ if pkgbz2:
165+ client.run_shell_command(
166+ 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -'
167+ % pkgbz2, response = MASTER_STR)
168
169 self.recreate_uInitrd()
170
171
172=== modified file 'lava_dispatcher/actions/deploy.py'
173--- lava_dispatcher/actions/deploy.py 2011-09-08 23:35:05 +0000
174+++ lava_dispatcher/actions/deploy.py 2011-09-15 07:09:50 +0000
175@@ -15,11 +15,11 @@
176 # GNU General Public License for more details.
177 #
178 # You should have received a copy of the GNU General Public License
179-# along
180-# with this program; if not, see <http://www.gnu.org/licenses>.
181+# along with this program; if not, see <http://www.gnu.org/licenses>.
182
183 from commands import getoutput, getstatusoutput
184 import os
185+import sys
186 import re
187 import shutil
188 import traceback
189@@ -31,13 +31,15 @@
190
191
192 class cmd_deploy_linaro_image(BaseAction):
193- def run(self, hwpack, rootfs, use_cache=True):
194+ def run(self, hwpack, rootfs, kernel_matrix=None, use_cache=True):
195 LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir
196 LAVA_IMAGE_URL = self.context.lava_image_url
197 client = self.client
198 print "deploying on %s" % client.hostname
199 print " hwpack: %s" % hwpack
200 print " rootfs: %s" % rootfs
201+ if kernel_matrix:
202+ print " package: %s" % kernel_matrix[0]
203 print "Booting master image"
204 client.boot_master_image()
205
206@@ -49,9 +51,17 @@
207 client.sio.write(tb)
208 raise CriticalError("Unable to reach LAVA server, check network")
209
210+ if kernel_matrix:
211+ hwpack = self.refresh_hwpack(kernel_matrix, hwpack, use_cache)
212+ #make new hwpack downloadable
213+ hwpack = hwpack.replace(LAVA_IMAGE_TMPDIR, '')
214+ hwpack = '/'.join(u.strip('/') for u in [
215+ LAVA_IMAGE_URL, hwpack])
216+ print "Hwpack with new kernel: %s" % hwpack
217+
218 try:
219- boot_tgz, root_tgz = self.generate_tarballs(
220- hwpack, rootfs, use_cache)
221+ boot_tgz, root_tgz = self.generate_tarballs(hwpack, rootfs,
222+ use_cache)
223 except:
224 tb = traceback.format_exc()
225 client.sio.write(tb)
226@@ -119,6 +129,7 @@
227 self.tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)
228 tarball_dir = self.tarball_dir
229 os.chmod(tarball_dir, 0755)
230+ #fix me: if url is not http-prefix, copy it to tarball_dir
231 if use_cache:
232 hwpack_path = download_with_cache(hwpack_url, tarball_dir, lava_cachedir)
233 rootfs_path = download_with_cache(rootfs_url, tarball_dir, lava_cachedir)
234@@ -184,3 +195,45 @@
235 'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs)
236 client.run_cmd_master('umount /mnt/boot')
237
238+ def refresh_hwpack(self, kernel_matrix, hwpack, use_cache=True):
239+ client = self.client
240+ LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir
241+ print "Deploying new kernel"
242+ new_kernel = kernel_matrix[0]
243+ deb_prefix = kernel_matrix[1]
244+ filesuffix = new_kernel.split(".")[-1]
245+
246+ if filesuffix != "deb":
247+ raise CriticalError("New kernel only support deb kernel package!")
248+
249+ # download package to local
250+ tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)
251+ os.chmod(tarball_dir, 0755)
252+ if use_cache:
253+ kernel_path = download_with_cache(new_kernel, tarball_dir)
254+ hwpack_path = download_with_cache(hwpack, tarball_dir)
255+ else:
256+ kernel_path = download(new_kernel, tarball_dir)
257+ hwpack_path = download(hwpack, tarball_dir)
258+
259+ cmd = ("sudo linaro-hwpack-replace -t %s -p %s -r %s"
260+ % (hwpack_path, kernel_path, deb_prefix))
261+
262+ rc, output = getstatusoutput(cmd)
263+ if rc:
264+ shutil.rmtree(tarball_dir)
265+ tb = traceback.format_exc()
266+ client.sio.write(tb)
267+ raise RuntimeError("linaro-hwpack-replace failed: %s" % output)
268+
269+ #fix it:l-h-r doesn't make a output option to specify the output hwpack,
270+ #so it needs to do manually here
271+
272+ #remove old hwpack and leave only new hwpack in tarball_dir
273+ os.remove(hwpack_path)
274+ hwpack_list = os.listdir(tarball_dir)
275+ for hp in hwpack_list:
276+ if hp.split(".")[-1] == "gz":
277+ new_hwpack_path = os.path.join(tarball_dir, hp)
278+ return new_hwpack_path
279+
280
281=== modified file 'lava_dispatcher/client.py'
282--- lava_dispatcher/client.py 2011-09-14 16:05:43 +0000
283+++ lava_dispatcher/client.py 2011-09-15 07:09:50 +0000
284@@ -130,7 +130,7 @@
285 # Details: system PS1 is set in /etc/bash.bashrc and user PS1 is set in
286 # /root/.bashrc, it is
287 # "${debian_chroot:+($debian_chroot)}\u@\h:\w\$ "
288- self.proc.sendline('export PS1="$PS1 rc=$(echo \$?) "')
289+ self.proc.sendline('export PS1="$PS1 [rc=$(echo \$?)]: "')
290 self.proc.expect(self.tester_str)
291
292 def enter_uboot(self):
293
294=== modified file 'lava_dispatcher/utils.py'
295--- lava_dispatcher/utils.py 2011-09-01 03:03:09 +0000
296+++ lava_dispatcher/utils.py 2011-09-15 07:09:50 +0000
297@@ -45,7 +45,11 @@
298 if os.path.exists(cache_loc):
299 filename = os.path.basename(cache_loc)
300 file_location = os.path.join(path, filename)
301- os.link(cache_loc, file_location)
302+ try:
303+ os.link(cache_loc, file_location)
304+ except OSError, err:
305+ if err.errno == 18:
306+ shutil.copy(cache_loc, file_location)
307 else:
308 file_location = download(url, path)
309 try:

Subscribers

People subscribed via source and target branches