Merge lp:~rsalveti/linaro-image-tools/generic-oe-support into lp:linaro-image-tools/11.11
- generic-oe-support
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | James Tunnicliffe |
Approved revision: | 549 |
Merged at revision: | 545 |
Proposed branch: | lp:~rsalveti/linaro-image-tools/generic-oe-support |
Merge into: | lp:linaro-image-tools/11.11 |
Diff against target: |
1068 lines (+367/-240) 7 files modified
linaro-hwpack-install (+193/-147) linaro-media-create (+38/-11) linaro_image_tools/media_create/android_boards.py (+4/-1) linaro_image_tools/media_create/boards.py (+45/-41) linaro_image_tools/media_create/chroot_utils.py (+17/-9) linaro_image_tools/media_create/rootfs.py (+3/-3) linaro_image_tools/media_create/tests/test_media_create.py (+67/-28) |
To merge this branch: | bzr merge lp:~rsalveti/linaro-image-tools/generic-oe-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Tunnicliffe (community) | Approve | ||
Review via email: mp+118857@code.launchpad.net |
Commit message
Description of the change
Adding support for generic linux based images, like OpenEmbedded.
The goal is to avoid using dpkg/apt when the rootfs used is not based on debian/ubuntu, and for that, the only generic way to support a hwpack is to use just the bootloader and the kernel packages, as they are not dependent on the rootfs.
These patches add one extra option to the hwpack-install script, to allow the user to request the script to just extract the kernel packages, and make sure the modules are properly in place. As hwpack-install is used by linaro-
As we can't depend on the rootfs type, we can force the rootfs to use UUID to identify the rootfs (as this is part of the initrd code). In case the user wants to just extract the kernel, the boot commands should reflect the usage of just the uImage file, together with the bootloader.
Tested with the OE lamp based image, and with lt-panda (to see if nothing else is broken).
Ricardo Salveti (rsalveti) wrote : | # |
On Thu, Aug 9, 2012 at 7:42 AM, James Tunnicliffe
<email address hidden> wrote:
> Review: Approve
>
> Looks fine. Gosh I wish we had moved block detection and change classification in the diff viewer (wouldn't it be nice if all the places where a variable were renamed could be just ticked off then ignored). Anyway, one small change, but I will make it and them merge:
>
> 409 + # if not a debian compatible system, just extract the kernel packages
> 410 + extract_kpkgs = False
> 411 + if not path_in_
> 412 + filesystem_dir + '/etc/debian_
> 413 + extract_kpkgs = True
>
> We should use os.path.
Yeah, guess I forgot while testing the initial code.
Thanks for the review and for the fix.
Preview Diff
1 | === modified file 'linaro-hwpack-install' |
2 | --- linaro-hwpack-install 2012-07-23 15:28:30 +0000 |
3 | +++ linaro-hwpack-install 2012-08-09 01:33:20 +0000 |
4 | @@ -1,4 +1,4 @@ |
5 | -#!/bin/bash |
6 | +#!/bin/sh |
7 | # linaro-hwpack-install - Install a Linaro Hardware Pack. |
8 | # This script is meant to run inside a chroot containing nothing other than |
9 | # ubuntu-minimal, so it must not depend on anything that's not in |
10 | @@ -62,6 +62,7 @@ |
11 | HWPACK_VERSION="" |
12 | HWPACK_ARCH="" |
13 | HWPACK_NAME="" |
14 | +EXTRACT_KERNEL_ONLY="no" |
15 | |
16 | while [ $# -gt 0 ]; do |
17 | case "$1" in |
18 | @@ -83,6 +84,9 @@ |
19 | HWPACK_NAME=$2 |
20 | shift; |
21 | shift;; |
22 | + --extract-kernel-only) |
23 | + EXTRACT_KERNEL_ONLY="yes" |
24 | + shift;; |
25 | --*) |
26 | die $usage_msg "\nUnrecognized option: \"$1\"";; |
27 | *) |
28 | @@ -98,165 +102,207 @@ |
29 | [ "$HWPACK_ARCH" = "" ] && die $usage_msg |
30 | [ "$HWPACK_NAME" = "" ] && die $usage_msg |
31 | |
32 | -# Try to acquire fd #9 (i.e. /var/lock/hwpack) for 2 seconds. |
33 | -# Using 9 as the file descriptor because of https://launchpad.net/bugs/249620 |
34 | -exec 9>$LOCKFILE |
35 | -flock -w2 9 || die "Could not acquire lock: $LOCKFILE" |
36 | +setup_hwpack() { |
37 | + # This creates all the directories we need. |
38 | + mkdir -p "$HWPACK_DIR" |
39 | + |
40 | + # Unpack the hwpack tarball. We don't download it here because the chroot may |
41 | + # not contain any tools that would allow us to do that. |
42 | + echo -n "Unpacking hardware pack ..." |
43 | + tar zxf "$HWPACK_TARBALL" -C "$HWPACK_DIR" |
44 | + echo "Done" |
45 | + |
46 | + # Check the format of the hwpack is supported. |
47 | + hwpack_format=$(cat ${HWPACK_DIR}/FORMAT) |
48 | + supported="false" |
49 | + for format in $SUPPORTED_FORMATS; do |
50 | + if [ "x$hwpack_format" = "x$format" ]; then |
51 | + supported="true" |
52 | + break |
53 | + fi |
54 | + done |
55 | + |
56 | + [ $supported = "true" ] || \ |
57 | + die "Unsupported hwpack format: $hwpack_format. "\ |
58 | + "Try using a newer version of $(basename $0)." |
59 | + |
60 | + # Check the architecture of the hwpack matches that of the host system. |
61 | + if [ "x$EXTRACT_KERNEL_ONLY" = "xno" ]; then |
62 | + # TODO: create a generic way to identify the architecture, without depending on dpkg |
63 | + [ "$HWPACK_ARCH" = `dpkg --print-architecture` ] || \ |
64 | + die "Hardware pack architecture ($HWPACK_ARCH) does not match the host's architecture" |
65 | + fi |
66 | +} |
67 | + |
68 | +setup_apt_sources() { |
69 | + # Install the apt sources that contain the packages we need. |
70 | + for filename in $(ls "${HWPACK_DIR}"/sources.list.d/); do |
71 | + file="${HWPACK_DIR}"/sources.list.d/$filename |
72 | + should_install=0 |
73 | + stripped_file=${TEMP_DIR}/$filename |
74 | + grep -v "\(^#\|^\s*$\)" $file > $stripped_file |
75 | + while read line; do |
76 | + # Only install files that have at least one line not present in the |
77 | + # existing sources lists. |
78 | + grep -qF "$line" $(find /etc/apt/sources.list.d/ -name '*.list') /etc/apt/sources.list \ |
79 | + || should_install=1 |
80 | + done < $stripped_file |
81 | + |
82 | + if [ $should_install -eq 1 ]; then |
83 | + $sudo cp $file /etc/apt/sources.list.d/hwpack.$filename |
84 | + fi |
85 | + done |
86 | + |
87 | + # Import the OpenPGP keys for the files installed above. |
88 | + for filename in $(ls "${HWPACK_DIR}"/sources.list.d.gpg/); do |
89 | + file="${HWPACK_DIR}"/sources.list.d.gpg/$filename |
90 | + $sudo apt-key add $file |
91 | + done |
92 | + |
93 | + # Add one extra apt source for the packages included in the hwpack and make |
94 | + # sure it's the first on the list of sources so that it gets precedence over |
95 | + # the others. |
96 | + echo "deb file:${HWPACK_DIR}/pkgs ./" > "$SOURCES_LIST_FILE" |
97 | + cat /etc/apt/sources.list >> "$SOURCES_LIST_FILE" |
98 | + |
99 | + if [ "$FORCE_YES" = "yes" ]; then |
100 | + FORCE_OPTIONS="--yes --force-yes" |
101 | + else |
102 | + FORCE_OPTIONS="" |
103 | + fi |
104 | + |
105 | + echo "Updating apt package lists ..." |
106 | + $sudo apt-get $FORCE_OPTIONS -o "$APT_GET_OPTIONS" update -q |
107 | +} |
108 | + |
109 | +setup_ubuntu_rootfs() { |
110 | + # Prevent daemons to start in the chroot |
111 | + echo "exit 101" > /usr/sbin/policy-rc.d |
112 | + chmod a+x /usr/sbin/policy-rc.d |
113 | + |
114 | + mv -f /sbin/start-stop-daemon /sbin/start-stop-daemon.REAL |
115 | + cat > /sbin/start-stop-daemon << EOF |
116 | +#!/bin/sh |
117 | + |
118 | +echo "Warning: Fake start-stop-daemon called, doing nothing" |
119 | +EOF |
120 | +chmod 755 /sbin/start-stop-daemon |
121 | + |
122 | +if [ -x /sbin/initctl ]; then |
123 | + mv -f /sbin/initctl /sbin/initctl.REAL |
124 | + cat > /sbin/initctl << EOF |
125 | +#!/bin/sh |
126 | + |
127 | +echo "Warning: Fake initctl called, doing nothing" |
128 | +EOF |
129 | + chmod 755 /sbin/initctl |
130 | + fi |
131 | +} |
132 | + |
133 | +install_deb_packages() { |
134 | + echo -n "Installing packages ..." |
135 | + |
136 | + # "newer" hwpacks contain a dependency package whose Depends is the |
137 | + # same as the packages config setting from the file the hwpack was |
138 | + # build from. But if we just installed that, a newer version of a |
139 | + # package than that in the hwpack might have made it to the main |
140 | + # archive and apt-get would install that instead. So we install the |
141 | + # specific package versions that make up the hwpack. /That/ however |
142 | + # would leave all the packages from the hwpack marked as manually |
143 | + # installed, so if a newer hwpack was installed over the top which no |
144 | + # longer depended on one of the packages the older one did, the |
145 | + # package would not be eligible for autoremoval. So we mark the all |
146 | + # packages newly installed as part of hwpack installed (apart from the |
147 | + # dependency package) as automatically installed with apt-get |
148 | + # markauto. |
149 | + # |
150 | + # For "older" hwpacks that don't have a dependency package, we just |
151 | + # manually install the contents of the hwpack. |
152 | + |
153 | + dependency_package="hwpack-${HWPACK_NAME}" |
154 | + if grep -q "^${dependency_package}=${HWPACK_VERSION}\$" "${HWPACK_DIR}"/manifest; then |
155 | + DEP_PACKAGE_PRESENT="yes" |
156 | + else |
157 | + DEP_PACKAGE_PRESENT="no" |
158 | + fi |
159 | + |
160 | + packages_without_versions=`sed 's/=.*//' "${HWPACK_DIR}"/manifest` |
161 | + packages_with_versions=`cat "${HWPACK_DIR}"/manifest` |
162 | + |
163 | + if [ "$INSTALL_LATEST" = "yes" ]; then |
164 | + packages="${packages_without_versions}" |
165 | + else |
166 | + packages="${packages_with_versions}" |
167 | + fi |
168 | + |
169 | + if [ "$DEP_PACKAGE_PRESENT" = "yes" ]; then |
170 | + to_be_installed= |
171 | + for package in $packages_without_versions; do |
172 | + if [ "${package}" != "${dependency_package}" ]; then |
173 | + { dpkg --get-selections $package 2>/dev/null| grep -qw 'install$'; } || to_be_installed="$to_be_installed $package" |
174 | + fi |
175 | + done |
176 | + fi |
177 | + |
178 | + $sudo apt-get $FORCE_OPTIONS -o "$APT_GET_OPTIONS" install ${packages} |
179 | + |
180 | + if [ "$DEP_PACKAGE_PRESENT" = "yes" ]; then |
181 | + if [ -n "${to_be_installed}" ]; then |
182 | + $sudo apt-get $FORCE_OPTIONS -o "$APT_GET_OPTIONS" markauto ${to_be_installed} |
183 | + fi |
184 | + fi |
185 | +} |
186 | + |
187 | +extract_kernel_packages() { |
188 | + echo "Extracting all kernel packages ..." |
189 | + |
190 | + ls ${HWPACK_DIR}/pkgs/linux-[ih]*.deb | while read pkg; do |
191 | + echo "Extracting package `basename $pkg`" |
192 | + dpkg-deb -x ${pkg} / |
193 | + done |
194 | + |
195 | + # manually generate modules.dep |
196 | + ls /lib/modules | while read kernel; do |
197 | + depmod ${kernel} |
198 | + done; |
199 | +} |
200 | |
201 | cleanup() { |
202 | # Ensure our temp dir and apt sources are removed. |
203 | echo -n "Cleaning up ..." |
204 | rm -rf $TEMP_DIR |
205 | - rm -f /usr/sbin/policy-rc.d |
206 | - mv -f /sbin/start-stop-daemon.REAL /sbin/start-stop-daemon |
207 | - if [ -x /sbin/initctl.REAL ]; then |
208 | - mv -f /sbin/initctl.REAL /sbin/initctl |
209 | + if [ "x$EXTRACT_KERNEL_ONLY" = "xno" ]; then |
210 | + rm -f /usr/sbin/policy-rc.d |
211 | + mv -f /sbin/start-stop-daemon.REAL /sbin/start-stop-daemon |
212 | + if [ -x /sbin/initctl.REAL ]; then |
213 | + mv -f /sbin/initctl.REAL /sbin/initctl |
214 | + fi |
215 | + $sudo apt-get update -qq |
216 | fi |
217 | - $sudo apt-get update -qq |
218 | echo "Done" |
219 | } |
220 | |
221 | +## main |
222 | + |
223 | +# Try to acquire fd #9 (i.e. /var/lock/hwpack) |
224 | +# Using 9 as the file descriptor because of https://launchpad.net/bugs/249620 |
225 | +exec 9>$LOCKFILE |
226 | +flock -n 9 || die "Could not acquire lock: $LOCKFILE" |
227 | + |
228 | # From now on we'll be making changes to the system, so we need to clean |
229 | # things up when the script exits. |
230 | trap cleanup EXIT |
231 | |
232 | -# This creates all the directories we need. |
233 | -mkdir -p "$HWPACK_DIR" |
234 | - |
235 | -# Unpack the hwpack tarball. We don't download it here because the chroot may |
236 | -# not contain any tools that would allow us to do that. |
237 | -echo -n "Unpacking hardware pack ..." |
238 | -tar zxf "$HWPACK_TARBALL" -C "$HWPACK_DIR" |
239 | -echo "Done" |
240 | - |
241 | -# Check the format of the hwpack is supported. |
242 | -hwpack_format=$(cat ${HWPACK_DIR}/FORMAT) |
243 | -supported="false" |
244 | -for format in $SUPPORTED_FORMATS; do |
245 | - if [ $hwpack_format == $format ]; then |
246 | - supported="true" |
247 | - break |
248 | - fi |
249 | -done |
250 | -[ $supported == "true" ] || \ |
251 | - die "Unsupported hwpack format: $hwpack_format. "\ |
252 | - "Try using a newer version of $(basename $0)." |
253 | - |
254 | -# Check the architecture of the hwpack matches that of the host system. |
255 | -[ "$HWPACK_ARCH" == `dpkg --print-architecture` ] || \ |
256 | - die "Hardware pack architecture ($HWPACK_ARCH) does not match the host's architecture" |
257 | - |
258 | -# Install the apt sources that contain the packages we need. |
259 | -for filename in $(ls "${HWPACK_DIR}"/sources.list.d/); do |
260 | - file="${HWPACK_DIR}"/sources.list.d/$filename |
261 | - should_install=0 |
262 | - stripped_file=${TEMP_DIR}/$filename |
263 | - grep -v "\(^#\|^\s*$\)" $file > $stripped_file |
264 | - while read line; do |
265 | - # Only install files that have at least one line not present in the |
266 | - # existing sources lists. |
267 | - grep -qF "$line" $(find /etc/apt/sources.list.d/ -name '*.list') /etc/apt/sources.list \ |
268 | - || should_install=1 |
269 | - done < $stripped_file |
270 | - |
271 | - if [ $should_install -eq 1 ]; then |
272 | - $sudo cp $file /etc/apt/sources.list.d/hwpack.$filename |
273 | - fi |
274 | -done |
275 | - |
276 | -# Import the OpenPGP keys for the files installed above. |
277 | -for filename in $(ls "${HWPACK_DIR}"/sources.list.d.gpg/); do |
278 | - file="${HWPACK_DIR}"/sources.list.d.gpg/$filename |
279 | - $sudo apt-key add $file |
280 | -done |
281 | - |
282 | -# Prevent daemons to start in the chroot |
283 | -echo "exit 101" > /usr/sbin/policy-rc.d |
284 | -chmod a+x /usr/sbin/policy-rc.d |
285 | - |
286 | -mv -f /sbin/start-stop-daemon /sbin/start-stop-daemon.REAL |
287 | -cat > /sbin/start-stop-daemon << EOF |
288 | -#!/bin/sh |
289 | - |
290 | -echo "Warning: Fake start-stop-daemon called, doing nothing" |
291 | -EOF |
292 | -chmod 755 /sbin/start-stop-daemon |
293 | - |
294 | -if [ -x /sbin/initctl ]; then |
295 | - mv -f /sbin/initctl /sbin/initctl.REAL |
296 | - cat > /sbin/initctl << EOF |
297 | -#!/bin/sh |
298 | - |
299 | -echo "Warning: Fake initctl called, doing nothing" |
300 | -EOF |
301 | - chmod 755 /sbin/initctl |
302 | -fi |
303 | - |
304 | -# Add one extra apt source for the packages included in the hwpack and make |
305 | -# sure it's the first on the list of sources so that it gets precedence over |
306 | -# the others. |
307 | -echo "deb file:${HWPACK_DIR}/pkgs ./" > "$SOURCES_LIST_FILE" |
308 | -cat /etc/apt/sources.list >> "$SOURCES_LIST_FILE" |
309 | - |
310 | -if [ "$FORCE_YES" == "yes" ]; then |
311 | - FORCE_OPTIONS="--yes --force-yes" |
312 | -else |
313 | - FORCE_OPTIONS="" |
314 | -fi |
315 | - |
316 | -echo "Updating apt package lists ..." |
317 | -$sudo apt-get $FORCE_OPTIONS -o "$APT_GET_OPTIONS" update -q |
318 | - |
319 | -echo -n "Installing packages ..." |
320 | - |
321 | -# "newer" hwpacks contain a dependency package whose Depends is the |
322 | -# same as the packages config setting from the file the hwpack was |
323 | -# build from. But if we just installed that, a newer version of a |
324 | -# package than that in the hwpack might have made it to the main |
325 | -# archive and apt-get would install that instead. So we install the |
326 | -# specific package versions that make up the hwpack. /That/ however |
327 | -# would leave all the packages from the hwpack marked as manually |
328 | -# installed, so if a newer hwpack was installed over the top which no |
329 | -# longer depended on one of the packages the older one did, the |
330 | -# package would not be eligible for autoremoval. So we mark the all |
331 | -# packages newly installed as part of hwpack installed (apart from the |
332 | -# dependency package) as automatically installed with apt-get |
333 | -# markauto. |
334 | -# |
335 | -# For "older" hwpacks that don't have a dependency package, we just |
336 | -# manually install the contents of the hwpack. |
337 | - |
338 | -dependency_package="hwpack-${HWPACK_NAME}" |
339 | -if grep -q "^${dependency_package}=${HWPACK_VERSION}\$" "${HWPACK_DIR}"/manifest; then |
340 | - DEP_PACKAGE_PRESENT="yes" |
341 | -else |
342 | - DEP_PACKAGE_PRESENT="no" |
343 | -fi |
344 | - |
345 | -packages_without_versions=`sed 's/=.*//' "${HWPACK_DIR}"/manifest` |
346 | -packages_with_versions=`cat "${HWPACK_DIR}"/manifest` |
347 | - |
348 | -if [ "$INSTALL_LATEST" == "yes" ]; then |
349 | - packages="${packages_without_versions}" |
350 | -else |
351 | - packages="${packages_with_versions}" |
352 | -fi |
353 | - |
354 | -if [ "$DEP_PACKAGE_PRESENT" == "yes" ]; then |
355 | - to_be_installed= |
356 | - for package in $packages_without_versions; do |
357 | - if [ "${package}" != "${dependency_package}" ]; then |
358 | - { dpkg --get-selections $package 2>/dev/null| grep -qw 'install$'; } || to_be_installed="$to_be_installed $package" |
359 | - fi |
360 | - done |
361 | -fi |
362 | - |
363 | -$sudo apt-get $FORCE_OPTIONS -o "$APT_GET_OPTIONS" install ${packages} |
364 | - |
365 | -if [ "$DEP_PACKAGE_PRESENT" == "yes" ]; then |
366 | - if [ -n "${to_be_installed}" ]; then |
367 | - $sudo apt-get $FORCE_OPTIONS -o "$APT_GET_OPTIONS" markauto ${to_be_installed} |
368 | - fi |
369 | +# Extract and set up the hwpack at the rootfs |
370 | +setup_hwpack |
371 | + |
372 | +# In case we only care about the kernel, don't mess up with the system |
373 | +if [ "x$EXTRACT_KERNEL_ONLY" = "xno" ]; then |
374 | + setup_apt_sources |
375 | + setup_ubuntu_rootfs |
376 | + install_deb_packages |
377 | +else |
378 | + extract_kernel_packages |
379 | fi |
380 | |
381 | echo "Done" |
382 | |
383 | === modified file 'linaro-media-create' |
384 | --- linaro-media-create 2012-07-26 09:09:49 +0000 |
385 | +++ linaro-media-create 2012-08-09 01:33:20 +0000 |
386 | @@ -164,14 +164,27 @@ |
387 | |
388 | # If --help was specified this won't execute. |
389 | # Create temp dir and initialize rest of path vars. |
390 | - filesystem_dir = 'binary' |
391 | - if not path_in_tarfile_exists('binary/etc', args.binary): |
392 | - # The binary image is in the new live format. |
393 | - filesystem_dir = 'binary/boot/filesystem.dir' |
394 | TMP_DIR = tempfile.mkdtemp() |
395 | - ROOTFS_DIR = os.path.join(TMP_DIR, filesystem_dir) |
396 | BOOT_DISK = os.path.join(TMP_DIR, 'boot-disc') |
397 | ROOT_DISK = os.path.join(TMP_DIR, 'root-disc') |
398 | + BIN_DIR = os.path.join(TMP_DIR, 'rootfs') |
399 | + os.mkdir(BIN_DIR) |
400 | + |
401 | + # Identify the correct path for the rootfs |
402 | + filesystem_dir = '' |
403 | + if path_in_tarfile_exists('binary/etc', args.binary): |
404 | + filesystem_dir = 'binary' |
405 | + elif path_in_tarfile_exists('binary/boot/filesystem.dir', args.binary): |
406 | + # The binary image is in the new live format. |
407 | + filesystem_dir = 'binary/boot/filesystem.dir' |
408 | + |
409 | + # if not a debian compatible system, just extract the kernel packages |
410 | + extract_kpkgs = False |
411 | + if not path_in_tarfile_exists( |
412 | + filesystem_dir + '/etc/debian_version', args.binary): |
413 | + extract_kpkgs = True |
414 | + |
415 | + ROOTFS_DIR = os.path.join(BIN_DIR, filesystem_dir) |
416 | |
417 | ensure_required_commands(args) |
418 | |
419 | @@ -188,28 +201,42 @@ |
420 | |
421 | atexit.register(cleanup_tempdir) |
422 | |
423 | - unpack_binary_tarball(args.binary, TMP_DIR) |
424 | + unpack_binary_tarball(args.binary, BIN_DIR) |
425 | |
426 | hwpacks = args.hwpacks |
427 | lmc_dir = os.path.dirname(__file__) |
428 | if lmc_dir == '': |
429 | lmc_dir = None |
430 | install_hwpacks(ROOTFS_DIR, TMP_DIR, lmc_dir, args.hwpack_force_yes, |
431 | - verified_files, *hwpacks) |
432 | + verified_files, extract_kpkgs, *hwpacks) |
433 | |
434 | if args.rootfs == 'btrfs': |
435 | - install_packages(ROOTFS_DIR, TMP_DIR, "btrfs-tools") |
436 | + if not extract_kpkgs: |
437 | + print ("Desired rootfs type is 'btrfs', trying to auto-install " |
438 | + "the 'btrfs-tools' package") |
439 | + install_packages(ROOTFS_DIR, TMP_DIR, "btrfs-tools") |
440 | + else: |
441 | + print ("Desired rootfs type is 'btrfs', please make sure the " |
442 | + "rootfs also includes 'btrfs-tools'") |
443 | |
444 | boot_partition, root_partition = setup_partitions( |
445 | board_config, media, args.image_size, args.boot_label, args.rfs_label, |
446 | args.rootfs, args.should_create_partitions, args.should_format_bootfs, |
447 | args.should_format_rootfs, args.should_align_boot_part) |
448 | |
449 | - rootfs_uuid = get_uuid(root_partition) |
450 | + uuid = get_uuid(root_partition) |
451 | + # In case we're only extracting the kernel packages, avoid |
452 | + # using uuid because we don't have a working initrd |
453 | + if extract_kpkgs: |
454 | + # XXX: this needs to be smarter as we can't always assume mmcblk devices |
455 | + rootfs_id = '/dev/mmcblk%dp%s' % ( |
456 | + board_config.mmc_device_id, 2 + board_config.mmc_part_offset) |
457 | + else: |
458 | + rootfs_id = "UUID=%s" % uuid |
459 | |
460 | if args.should_format_bootfs: |
461 | board_config.populate_boot( |
462 | - ROOTFS_DIR, rootfs_uuid, boot_partition, BOOT_DISK, media.path, |
463 | + ROOTFS_DIR, rootfs_id, boot_partition, BOOT_DISK, media.path, |
464 | args.is_live, args.is_lowmem, args.consoles) |
465 | |
466 | if args.should_format_rootfs: |
467 | @@ -217,7 +244,7 @@ |
468 | if args.swap_file is not None: |
469 | create_swap = True |
470 | populate_rootfs(ROOTFS_DIR, ROOT_DISK, root_partition, args.rootfs, |
471 | - rootfs_uuid, create_swap, str(args.swap_file), |
472 | + rootfs_id, create_swap, str(args.swap_file), |
473 | board_config.mmc_device_id, board_config.mmc_part_offset, |
474 | board_config) |
475 | |
476 | |
477 | === modified file 'linaro_image_tools/media_create/android_boards.py' |
478 | --- linaro_image_tools/media_create/android_boards.py 2012-07-26 15:30:34 +0000 |
479 | +++ linaro_image_tools/media_create/android_boards.py 2012-08-09 01:33:20 +0000 |
480 | @@ -77,10 +77,13 @@ |
481 | """ |
482 | boot_env = {} |
483 | boot_env["bootargs"] = cls._get_bootargs(consoles) |
484 | + initrd = False |
485 | + if cls.initrd_addr: |
486 | + initrd = True |
487 | # On Android, the DTB file is always built as part of the kernel it |
488 | # comes from - and lives in the same directory in the boot tarball, so |
489 | # here we don't need to pass the whole path to it. |
490 | - boot_env["bootcmd"] = cls._get_bootcmd(cls.dtb_name) |
491 | + boot_env["bootcmd"] = cls._get_bootcmd(initrd, cls.dtb_name) |
492 | return boot_env |
493 | |
494 | @classmethod |
495 | |
496 | === modified file 'linaro_image_tools/media_create/boards.py' |
497 | --- linaro_image_tools/media_create/boards.py 2012-07-26 16:20:57 +0000 |
498 | +++ linaro_image_tools/media_create/boards.py 2012-08-09 01:33:20 +0000 |
499 | @@ -576,7 +576,7 @@ |
500 | return cls.get_v1_sfdisk_cmd(should_align_boot_part) |
501 | |
502 | @classmethod |
503 | - def _get_bootcmd(cls, d_img_data): |
504 | + def _get_bootcmd(cls, i_img_data, d_img_data): |
505 | """Get the bootcmd for this board. |
506 | |
507 | In general subclasses should not have to override this. |
508 | @@ -587,20 +587,22 @@ |
509 | initrd_addr=cls.initrd_addr, dtb_addr=cls.dtb_addr) |
510 | boot_script = ( |
511 | ("%(fatload_command)s mmc %(mmc_option)s %(kernel_addr)s " + |
512 | - "%(uimage_path)suImage; ") + |
513 | + "%(uimage_path)suImage; ")) % replacements |
514 | + if i_img_data is not None: |
515 | + boot_script += ( |
516 | ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " + |
517 | "%(uimage_path)suInitrd; ")) % replacements |
518 | - if d_img_data is not None: |
519 | - assert cls.dtb_addr is not None, ( |
520 | - "Need a dtb_addr when passing d_img_data") |
521 | - boot_script += ( |
522 | - ("%(fatload_command)s mmc %(mmc_option)s %(dtb_addr)s " + |
523 | - "board.dtb; ") + |
524 | - "bootm %(kernel_addr)s %(initrd_addr)s %(dtb_addr)s" |
525 | - ) % replacements |
526 | - else: |
527 | - boot_script += ( |
528 | - "bootm %(kernel_addr)s %(initrd_addr)s" % replacements) |
529 | + if d_img_data is not None: |
530 | + assert cls.dtb_addr is not None, ( |
531 | + "Need a dtb_addr when passing d_img_data") |
532 | + boot_script += ( |
533 | + ("%(fatload_command)s mmc %(mmc_option)s %(dtb_addr)s " + |
534 | + "board.dtb; ")) % replacements |
535 | + boot_script += (("bootm %(kernel_addr)s")) % replacements |
536 | + if i_img_data is not None: |
537 | + boot_script += ((" %(initrd_addr)s")) % replacements |
538 | + if d_img_data is not None: |
539 | + boot_script += ((" %(dtb_addr)s")) % replacements |
540 | return boot_script |
541 | |
542 | @classmethod |
543 | @@ -618,7 +620,7 @@ |
544 | cls.add_boot_args(boot_args_file.read().strip()) |
545 | |
546 | @classmethod |
547 | - def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_uuid): |
548 | + def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_id): |
549 | """Get the bootargs for this board. |
550 | |
551 | In general subclasses should not have to override this. |
552 | @@ -631,7 +633,7 @@ |
553 | serial_opts += ' console=%s' % console |
554 | |
555 | lowmem_opt = '' |
556 | - boot_snippet = 'root=UUID=%s' % rootfs_uuid |
557 | + boot_snippet = 'root=%s' % rootfs_id |
558 | if is_live: |
559 | serial_opts += ' %s' % cls.live_serial_opts |
560 | boot_snippet = 'boot=casper' |
561 | @@ -648,21 +650,21 @@ |
562 | % replacements) |
563 | |
564 | @classmethod |
565 | - def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid, |
566 | - d_img_data): |
567 | + def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_id, |
568 | + i_img_data, d_img_data): |
569 | """Get the boot environment for this board. |
570 | |
571 | In general subclasses should not have to override this. |
572 | """ |
573 | boot_env = {} |
574 | boot_env["bootargs"] = cls._get_bootargs( |
575 | - is_live, is_lowmem, consoles, rootfs_uuid) |
576 | - boot_env["bootcmd"] = cls._get_bootcmd(d_img_data) |
577 | + is_live, is_lowmem, consoles, rootfs_id) |
578 | + boot_env["bootcmd"] = cls._get_bootcmd(i_img_data, d_img_data) |
579 | return boot_env |
580 | |
581 | @classmethod |
582 | def make_boot_files(cls, bootloader_parts_dir, is_live, is_lowmem, |
583 | - consoles, chroot_dir, rootfs_uuid, boot_dir, |
584 | + consoles, chroot_dir, rootfs_id, boot_dir, |
585 | boot_device_or_file): |
586 | if cls.hwpack_format == HardwarepackHandler.FORMAT_1: |
587 | parts_dir = bootloader_parts_dir |
588 | @@ -670,8 +672,8 @@ |
589 | parts_dir = chroot_dir |
590 | (k_img_data, i_img_data, d_img_data) = cls._get_kflavor_files( |
591 | parts_dir) |
592 | - boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_uuid, |
593 | - d_img_data) |
594 | + boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_id, |
595 | + i_img_data, d_img_data) |
596 | |
597 | if cls.hwpack_format == HardwarepackHandler.FORMAT_1: |
598 | cls._make_boot_files( |
599 | @@ -728,7 +730,9 @@ |
600 | cls.bootloader_dd) |
601 | |
602 | make_uImage(cls.load_addr, k_img_data, boot_dir) |
603 | - make_uInitrd(i_img_data, boot_dir) |
604 | + |
605 | + if i_img_data is not None: |
606 | + make_uInitrd(i_img_data, boot_dir) |
607 | |
608 | if d_img_data is not None: |
609 | make_dtb(d_img_data, boot_dir) |
610 | @@ -766,7 +770,7 @@ |
611 | raise NotImplementedError() |
612 | |
613 | @classmethod |
614 | - def populate_boot(cls, chroot_dir, rootfs_uuid, boot_partition, boot_disk, |
615 | + def populate_boot(cls, chroot_dir, rootfs_id, boot_partition, boot_disk, |
616 | boot_device_or_file, is_live, is_lowmem, consoles): |
617 | parts_dir = 'boot' |
618 | if is_live: |
619 | @@ -799,7 +803,7 @@ |
620 | |
621 | cls.make_boot_files( |
622 | bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir, |
623 | - rootfs_uuid, boot_disk, boot_device_or_file) |
624 | + rootfs_id, boot_disk, boot_device_or_file) |
625 | |
626 | @classmethod |
627 | def _get_kflavor_files(cls, path): |
628 | @@ -833,18 +837,18 @@ |
629 | def _get_kflavor_files_v2(cls, path): |
630 | kernel = _get_file_matching(os.path.join(path, cls.vmlinuz)) |
631 | if kernel is not None: |
632 | + logger = logging.getLogger("linaro_image_tools") |
633 | initrd = _get_file_matching(os.path.join(path, cls.initrd)) |
634 | - if initrd is not None: |
635 | - dtb = None |
636 | - if cls.dtb_file is not None: |
637 | - dtb = _get_file_matching(os.path.join(path, cls.dtb_file)) |
638 | - logger = logging.getLogger("linaro_image_tools") |
639 | - logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \ |
640 | - (kernel, initrd, dtb)) |
641 | - return (kernel, initrd, dtb) |
642 | - raise ValueError( |
643 | - "Found kernel matching %s but no initrd matching %s" % ( |
644 | - cls.vmlinuz, cls.initrd)) |
645 | + if initrd is None: |
646 | + logger.warn( |
647 | + "Could not find a valid initrd, skipping uInitd.") |
648 | + dtb = _get_file_matching(os.path.join(path, cls.dtb_file)) |
649 | + if dtb is None and cls.dtb_file is not None: |
650 | + logger.warn( |
651 | + "Could not find a valid dtb file, skipping it.") |
652 | + logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \ |
653 | + (kernel, initrd, dtb)) |
654 | + return (kernel, initrd, dtb) |
655 | raise ValueError( |
656 | "No kernel found matching %s." % (cls.vmlinuz)) |
657 | |
658 | @@ -912,7 +916,7 @@ |
659 | |
660 | @classmethod |
661 | def make_boot_files(cls, bootloader_parts_dir, is_live, is_lowmem, |
662 | - consoles, chroot_dir, rootfs_uuid, boot_dir, |
663 | + consoles, chroot_dir, rootfs_id, boot_dir, |
664 | boot_device_or_file): |
665 | # XXX: This is also part of our temporary hack to fix bug 697824; we |
666 | # need to call set_appropriate_serial_tty() before doing anything that |
667 | @@ -921,7 +925,7 @@ |
668 | cls.set_appropriate_serial_tty(chroot_dir) |
669 | super(OmapConfig, cls).make_boot_files( |
670 | bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir, |
671 | - rootfs_uuid, boot_dir, boot_device_or_file) |
672 | + rootfs_id, boot_dir, boot_device_or_file) |
673 | |
674 | @classmethod |
675 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, |
676 | @@ -1511,10 +1515,10 @@ |
677 | mmc_option = '0:2' |
678 | |
679 | @classmethod |
680 | - def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid, |
681 | - d_img_data): |
682 | + def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_id, |
683 | + i_img_data, d_img_data): |
684 | boot_env = super(SamsungConfig, cls)._get_boot_env( |
685 | - is_live, is_lowmem, consoles, rootfs_uuid, d_img_data) |
686 | + is_live, is_lowmem, consoles, rootfs_id, i_img_data, d_img_data) |
687 | |
688 | boot_env["ethact"] = "smc911x-0" |
689 | boot_env["ethaddr"] = "00:40:5c:26:0a:5b" |
690 | |
691 | === modified file 'linaro_image_tools/media_create/chroot_utils.py' |
692 | --- linaro_image_tools/media_create/chroot_utils.py 2012-07-23 14:10:35 +0000 |
693 | +++ linaro_image_tools/media_create/chroot_utils.py 2012-08-09 01:33:20 +0000 |
694 | @@ -46,7 +46,7 @@ |
695 | |
696 | def install_hwpacks( |
697 | chroot_dir, tmp_dir, tools_dir, hwpack_force_yes, verified_files, |
698 | - *hwpack_files): |
699 | + extract_kpkgs = False, *hwpack_files): |
700 | """Install the given hwpacks onto the given chroot.""" |
701 | prepare_chroot(chroot_dir, tmp_dir) |
702 | |
703 | @@ -79,18 +79,19 @@ |
704 | hwpack_verified = False |
705 | if os.path.basename(hwpack_file) in verified_files: |
706 | hwpack_verified = True |
707 | - install_hwpack(chroot_dir, hwpack_file, |
708 | + install_hwpack(chroot_dir, hwpack_file, extract_kpkgs, |
709 | hwpack_force_yes or hwpack_verified) |
710 | finally: |
711 | run_local_atexit_funcs() |
712 | |
713 | |
714 | -def install_hwpack(chroot_dir, hwpack_file, hwpack_force_yes): |
715 | +def install_hwpack(chroot_dir, hwpack_file, extract_kpkgs, hwpack_force_yes): |
716 | """Install an hwpack on the given chroot. |
717 | |
718 | Copy the hwpack file to the chroot and run linaro-hwpack-install passing |
719 | that hwpack file to it. If hwpack_force_yes is True, also pass |
720 | - --force-yes to linaro-hwpack-install. |
721 | + --force-yes to linaro-hwpack-install. In case extract_kpkgs is True, it |
722 | + will not install all the packages, but just extract the kernel ones. |
723 | """ |
724 | hwpack_basename = os.path.basename(hwpack_file) |
725 | copy_file(hwpack_file, chroot_dir) |
726 | @@ -110,6 +111,8 @@ |
727 | '--hwpack-name', name] |
728 | if hwpack_force_yes: |
729 | args.append('--force-yes') |
730 | + if extract_kpkgs: |
731 | + args.append('--extract-kernel-only') |
732 | args.append('/%s' % hwpack_basename) |
733 | cmd_runner.run(args, as_root=True, chroot=chroot_dir).wait() |
734 | print "-" * 60 |
735 | @@ -179,15 +182,20 @@ |
736 | basename = os.path.basename(filepath) |
737 | path_to_orig = os.path.join(tmp_dir, basename) |
738 | # Move the existing file from the given directory to the temp dir. |
739 | - cmd_runner.run( |
740 | - ['mv', '-f', os.path.join(directory, basename), path_to_orig], |
741 | - as_root=True).wait() |
742 | + oldpath = os.path.join(directory, basename) |
743 | + if os.path.exists(oldpath): |
744 | + cmd_runner.run( |
745 | + ['mv', '-f', oldpath, path_to_orig], as_root=True).wait() |
746 | # Now copy the given file onto the given directory. |
747 | cmd_runner.run(['cp', filepath, directory], as_root=True).wait() |
748 | |
749 | def undo(): |
750 | - cmd_runner.run( |
751 | - ['mv', '-f', path_to_orig, directory], as_root=True).wait() |
752 | + if os.path.exists(path_to_orig): |
753 | + cmd_runner.run( |
754 | + ['mv', '-f', path_to_orig, directory], as_root=True).wait() |
755 | + else: |
756 | + cmd_runner.run( |
757 | + ['rm', '-f', oldpath], as_root=True).wait() |
758 | local_atexit.append(undo) |
759 | |
760 | |
761 | |
762 | === modified file 'linaro_image_tools/media_create/rootfs.py' |
763 | --- linaro_image_tools/media_create/rootfs.py 2012-06-13 14:11:28 +0000 |
764 | +++ linaro_image_tools/media_create/rootfs.py 2012-08-09 01:33:20 +0000 |
765 | @@ -42,7 +42,7 @@ |
766 | |
767 | |
768 | def populate_rootfs(content_dir, root_disk, partition, rootfs_type, |
769 | - rootfs_uuid, should_create_swap, swap_size, |
770 | + rootfs_id, should_create_swap, swap_size, |
771 | mmc_device_id, partition_offset, board_config=None): |
772 | """Populate the rootfs and make the necessary tweaks to make it usable. |
773 | |
774 | @@ -64,8 +64,8 @@ |
775 | move_contents(content_dir, root_disk) |
776 | |
777 | mount_options = rootfs_mount_options(rootfs_type) |
778 | - fstab_additions = ["UUID=%s / %s %s 0 1" % ( |
779 | - rootfs_uuid, rootfs_type, mount_options)] |
780 | + fstab_additions = ["%s / %s %s 0 1" % ( |
781 | + rootfs_id, rootfs_type, mount_options)] |
782 | if should_create_swap: |
783 | print "\nCreating SWAP File\n" |
784 | if has_space_left_for_swap(root_disk, swap_size): |
785 | |
786 | === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' |
787 | --- linaro_image_tools/media_create/tests/test_media_create.py 2012-07-26 16:20:57 +0000 |
788 | +++ linaro_image_tools/media_create/tests/test_media_create.py 2012-08-09 01:33:20 +0000 |
789 | @@ -950,7 +950,8 @@ |
790 | |
791 | boot_env = board_configs['snowball_emmc']._get_boot_env( |
792 | is_live=False, is_lowmem=False, consoles=[], |
793 | - rootfs_uuid="test_boot_env_uuid", d_img_data=None) |
794 | + rootfs_id="UUID=test_boot_env_uuid", |
795 | + i_img_data=None, d_img_data=None) |
796 | boards.SnowballEmmcConfig._make_boot_files(boot_env, self.tempdir, |
797 | self.temp_bootdir_path, 'boot_device_or_file', k_img_file, |
798 | i_img_file, None) |
799 | @@ -1577,7 +1578,7 @@ |
800 | def test_vexpress(self): |
801 | boot_commands = board_configs['vexpress']._get_boot_env( |
802 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], |
803 | - rootfs_uuid="deadbeef", d_img_data=None) |
804 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
805 | expected = { |
806 | 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 ' |
807 | 'console=ttyXXX root=UUID=deadbeef rootwait ro', |
808 | @@ -1589,7 +1590,7 @@ |
809 | def test_vexpress_a9(self): |
810 | boot_commands = board_configs['vexpress-a9']._get_boot_env( |
811 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], |
812 | - rootfs_uuid="deadbeef", d_img_data=None) |
813 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
814 | expected = { |
815 | 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 ' |
816 | 'console=ttyXXX root=UUID=deadbeef rootwait ro', |
817 | @@ -1601,7 +1602,8 @@ |
818 | def test_mx51(self): |
819 | boot_commands = boards.Mx51Config._get_boot_env( |
820 | is_live=False, is_lowmem=False, consoles=[], |
821 | - rootfs_uuid="deadbeef", d_img_data="mx51.dtb") |
822 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", |
823 | + d_img_data="mx51.dtb") |
824 | expected = { |
825 | 'bootargs': 'console=tty0 console=ttymxc0,115200n8 ' |
826 | 'root=UUID=deadbeef rootwait ro', |
827 | @@ -1614,7 +1616,7 @@ |
828 | def test_smdkv310(self): |
829 | boot_commands = board_configs['smdkv310']._get_boot_env( |
830 | is_live=False, is_lowmem=False, consoles=[], |
831 | - rootfs_uuid="deadbeef", d_img_data=None) |
832 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
833 | expected = { |
834 | 'bootargs': 'console=ttySAC1,115200n8 root=UUID=deadbeef ' |
835 | 'rootwait ro', |
836 | @@ -1628,7 +1630,7 @@ |
837 | def test_origen(self): |
838 | boot_commands = board_configs['origen']._get_boot_env( |
839 | is_live=False, is_lowmem=False, consoles=[], |
840 | - rootfs_uuid="deadbeef", d_img_data=None) |
841 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
842 | expected = { |
843 | 'bootargs': 'console=ttySAC2,115200n8 root=UUID=deadbeef ' |
844 | 'rootwait ro', |
845 | @@ -1640,7 +1642,7 @@ |
846 | def test_ux500(self): |
847 | boot_commands = board_configs['ux500']._get_boot_env( |
848 | is_live=False, is_lowmem=False, consoles=[], |
849 | - rootfs_uuid="deadbeef", d_img_data=None) |
850 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
851 | expected = { |
852 | 'bootargs': 'console=tty0 console=ttyAMA2,115200n8 ' |
853 | 'root=UUID=deadbeef rootwait ro earlyprintk ' |
854 | @@ -1656,7 +1658,7 @@ |
855 | def test_snowball_emmc(self): |
856 | boot_commands = board_configs['snowball_emmc']._get_boot_env( |
857 | is_live=False, is_lowmem=False, consoles=[], |
858 | - rootfs_uuid="deadbeef", d_img_data=None) |
859 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
860 | expected = { |
861 | 'bootargs': 'console=tty0 console=ttyAMA2,115200n8 ' |
862 | 'root=UUID=deadbeef rootwait ro earlyprintk ' |
863 | @@ -1677,7 +1679,8 @@ |
864 | config.serial_tty = config._serial_tty |
865 | boot_commands = config._get_boot_env( |
866 | is_live=False, is_lowmem=False, consoles=[], |
867 | - rootfs_uuid="deadbeef", d_img_data="panda.dtb") |
868 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", |
869 | + d_img_data="panda.dtb") |
870 | expected = { |
871 | 'bootargs': 'console=tty0 console=ttyO2,115200n8 ' |
872 | 'root=UUID=deadbeef rootwait ro earlyprintk fixrtc ' |
873 | @@ -1697,7 +1700,8 @@ |
874 | config.serial_tty = config._serial_tty |
875 | boot_commands = config._get_boot_env( |
876 | is_live=False, is_lowmem=False, consoles=[], |
877 | - rootfs_uuid="deadbeef", d_img_data="beagle.dtb") |
878 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", |
879 | + d_img_data="beagle.dtb") |
880 | expected = { |
881 | 'bootargs': 'console=tty0 console=ttyO2,115200n8 ' |
882 | 'root=UUID=deadbeef rootwait ro earlyprintk fixrtc ' |
883 | @@ -1717,7 +1721,8 @@ |
884 | config.serial_tty = config._serial_tty |
885 | boot_cmd = config._get_boot_env( |
886 | is_live=False, is_lowmem=False, consoles=[], |
887 | - rootfs_uuid="deadbeef", d_img_data="igep.dtb") |
888 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", |
889 | + d_img_data="igep.dtb") |
890 | expected = { |
891 | 'bootargs': 'console=tty0 console=ttyO2,115200n8 ' |
892 | 'root=UUID=deadbeef rootwait ro earlyprintk fixrtc ' |
893 | @@ -1737,7 +1742,8 @@ |
894 | config.serial_tty = config._serial_tty |
895 | boot_commands = config._get_boot_env( |
896 | is_live=False, is_lowmem=False, consoles=[], |
897 | - rootfs_uuid="deadbeef", d_img_data="overo.dtb") |
898 | + rootfs_id="UUID=deadbeef", i_img_data="initrd", |
899 | + d_img_data="overo.dtb") |
900 | expected = { |
901 | 'bootargs': 'console=tty0 console=ttyO2,115200n8 ' |
902 | 'root=UUID=deadbeef rootwait ro earlyprintk ' |
903 | @@ -1760,7 +1766,7 @@ |
904 | extra_boot_args_options = boot_args |
905 | boot_commands = config._get_boot_env( |
906 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], |
907 | - rootfs_uuid="deadbeef", d_img_data=None) |
908 | + rootfs_id="UUID=deadbeef", i_img_data=None, d_img_data=None) |
909 | expected = ( |
910 | ' console=ttyXXX root=UUID=deadbeef rootwait ro %s' % boot_args) |
911 | self.assertEqual(expected, boot_commands['bootargs']) |
912 | @@ -2874,10 +2880,10 @@ |
913 | class TestPopulateBoot(TestCaseWithFixtures): |
914 | |
915 | expected_args = ( |
916 | - 'chroot_dir/boot', False, False, [], 'chroot_dir', 'rootfs_uuid', |
917 | + 'chroot_dir/boot', False, False, [], 'chroot_dir', 'rootfs_id', |
918 | 'boot_disk', 'boot_device_or_file') |
919 | expected_args_live = ( |
920 | - 'chroot_dir/casper', True, False, [], 'chroot_dir', 'rootfs_uuid', |
921 | + 'chroot_dir/casper', True, False, [], 'chroot_dir', 'rootfs_id', |
922 | 'boot_disk', 'boot_device_or_file') |
923 | expected_calls = [ |
924 | 'mkdir -p boot_disk', |
925 | @@ -2903,7 +2909,7 @@ |
926 | |
927 | def call_populate_boot(self, config, is_live=False): |
928 | config.populate_boot( |
929 | - 'chroot_dir', 'rootfs_uuid', 'boot_partition', 'boot_disk', |
930 | + 'chroot_dir', 'rootfs_id', 'boot_partition', 'boot_disk', |
931 | 'boot_device_or_file', is_live, False, []) |
932 | |
933 | def test_populate_boot_live(self): |
934 | @@ -3000,7 +3006,7 @@ |
935 | |
936 | populate_rootfs( |
937 | contents_dir, root_disk, partition='/dev/rootfs', |
938 | - rootfs_type='ext3', rootfs_uuid='uuid', should_create_swap=True, |
939 | + rootfs_type='ext3', rootfs_id='UUID=uuid', should_create_swap=True, |
940 | swap_size=100, mmc_device_id=0, partition_offset=0) |
941 | |
942 | self.assertEqual( |
943 | @@ -3308,14 +3314,13 @@ |
944 | fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
945 | temporarily_overwrite_file_on_dir('/path/to/file', '/dir', '/tmp/dir') |
946 | self.assertEquals( |
947 | - ['%s mv -f /dir/file /tmp/dir/file' % sudo_args, |
948 | - '%s cp /path/to/file /dir' % sudo_args], |
949 | + ['%s cp /path/to/file /dir' % sudo_args], |
950 | fixture.mock.commands_executed) |
951 | |
952 | fixture.mock.calls = [] |
953 | run_local_atexit_funcs() |
954 | self.assertEquals( |
955 | - ['%s mv -f /tmp/dir/file /dir' % sudo_args], |
956 | + ['%s rm -f /dir/file' % sudo_args], |
957 | fixture.mock.commands_executed) |
958 | |
959 | def test_copy_file(self): |
960 | @@ -3355,10 +3360,12 @@ |
961 | hwpack_name = "foo" |
962 | hwpack_version = "4" |
963 | hwpack_architecture = "armel" |
964 | + extract_kpkgs = False |
965 | self.create_minimal_v3_hwpack(hwpack_tgz_location, hwpack_name, |
966 | hwpack_version, hwpack_architecture) |
967 | force_yes = False |
968 | - install_hwpack(chroot_dir, hwpack_tgz_location, force_yes) |
969 | + install_hwpack(chroot_dir, hwpack_tgz_location, |
970 | + extract_kpkgs, force_yes) |
971 | self.assertEquals( |
972 | ['%s cp %s %s' % (sudo_args, hwpack_tgz_location, chroot_dir), |
973 | '%s %s %s linaro-hwpack-install --hwpack-version %s ' |
974 | @@ -3374,6 +3381,38 @@ |
975 | ['%s rm -f %s/hwpack.tgz' % (sudo_args, chroot_dir)], |
976 | fixture.mock.commands_executed) |
977 | |
978 | + def test_install_hwpack_extract(self): |
979 | + self.useFixture(MockSomethingFixture( |
980 | + sys, 'stdout', open('/dev/null', 'w'))) |
981 | + fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
982 | + chroot_dir = 'chroot_dir' |
983 | + hwpack_dir = tempfile.mkdtemp() |
984 | + hwpack_file_name = 'hwpack.tgz' |
985 | + hwpack_tgz_location = os.path.join(hwpack_dir, hwpack_file_name) |
986 | + hwpack_name = "foo" |
987 | + hwpack_version = "4" |
988 | + hwpack_architecture = "armel" |
989 | + extract_kpkgs = True |
990 | + self.create_minimal_v3_hwpack(hwpack_tgz_location, hwpack_name, |
991 | + hwpack_version, hwpack_architecture) |
992 | + force_yes = False |
993 | + install_hwpack(chroot_dir, hwpack_tgz_location, |
994 | + extract_kpkgs, force_yes) |
995 | + self.assertEquals( |
996 | + ['%s cp %s %s' % (sudo_args, hwpack_tgz_location, chroot_dir), |
997 | + '%s %s %s linaro-hwpack-install --hwpack-version %s ' |
998 | + '--hwpack-arch %s --hwpack-name %s --extract-kernel-only /%s' |
999 | + % (sudo_args, chroot_args, chroot_dir, |
1000 | + hwpack_version, hwpack_architecture, hwpack_name, |
1001 | + hwpack_file_name)], |
1002 | + fixture.mock.commands_executed) |
1003 | + |
1004 | + fixture.mock.calls = [] |
1005 | + run_local_atexit_funcs() |
1006 | + self.assertEquals( |
1007 | + ['%s rm -f %s/hwpack.tgz' % (sudo_args, chroot_dir)], |
1008 | + fixture.mock.commands_executed) |
1009 | + |
1010 | def test_install_hwpacks(self): |
1011 | self.useFixture(MockSomethingFixture( |
1012 | sys, 'stdout', open('/dev/null', 'w'))) |
1013 | @@ -3389,6 +3428,7 @@ |
1014 | hwpack_file_names = ['hwpack1.tgz', 'hwpack2.tgz'] |
1015 | hwpack_tgz_locations = [] |
1016 | hwpack_names = [] |
1017 | + extract_kpkgs = False |
1018 | for hwpack_file_name in hwpack_file_names: |
1019 | hwpack_tgz_location = os.path.join(hwpack_dir, hwpack_file_name) |
1020 | hwpack_tgz_locations.append(hwpack_tgz_location) |
1021 | @@ -3400,7 +3440,7 @@ |
1022 | hwpack_architecture) |
1023 | |
1024 | install_hwpacks( |
1025 | - chroot_dir, tmp_dir, prefer_dir, force_yes, [], |
1026 | + chroot_dir, tmp_dir, prefer_dir, force_yes, [], extract_kpkgs, |
1027 | hwpack_tgz_locations[0], hwpack_tgz_locations[1]) |
1028 | linaro_hwpack_install = find_command( |
1029 | 'linaro-hwpack-install', prefer_dir=prefer_dir) |
1030 | @@ -3463,14 +3503,12 @@ |
1031 | prepare_chroot('chroot', '/tmp/dir') |
1032 | run_local_atexit_funcs() |
1033 | expected = [ |
1034 | - 'mv -f chroot/etc/resolv.conf /tmp/dir/resolv.conf', |
1035 | 'cp /etc/resolv.conf chroot/etc', |
1036 | - 'mv -f chroot/etc/hosts /tmp/dir/hosts', |
1037 | 'cp /etc/hosts chroot/etc', |
1038 | 'cp /usr/bin/qemu-arm-static chroot/usr/bin', |
1039 | 'rm -f chroot/usr/bin/qemu-arm-static', |
1040 | - 'mv -f /tmp/dir/hosts chroot/etc', |
1041 | - 'mv -f /tmp/dir/resolv.conf chroot/etc'] |
1042 | + 'rm -f chroot/etc/hosts', |
1043 | + 'rm -f chroot/etc/resolv.conf'] |
1044 | expected = [ |
1045 | "%s %s" % (sudo_args, line) for line in expected] |
1046 | self.assertEquals(expected, fixture.mock.commands_executed) |
1047 | @@ -3508,7 +3546,7 @@ |
1048 | def mock_run_local_atexit_functions(): |
1049 | self.run_local_atexit_functions_called = True |
1050 | |
1051 | - def mock_install_hwpack(p1, p2, p3): |
1052 | + def mock_install_hwpack(p1, p2, p3, p4): |
1053 | raise Exception('hwpack mock exception') |
1054 | |
1055 | self.useFixture(MockSomethingFixture( |
1056 | @@ -3524,10 +3562,11 @@ |
1057 | |
1058 | force_yes = True |
1059 | exception_caught = False |
1060 | + extract_kpkgs = False |
1061 | try: |
1062 | install_hwpacks( |
1063 | 'chroot', '/tmp/dir', preferred_tools_dir(), force_yes, [], |
1064 | - 'hwp.tgz', 'hwp2.tgz') |
1065 | + extract_kpkgs, 'hwp.tgz', 'hwp2.tgz') |
1066 | except: |
1067 | exception_caught = True |
1068 | self.assertTrue(self.run_local_atexit_functions_called) |
Looks fine. Gosh I wish we had moved block detection and change classification in the diff viewer (wouldn't it be nice if all the places where a variable were renamed could be just ticked off then ignored). Anyway, one small change, but I will make it and them merge:
409 + # if not a debian compatible system, just extract the kernel packages tarfile_ exists( version' , args.binary):
410 + extract_kpkgs = False
411 + if not path_in_
412 + filesystem_dir + '/etc/debian_
413 + extract_kpkgs = True
We should use os.path. join(filesystem _dir, '/etc/debian_ version' ) for path strings.
Thanks.