diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 517: Ensure produced files are not owned by root for Fast Models builds. Fixes #994360. Patch contribu...

Message ID 20120516071911.29159.62161.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Данило Шеган May 16, 2012, 7:19 a.m. UTC
Merge authors:
  Michael Hope (michaelh1)
Related merge proposals:
  https://code.launchpad.net/~michaelh1/linaro-image-tools/lp994360/+merge/104862
  proposed by: Michael Hope (michaelh1)
  review: Approve - Данило Шеган (danilo)
------------------------------------------------------------
revno: 517 [merge]
committer: Danilo Šegan <danilo@segan.org>
branch nick: trunk
timestamp: Wed 2012-05-16 09:17:13 +0200
message:
  Ensure produced files are not owned by root for Fast Models builds. Fixes #994360. Patch contributed by Michael Hope.
modified:
  linaro_image_tools/media_create/boards.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
diff mbox

Patch

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2012-04-24 00:14:34 +0000
+++ linaro_image_tools/media_create/boards.py	2012-05-16 07:17:13 +0000
@@ -90,6 +90,18 @@ 
     return start, end, length
 
 
+def copy_drop(src, dest_dir):
+    """Copy a file from src to destdir, dropping root ownership on the
+    way.
+    """
+    cmd = [ "cp", "-v",  src, dest_dir ]
+    cmd_runner.run(cmd, as_root=True).wait()
+
+    final = os.path.join(dest_dir, os.path.basename(src))
+    cmd = [ "chown", "%s:%s" % (os.getuid(), os.getgid()), final ]
+    cmd_runner.run(cmd, as_root=True).wait()
+
+
 class classproperty(object):
     """A descriptor that provides @property behavior on class methods."""
     def __init__(self, getter):
@@ -1354,17 +1366,12 @@ 
     def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir,
                          boot_device_or_file, k_img_data, i_img_data,
                          d_img_data):
-        logger = logging.getLogger("linaro_image_tools")
-        logger.info("WTF=%s." % boot_device_or_file )
         output_dir=os.path.dirname(boot_device_or_file)
-        cmd = [ "cp", "-v",  _get_file_matching("%s/boot/img.axf" % chroot_dir), output_dir ]
-        proc = cmd_runner.run(cmd, as_root=True)
-        proc.wait()
-        cmd = [ "cp", "-v",  k_img_data, i_img_data, d_img_data, output_dir ]
-        proc = cmd_runner.run(cmd, as_root=True)
-        proc.wait()
-        return
-
+
+        copy_drop(_get_file_matching("%s/boot/img.axf" % chroot_dir), output_dir)
+
+        for filename in (k_img_data, i_img_data, d_img_data):
+            copy_drop(filename, output_dir)
 
 class SamsungConfig(BoardConfig):
     @classproperty