summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2022-02-14 16:45:18 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-16 09:46:29 +0000
commit0c20edddfc2b65cc1b5e97cf7eb321cd3884b6b6 (patch)
tree93e04d2fa5f04c298fc37f94e6236d0d90f875df /scripts
parent5d16ba9078a4f90f975794a286f3845a4377cf49 (diff)
downloadpoky-0c20edddfc2b65cc1b5e97cf7eb321cd3884b6b6.tar.gz
wic: rawcopy: Add support for packed images
Add support for packed images to wic rawcopy handler do minimize disk usage in deploy directory and reuse of packed images between wic and swupdate. Add `unpack` to sourceparams to unpack an bz2, gz and xz archives. Example: part / --source rawcopy --sourceparams="file=core-image-minimal-qemu.ext4.gz,unpack" (From OE-Core rev: 4c97d25791389ece041565981ba3207ce9949a1a) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/plugins/source/rawcopy.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py
index fa7b1eb8ac..7c90cd3cf8 100644
--- a/scripts/lib/wic/plugins/source/rawcopy.py
+++ b/scripts/lib/wic/plugins/source/rawcopy.py
@@ -4,6 +4,8 @@
4 4
5import logging 5import logging
6import os 6import os
7import signal
8import subprocess
7 9
8from wic import WicError 10from wic import WicError
9from wic.pluginbase import SourcePlugin 11from wic.pluginbase import SourcePlugin
@@ -38,6 +40,25 @@ class RawCopyPlugin(SourcePlugin):
38 40
39 exec_cmd(cmd) 41 exec_cmd(cmd)
40 42
43 @staticmethod
44 def do_image_uncompression(src, dst, workdir):
45 def subprocess_setup():
46 # Python installs a SIGPIPE handler by default. This is usually not what
47 # non-Python subprocesses expect.
48 # SIGPIPE errors are known issues with gzip/bash
49 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
50
51 extension = os.path.splitext(src)[1]
52 decompressor = {
53 ".bz2": "bzip2",
54 ".gz": "gzip",
55 ".xz": "xz"
56 }.get(extension)
57 if not decompressor:
58 raise WicError("Not supported compressor filename extension: %s" % extension)
59 cmd = "%s -dc %s > %s" % (decompressor, src, dst)
60 subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True, cwd=workdir)
61
41 @classmethod 62 @classmethod
42 def do_prepare_partition(cls, part, source_params, cr, cr_workdir, 63 def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
43 oe_builddir, bootimg_dir, kernel_dir, 64 oe_builddir, bootimg_dir, kernel_dir,
@@ -56,7 +77,13 @@ class RawCopyPlugin(SourcePlugin):
56 if 'file' not in source_params: 77 if 'file' not in source_params:
57 raise WicError("No file specified") 78 raise WicError("No file specified")
58 79
59 src = os.path.join(kernel_dir, source_params['file']) 80 if 'unpack' in source_params:
81 img = os.path.join(kernel_dir, source_params['file'])
82 src = os.path.join(cr_workdir, os.path.splitext(source_params['file'])[0])
83 RawCopyPlugin.do_image_uncompression(img, src, cr_workdir)
84 else:
85 src = os.path.join(kernel_dir, source_params['file'])
86
60 dst = os.path.join(cr_workdir, "%s.%s" % (os.path.basename(source_params['file']), part.lineno)) 87 dst = os.path.join(cr_workdir, "%s.%s" % (os.path.basename(source_params['file']), part.lineno))
61 88
62 if not os.path.exists(os.path.dirname(dst)): 89 if not os.path.exists(os.path.dirname(dst)):