All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/4] wic: partition: Support valueless keys in sourceparams
@ 2022-02-14 18:12 Stefan Herbrechtsmeier
  2022-02-14 18:12 ` [PATCH v3 2/4] wic: rawcopy: Add support for packed images Stefan Herbrechtsmeier
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefan Herbrechtsmeier @ 2022-02-14 18:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Stefan Herbrechtsmeier

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Accept valueless keys in sourceparams without equals sign (=) to match
the comment and support Boolean entries.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
---

(no changes since v1)

 scripts/lib/wic/partition.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index a25834048e..09e491dd49 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -171,7 +171,7 @@ class Partition():
             # Split sourceparams string of the form key1=val1[,key2=val2,...]
             # into a dict.  Also accepts valueless keys i.e. without =
             splitted = self.sourceparams.split(',')
-            srcparams_dict = dict(par.split('=', 1) for par in splitted if par)
+            srcparams_dict = dict((par.split('=', 1) + [None])[:2] for par in splitted if par)
 
         plugin = PluginMgr.get_plugins('source')[self.source]
         plugin.do_configure_partition(self, srcparams_dict, creator,
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/4] wic: rawcopy: Add support for packed images
  2022-02-14 18:12 [PATCH v3 1/4] wic: partition: Support valueless keys in sourceparams Stefan Herbrechtsmeier
@ 2022-02-14 18:12 ` Stefan Herbrechtsmeier
  2022-02-14 18:12 ` [PATCH v3 3/4] selftest: wic: Remove requirement of syslinux from test_rawcopy_plugin Stefan Herbrechtsmeier
  2022-02-14 18:12 ` [PATCH v3 4/4] selftest: wic: Add rawcopy plugin unpack test Stefan Herbrechtsmeier
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Herbrechtsmeier @ 2022-02-14 18:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Stefan Herbrechtsmeier

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

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"

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

---

(no changes since v2)

Changes in v2:
- Reword WicError message and add compressor filename extension

 scripts/lib/wic/plugins/source/rawcopy.py | 29 ++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

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 @@
 
 import logging
 import os
+import signal
+import subprocess
 
 from wic import WicError
 from wic.pluginbase import SourcePlugin
@@ -38,6 +40,25 @@ class RawCopyPlugin(SourcePlugin):
 
         exec_cmd(cmd)
 
+    @staticmethod
+    def do_image_uncompression(src, dst, workdir):
+        def subprocess_setup():
+            # Python installs a SIGPIPE handler by default. This is usually not what
+            # non-Python subprocesses expect.
+            # SIGPIPE errors are known issues with gzip/bash
+            signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+
+        extension = os.path.splitext(src)[1]
+        decompressor = {
+            ".bz2": "bzip2",
+            ".gz": "gzip",
+            ".xz": "xz"
+        }.get(extension)
+        if not decompressor:
+            raise WicError("Not supported compressor filename extension: %s" % extension)
+        cmd = "%s -dc %s > %s" % (decompressor, src, dst)
+        subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True, cwd=workdir)
+
     @classmethod
     def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
                              oe_builddir, bootimg_dir, kernel_dir,
@@ -56,7 +77,13 @@ class RawCopyPlugin(SourcePlugin):
         if 'file' not in source_params:
             raise WicError("No file specified")
 
