Merge lp:~salgado/linaro-image-tools/bug-814671 into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Approved by: Mattias Backman
Approved revision: 461
Merged at revision: 464
Proposed branch: lp:~salgado/linaro-image-tools/bug-814671
Merge into: lp:linaro-image-tools/11.11
Diff against target: 37 lines (+16/-0)
2 files modified
linaro_image_tools/media_create/chroot_utils.py (+15/-0)
linaro_image_tools/media_create/tests/test_media_create.py (+1/-0)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/bug-814671
Reviewer Review Type Date Requested Status
Mattias Backman (community) Approve
Review via email: mp+82454@code.launchpad.net

Description of the change

This makes lmc fail as soon as we detect we cannot run anything in the chroot. That way we can give a clearer error message. Testing this properly is rather tricky, but you can do it manually by unregistering the qemu-arm-static interpreter and then running lmc:

  sudo update-binfmts --package qemu-user-static --remove qemu-arm /usr/bin/qemu-arm-static
  linaro-media-create ...

After that you can register qemu-arm-static again by running the following:

  sudo update-binfmts --import qemu-arm

To post a comment you must log in.
Revision history for this message
Mattias Backman (mabac) wrote :

Looks good to me. A minor nitpick about the test below.

I think we're fine without unit tests for this change since it's
really straight forward. I have tested it manually according to your
instructions and it works fine.

> === modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
> --- linaro_image_tools/media_create/tests/test_media_create.py  2011-11-15 08:07:46 +0000
> +++ linaro_image_tools/media_create/tests/test_media_create.py  2011-11-16 21:17:32 +0000
> @@ -2682,6 +2682,7 @@
>             'prepare_chroot %(chroot_dir)s %(tmp_dir)s',
>             'cp %(linaro_hwpack_install)s %(chroot_dir)s/usr/bin',
>             'mount proc %(chroot_dir)s/proc -t proc',
> +            'chroot chroot_dir true',

Maybe that could be
                'chroot %(chroot_dir)s true',

just in case someone changes the chroot_dir variable?

>             'cp hwpack1.tgz %(chroot_dir)s',
>             ('%(chroot_args)s %(chroot_dir)s linaro-hwpack-install '
>              '--force-yes /hwpack1.tgz'),
>
>
>

Revision history for this message
Mattias Backman (mabac) :
review: Approve
Revision history for this message
Guilherme Salgado (salgado) wrote :

On Thu, 2011-11-17 at 11:02 +0000, Mattias Backman wrote:
> Looks good to me. A minor nitpick about the test below.
>
> I think we're fine without unit tests for this change since it's
> really straight forward. I have tested it manually according to your
> instructions and it works fine.
>
> > === modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
> > --- linaro_image_tools/media_create/tests/test_media_create.py 2011-11-15 08:07:46 +0000
> > +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-11-16 21:17:32 +0000
> > @@ -2682,6 +2682,7 @@
> > 'prepare_chroot %(chroot_dir)s %(tmp_dir)s',
> > 'cp %(linaro_hwpack_install)s %(chroot_dir)s/usr/bin',
> > 'mount proc %(chroot_dir)s/proc -t proc',
> > + 'chroot chroot_dir true',
>
> Maybe that could be
> 'chroot %(chroot_dir)s true',
>
> just in case someone changes the chroot_dir variable?

Oh, I don't even consider this a nitpick; we should hard-code as little
as possible in our tests and I should know that. Consider it done, and
thanks for the quick review. :)

Revision history for this message
Guilherme Salgado (salgado) wrote :

I'm also wondering whether or not it's a good idea to merge this before we cut the 2011.11 release. I think it may be better to wait and land it after the release as it doesn't fix any defects anyway. Opinions?

Revision history for this message
Mattias Backman (mabac) wrote :

On Thu, Nov 17, 2011 at 2:24 PM, Guilherme Salgado
<email address hidden> wrote:
> I'm also wondering whether or not it's a good idea to merge this before we cut the 2011.11 release. I think it may be better to wait and land it after the release as it doesn't fix any defects anyway. Opinions?

You're right that it isn't urgent since no one is blocked by it so we
might as well land it after the release.

> --
> https://code.launchpad.net/~salgado/linaro-image-tools/bug-814671/+merge/82454
> You are reviewing the proposed merge of lp:~salgado/linaro-image-tools/bug-814671 into lp:linaro-image-tools.
>

462. By Guilherme Salgado

Change a test to not hard-code a value

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_image_tools/media_create/chroot_utils.py'
2--- linaro_image_tools/media_create/chroot_utils.py 2011-07-25 16:48:37 +0000
3+++ linaro_image_tools/media_create/chroot_utils.py 2011-11-17 14:06:23 +0000
4@@ -57,6 +57,21 @@
5
6 try:
7 mount_chroot_proc(chroot_dir)
8+ try:
9+ # Sometimes the host will have qemu-user-static installed but
10+ # another package (i.e. scratchbox) will have mangled its config
11+ # and thus we won't be able to chroot and install the hwpack, so
12+ # we fail here and tell the user to ensure qemu-arm-static is
13+ # setup before trying again.
14+ cmd_runner.run(['true'], as_root=True, chroot=chroot_dir).wait()
15+ except:
16+ print ("Cannot proceed with hwpack installation because "
17+ "there doesn't seem to be a binfmt interpreter registered "
18+ "to execute armel binaries in the chroot. Please check "
19+ "that qemu-user-static is installed and properly "
20+ "configured before trying again.")
21+ raise
22+
23 for hwpack_file in hwpack_files:
24 hwpack_verified = False
25 if os.path.basename(hwpack_file) in verified_files:
26
27=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
28--- linaro_image_tools/media_create/tests/test_media_create.py 2011-11-17 09:03:31 +0000
29+++ linaro_image_tools/media_create/tests/test_media_create.py 2011-11-17 14:06:23 +0000
30@@ -2716,6 +2716,7 @@
31 'prepare_chroot %(chroot_dir)s %(tmp_dir)s',
32 'cp %(linaro_hwpack_install)s %(chroot_dir)s/usr/bin',
33 'mount proc %(chroot_dir)s/proc -t proc',
34+ 'chroot %(chroot_dir)s true',
35 'cp hwpack1.tgz %(chroot_dir)s',
36 ('%(chroot_args)s %(chroot_dir)s linaro-hwpack-install '
37 '--force-yes /hwpack1.tgz'),

Subscribers

People subscribed via source and target branches