Merge lp:~mabac/linaro-image-tools/bug-638384-hwpackforceyes-unneeded into lp:linaro-image-tools/11.11

Proposed by Mattias Backman
Status: Merged
Merged at revision: 335
Proposed branch: lp:~mabac/linaro-image-tools/bug-638384-hwpackforceyes-unneeded
Merge into: lp:linaro-image-tools/11.11
Diff against target: 91 lines (+16/-11)
3 files modified
linaro-media-create (+9/-7)
linaro_image_tools/media_create/chroot_utils.py (+5/-2)
linaro_image_tools/media_create/tests/test_media_create.py (+2/-2)
To merge this branch: bzr merge lp:~mabac/linaro-image-tools/bug-638384-hwpackforceyes-unneeded
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) Approve
Review via email: mp+59371@code.launchpad.net

Description of the change

Hi,

This branch makes --hwpack-force-yes implied if signatures for hwpacks are passed and verification is ok.

It will only bypass the package signature checking for those hwpacks which have ok signatures passed.

The behaviour for binary-sig is not changed yet.

Thanks,

Mattias

To post a comment you must log in.
335. By Mattias Backman

Use os.path.basename() instead of split().

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

The existing code seems to cause the script to abort when the sha1sum check of any hwpack fails, but after this change I think such a failure wouldn't cause the script to abort. Is this intentional?

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

On Fri, Apr 29, 2011 at 7:51 PM, Guilherme Salgado
<email address hidden> wrote:
> The existing code seems to cause the script to abort when the sha1sum check of any hwpack fails, but after this change I think such a failure wouldn't cause the script to abort.  Is this intentional?

I think that cmd_runner makes the script abort when the return code of
sha1sums is > 0. So I think that I can remove the check from the call
to gpg also since it aborts anyway. I couldn't decide whether to do
that or leave it in to make it clear that the intention is to abort
when the verification fails. But then I should do something similar
for sha1sums to be consistent, I guess.

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

You're right, Mattias. I'd forgotten about that. I think we should do the same for the gpg check indeed, as that code will never be executed because cmd_runner.run() will raise an exception in wait() when the return code of the subprocess is non-zero, which means the print and sys.exit() calls can never be executed.

review: Approve
336. By Mattias Backman

