[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 335: Install hwpack with --force-yes if hwpack integrity has been verified.

Message ID 20110502080413.5510.80897.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Mattias Backman May 2, 2011, 8:04 a.m.
Merge authors:
  Mattias Backman (mabac)
Related merge proposals:
  https://code.launchpad.net/~mabac/linaro-image-tools/bug-638384-hwpackforceyes-unneeded/+merge/59371
  proposed by: Mattias Backman (mabac)
  review: Approve - Guilherme Salgado (salgado)
------------------------------------------------------------
revno: 335 [merge]
committer: Mattias Backman <mattias.backman@linaro.org>
branch nick: trunk
timestamp: Mon 2011-05-02 09:59:07 +0200
message:
  Install hwpack with --force-yes if hwpack integrity has been verified.
modified:
  linaro-media-create
  linaro_image_tools/media_create/chroot_utils.py
  linaro_image_tools/media_create/tests/test_media_create.py


--
lp:linaro-image-tools
https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk

You are subscribed to branch lp:linaro-image-tools.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription

Patch

=== modified file 'linaro-media-create'
--- linaro-media-create	2011-04-29 10:53:52 +0000
+++ linaro-media-create	2011-05-02 07:59:07 +0000
@@ -22,6 +22,7 @@ 
 import os
 import sys
 import tempfile
+import subprocess
 
 from linaro_image_tools import cmd_runner
 
@@ -104,16 +105,17 @@ 
     ensure_required_commands(args)
 
     sig_file_list = args.hwpacksigs[:]
+    verified_files = []
     if args.binarysig is not None:
         sig_file_list.append(args.binarysig)
     for sig_file in sig_file_list:
         hash_file = sig_file[0:-len('.asc')]
-        if cmd_runner.run(['gpg', '--verify', sig_file]).wait() != 0:
-            print "Could not verify hash file signature %s." % sig_file
-            sys.exit(1)
-        if cmd_runner.run(['sha1sum', '-c', hash_file]).wait() != 0:
-            print "Could not verify hash in file %s." % hash_file
-            sys.exit(1)
+        cmd_runner.run(['gpg', '--verify', sig_file]).wait() != 0:
+        sha1sums_out, _ = cmd_runner.run(['sha1sum', '-c', hash_file],
+                                         stdout=subprocess.PIPE).communicate()
+        verified_files.extend(sha1sums_out.replace(': OK', '').splitlines())
+    for verified_file in verified_files:
+        print 'Hash verification of file %s OK.' % verified_file
 
     media = Media(args.device)
     if media.is_block_device:
@@ -134,7 +136,7 @@ 
     if lmc_dir == '':
         lmc_dir = None
     install_hwpacks(
-        ROOTFS_DIR, TMP_DIR, lmc_dir, args.hwpack_force_yes, *hwpacks)
+        ROOTFS_DIR, TMP_DIR, lmc_dir, args.hwpack_force_yes, verified_files, *hwpacks)
 
     if args.rootfs == 'btrfs':
         install_packages(ROOTFS_DIR, TMP_DIR, "btrfs-tools")

=== 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-04-29 11:47:02 +0000
@@ -43,7 +43,7 @@ 
                   os.path.join(chroot_dir, 'usr', 'bin'))
 
 def install_hwpacks(
-    chroot_dir, tmp_dir, tools_dir, hwpack_force_yes, *hwpack_files):
+    chroot_dir, tmp_dir, tools_dir, hwpack_force_yes, verified_files, *hwpack_files):
     """Install the given hwpacks onto the given chroot."""
     prepare_chroot(chroot_dir, tmp_dir)
 
@@ -58,7 +58,10 @@ 
     try:
         mount_chroot_proc(chroot_dir)
         for hwpack_file in hwpack_files:
-            install_hwpack(chroot_dir, hwpack_file, hwpack_force_yes)
+            hwpack_verified = False
+            if os.path.basename(hwpack_file) in verified_files:
+                hwpack_verified = True
+            install_hwpack(chroot_dir, hwpack_file, hwpack_force_yes or hwpack_verified)
     finally:
         run_local_atexit_funcs()
 

=== 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:59:07 +0000
@@ -1392,7 +1392,7 @@ 
         prefer_dir = preferred_tools_dir()
 
         install_hwpacks(
-            chroot_dir, tmp_dir, prefer_dir, force_yes, 'hwpack1.tgz',
+            chroot_dir, tmp_dir, prefer_dir, force_yes, [], 'hwpack1.tgz',
             'hwpack2.tgz')
         linaro_hwpack_install = find_command(
             'linaro-hwpack-install', prefer_dir=prefer_dir)
@@ -1506,7 +1506,7 @@ 
         exception_caught = False
         try:
             install_hwpacks(
-                'chroot', '/tmp/dir', preferred_tools_dir(), force_yes,
+                'chroot', '/tmp/dir', preferred_tools_dir(), force_yes, [],
                 'hwp.tgz', 'hwp2.tgz')
         except:
             exception_caught = True