-        src = os.path.join(kernel_dir, source_params['file'])
+        if 'unpack' in source_params:
+            img = os.path.join(kernel_dir, source_params['file'])
+            src = os.path.join(cr_workdir, os.path.splitext(source_params['file'])[0])
+            RawCopyPlugin.do_image_uncompression(img, src, cr_workdir)
+        else:
+            src = os.path.join(kernel_dir, source_params['file'])
+
         dst = os.path.join(cr_workdir, "%s.%s" % (os.path.basename(source_params['file']), part.lineno))
 
         if not os.path.exists(os.path.dirname(dst)):
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 3/4] selftest: wic: Remove requirement of syslinux from test_rawcopy_plugin
  2022-02-14 18:12 [PATCH v3 1/4] wic: partition: Support valueless keys in sourceparams Stefan Herbrechtsmeier
  2022-02-14 18:12 ` [PATCH v3 2/4] wic: rawcopy: Add support for packed images Stefan Herbrechtsmeier
@ 2022-02-14 18:12 ` Stefan Herbrechtsmeier
  2022-02-14 18:12 ` [PATCH v3 4/4] selftest: wic: Add rawcopy plugin unpack test Stefan Herbrechtsmeier
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Herbrechtsmeier @ 2022-02-14 18:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Stefan Herbrechtsmeier

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Remove bootimg-pcbios from wks to eliminate requirement of syslinux from
test_rawcopy_plugin to avoid the following error.

ERROR: Couldn't find correct bootimg_dir, exiting

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
---

(no changes since v1)

 meta/lib/oeqa/selftest/cases/wic.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 5fc8e65142..96b3e1b6a5 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1070,10 +1070,8 @@ class Wic2(WicTestCase):
         img = 'core-image-minimal'
         machine = get_bb_var('MACHINE', img)
         with NamedTemporaryFile("w", suffix=".wks") as wks:
-            wks.writelines(['part /boot --active --source bootimg-pcbios\n',
-                            'part / --source rawcopy --sourceparams="file=%s-%s.ext4" --use-uuid\n'\
-                             % (img, machine),
-                            'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n'])
+            wks.write('part / --source rawcopy --sourceparams="file=%s-%s.ext4"\n'\
+                      % (img, machine))
             wks.flush()
             cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
             runCmd(cmd)
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 4/4] selftest: wic: Add rawcopy plugin unpack test
  2022-02-14 18:12 [PATCH v3 1/4] wic: partition: Support valueless keys in sourceparams Stefan Herbrechtsmeier
  2022-02-14 18:12 ` [PATCH v3 2/4] wic: rawcopy: Add support for packed images Stefan Herbrechtsmeier
  2022-02-14 18:12 ` [PATCH v3 3/4] selftest: wic: Remove requirement of syslinux from test_rawcopy_plugin Stefan Herbrechtsmeier
@ 2022-02-14 18:12 ` Stefan Herbrechtsmeier
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Herbrechtsmeier @ 2022-02-14 18:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Stefan Herbrechtsmeier

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

---

(no changes since v1)

 meta/lib/oeqa/selftest/cases/wic.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 96b3e1b6a5..a021f8d84b 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1065,13 +1065,14 @@ class Wic2(WicTestCase):
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, '2')
 
-    def test_rawcopy_plugin(self):
+    def _rawcopy_plugin(self, fstype):
         """Test rawcopy plugin"""
         img = 'core-image-minimal'
         machine = get_bb_var('MACHINE', img)
+        params = ',unpack' if fstype.endswith('.gz') else ''
         with NamedTemporaryFile("w", suffix=".wks") as wks:
-            wks.write('part / --source rawcopy --sourceparams="file=%s-%s.ext4"\n'\
-                      % (img, machine))
+            wks.write('part / --source rawcopy --sourceparams="file=%s-%s.%s%s"\n'\
+                      % (img, machine, fstype, params))
             wks.flush()
             cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
             runCmd(cmd)
@@ -1079,6 +1080,17 @@ class Wic2(WicTestCase):
             out = glob(self.resultdir + "%s-*direct" % wksname)
             self.assertEqual(1, len(out))
 
+    def test_rawcopy_plugin(self):
+        self._rawcopy_plugin('ext4')
+
+    def test_rawcopy_plugin_unpack(self):
+        fstype = 'ext4.gz'
+        config = 'IMAGE_FSTYPES = "%s"\n' % fstype
+        self.append_config(config)
+        self.assertEqual(0, bitbake('core-image-minimal').status)
+        self.remove_config(config)
+        self._rawcopy_plugin(fstype)
+
     def test_empty_plugin(self):
         """Test empty plugin"""
         config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_empty_plugin.wks"\n'
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-14 18:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 18:12 [PATCH v3 1/4] wic: partition: Support valueless keys in sourceparams Stefan Herbrechtsmeier
2022-02-14 18:12 ` [PATCH v3 2/4] wic: rawcopy: Add support for packed images Stefan Herbrechtsmeier
2022-02-14 18:12 ` [PATCH v3 3/4] selftest: wic: Remove requirement of syslinux from test_rawcopy_plugin Stefan Herbrechtsmeier
2022-02-14 18:12 ` [PATCH v3 4/4] selftest: wic: Add rawcopy plugin unpack test Stefan Herbrechtsmeier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.