Remove message and exit that can never be reached.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro-media-create'
--- linaro-media-create 2011-04-29 10:53:52 +0000
+++ linaro-media-create 2011-05-02 07:51:29 +0000
@@ -22,6 +22,7 @@
22import os22import os
23import sys23import sys
24import tempfile24import tempfile
25import subprocess
2526
26from linaro_image_tools import cmd_runner27from linaro_image_tools import cmd_runner
2728
@@ -104,16 +105,17 @@
104 ensure_required_commands(args)105 ensure_required_commands(args)
105106
106 sig_file_list = args.hwpacksigs[:]107 sig_file_list = args.hwpacksigs[:]
108 verified_files = []
107 if args.binarysig is not None:109 if args.binarysig is not None:
108 sig_file_list.append(args.binarysig)110 sig_file_list.append(args.binarysig)
109 for sig_file in sig_file_list:111 for sig_file in sig_file_list:
110 hash_file = sig_file[0:-len('.asc')]112 hash_file = sig_file[0:-len('.asc')]
111 if cmd_runner.run(['gpg', '--verify', sig_file]).wait() != 0:113 cmd_runner.run(['gpg', '--verify', sig_file]).wait() != 0:
112 print "Could not verify hash file signature %s." % sig_file114 sha1sums_out, _ = cmd_runner.run(['sha1sum', '-c', hash_file],
113 sys.exit(1)115 stdout=subprocess.PIPE).communicate()
114 if cmd_runner.run(['sha1sum', '-c', hash_file]).wait() != 0:116 verified_files.extend(sha1sums_out.replace(': OK', '').splitlines())
115 print "Could not verify hash in file %s." % hash_file117 for verified_file in verified_files:
116 sys.exit(1)118 print 'Hash verification of file %s OK.' % verified_file
117119
118 media = Media(args.device)120 media = Media(args.device)
119 if media.is_block_device:121 if media.is_block_device:
@@ -134,7 +136,7 @@
134 if lmc_dir == '':136 if lmc_dir == '':
135 lmc_dir = None137 lmc_dir = None
136 install_hwpacks(138 install_hwpacks(
137 ROOTFS_DIR, TMP_DIR, lmc_dir, args.hwpack_force_yes, *hwpacks)139 ROOTFS_DIR, TMP_DIR, lmc_dir, args.hwpack_force_yes, verified_files, *hwpacks)
138140
139 if args.rootfs == 'btrfs':141 if args.rootfs == 'btrfs':
140 install_packages(ROOTFS_DIR, TMP_DIR, "btrfs-tools")142 install_packages(ROOTFS_DIR, TMP_DIR, "btrfs-tools")
141143
=== modified file 'linaro_image_tools/media_create/chroot_utils.py'
--- linaro_image_tools/media_create/chroot_utils.py 2011-04-04 21:20:09 +0000
+++ linaro_image_tools/media_create/chroot_utils.py 2011-05-02 07:51:29 +0000
@@ -43,7 +43,7 @@
43 os.path.join(chroot_dir, 'usr', 'bin'))43 os.path.join(chroot_dir, 'usr', 'bin'))
4444
45def install_hwpacks(45def install_hwpacks(
46 chroot_dir, tmp_dir, tools_dir, hwpack_force_yes, *hwpack_files):46 chroot_dir, tmp_dir, tools_dir, hwpack_force_yes, verified_files, *hwpack_files):
47 """Install the given hwpacks onto the given chroot."""47 """Install the given hwpacks onto the given chroot."""
48 prepare_chroot(chroot_dir, tmp_dir)48 prepare_chroot(chroot_dir, tmp_dir)
4949
@@ -58,7 +58,10 @@
58 try:58 try:
59 mount_chroot_proc(chroot_dir)59 mount_chroot_proc(chroot_dir)
60 for hwpack_file in hwpack_files:60 for hwpack_file in hwpack_files:
61 install_hwpack(chroot_dir, hwpack_file, hwpack_force_yes)61 hwpack_verified = False
62 if os.path.basename(hwpack_file) in verified_files:
63 hwpack_verified = True
64 install_hwpack(chroot_dir, hwpack_file, hwpack_force_yes or hwpack_verified)
62 finally:65 finally:
63 run_local_atexit_funcs()66 run_local_atexit_funcs()
6467
6568
=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py 2011-04-29 11:03:10 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py 2011-05-02 07:51:29 +0000
@@ -1392,7 +1392,7 @@
1392 prefer_dir = preferred_tools_dir()1392 prefer_dir = preferred_tools_dir()
13931393
1394 install_hwpacks(1394 install_hwpacks(
1395 chroot_dir, tmp_dir, prefer_dir, force_yes, 'hwpack1.tgz',1395 chroot_dir, tmp_dir, prefer_dir, force_yes, [], 'hwpack1.tgz',
1396 'hwpack2.tgz')1396 'hwpack2.tgz')
1397 linaro_hwpack_install = find_command(1397 linaro_hwpack_install = find_command(
1398 'linaro-hwpack-install', prefer_dir=prefer_dir)1398 'linaro-hwpack-install', prefer_dir=prefer_dir)
@@ -1506,7 +1506,7 @@
1506 exception_caught = False1506 exception_caught = False
1507 try:1507 try:
1508 install_hwpacks(1508 install_hwpacks(
1509 'chroot', '/tmp/dir', preferred_tools_dir(), force_yes,1509 'chroot', '/tmp/dir', preferred_tools_dir(), force_yes, [],
1510 'hwp.tgz', 'hwp2.tgz')1510 'hwp.tgz', 'hwp2.tgz')
1511 except:1511 except:
1512 exception_caught = True1512 exception_caught = True

Subscribers

People subscribed via source and target branches