diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/wic/plugins/source/rawcopy.py | 29 |
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 | ||
| 5 | import logging | 5 | import logging |
| 6 | import os | 6 | import os |
| 7 | import signal | ||
| 8 | import subprocess | ||
| 7 | 9 | ||
| 8 | from wic import WicError | 10 | from wic import WicError |
| 9 | from wic.pluginbase import SourcePlugin | 11 | from 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)): |
