[oe-commits] Maciej Borzecki : wic: add globbing support in IMAGE_BOOT_FILES entries

git at git.openembedded.org git at git.openembedded.org
Fri Dec 19 18:08:45 UTC 2014


Module: openembedded-core.git
Branch: master
Commit: 2c9635bdb97ddc80750c11d356e153a99d61cf09
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=2c9635bdb97ddc80750c11d356e153a99d61cf09

Author: Maciej Borzecki <maciej.borzecki at open-rnd.pl>
Date:   Wed Dec 10 12:45:57 2014 +0100

wic: add globbing support in IMAGE_BOOT_FILES entries

Adding glob support for entries in IMAGE_BOOT_FILES. Files picked up by
glob are by default installed under their basename, as this is likely
most common use case. Target name for globbed entries specifies the
name of directory in which files will be installed withing the partition.

Signed-off-by: Maciej Borzecki <maciej.borzecki at open-rnd.pl>
Signed-off-by: Maciek Borzecki <maciek.borzecki at gmail.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>

---

 .../lib/wic/plugins/source/bootimg-partition.py    | 41 +++++++++++++++++-----
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
index 564118a..6ba39a0 100644
--- a/scripts/lib/wic/plugins/source/bootimg-partition.py
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -29,6 +29,7 @@ import re
 from wic import msger
 from wic.pluginbase import SourcePlugin
 from wic.utils.oe.misc import *
+from glob import glob
 
 class BootimgPartitionPlugin(SourcePlugin):
     name = 'bootimg-partition'
@@ -87,7 +88,7 @@ class BootimgPartitionPlugin(SourcePlugin):
 
         # list of tuples (src_name, dst_name)
         deploy_files = []
-        for src_entry in re.findall(r'[\w;\-\./]+', boot_files):
+        for src_entry in re.findall(r'[\w;\-\./\*]+', boot_files):
             if ';' in src_entry:
                 dst_entry = tuple(src_entry.split(';'))
                 if not dst_entry[0] or not dst_entry[1]:
@@ -100,14 +101,36 @@ class BootimgPartitionPlugin(SourcePlugin):
 
         for deploy_entry in deploy_files:
             src, dst = deploy_entry
-            src_path = os.path.join(bootimg_dir, src)
-            dst_path = os.path.join(hdddir, dst)
-
-            msger.debug('Install %s as %s' % (os.path.basename(src_path),
-                                              dst_path))
-            install_cmd = "install -m 0644 -D %s %s" \
-                          % (src_path, dst_path)
-            exec_cmd(install_cmd)
+            install_task = []
+            if '*' in src:
+                # by default install files under their basename
+                entry_name_fn = os.path.basename
+                if dst != src:
+                    # unless a target name was given, then treat name
+                    # as a directory and append a basename
+                    entry_name_fn = lambda name: \
+                                    os.path.join(dst,
+                                                 os.path.basename(name))
+
+                srcs = glob(os.path.join(bootimg_dir, src))
+
+                msger.debug('Globbed sources: %s' % (', '.join(srcs)))
+                for entry in srcs:
+                    entry_dst_name = entry_name_fn(entry)
+                    install_task.append((entry,
+                                         os.path.join(hdddir,
+                                                      entry_dst_name)))
+            else:
+                install_task = [(os.path.join(bootimg_dir, src),
+                                 os.path.join(hdddir, dst))]
+
+            for task in install_task:
+                src_path, dst_path = task
+                msger.debug('Install %s as %s' % (os.path.basename(src_path),
+                                                  dst_path))
+                install_cmd = "install -m 0644 -D %s %s" \
+                              % (src_path, dst_path)
+                exec_cmd(install_cmd)
 
         msger.debug('Prepare boot partition using rootfs in %s' % (hdddir))
         part.prepare_rootfs(cr_workdir, oe_builddir, hdddir,



More information about the Openembedded-commits mailing list