* [PATCH v2 0/6] #11283: wic rm
@ 2017-06-07 10:25 Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 1/6] wic: add wic_init_parser_rm Ed Bartosh
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Ed Bartosh @ 2017-06-07 10:25 UTC (permalink / raw)
To: openembedded-core
Hi,
This is an implementation of new wic subcommand 'wic rm'.
It removes files or directories from vfat partitions:
$ wic ls ./tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1
Volume in drive : is boot
Volume Serial Number is 11D0-DE21
Directory for ::/
libcom32 c32 186500 2017-06-02 15:15
libutil c32 24148 2017-06-02 15:15
syslinux cfg 209 2017-06-02 15:15
vesamenu c32 27104 2017-06-02 15:15
vmlinuz 6926384 2017-06-02 15:15
5 files 7 164 345 bytes
16 582 656 bytes free
$ wic rm ./tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1/libutil.c32
$ wic ls ./tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1
Volume in drive : is boot
Volume Serial Number is 11D0-DE21
Directory for ::/
libcom32 c32 186500 2017-06-02 15:15
syslinux cfg 209 2017-06-02 15:15
vesamenu c32 27104 2017-06-02 15:15
vmlinuz 6926384 2017-06-02 15:15
4 files 7 140 197 bytes
16 607 232 bytes free
The patchset also contains test case for 'wic rm' functionality.
Changes in v2: Modified test_wic_rm to fix test failure on Yocto autobuilder.
The following changes since commit 4a114a5ab10fc467c6c270b20af25b852250c78c:
image_types_wic: schedule prepare_wic_build correctly (2017-06-07 10:42:20 +0300)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib ed/wic/wip
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ed/wic/wip
Ed Bartosh (6):
wic: add wic_init_parser_rm
wic: add help and usage content for 'wic rm'
wic: add 'wic rm' command
wic: implement removing files
wic: implement removing directories
selftest: add test_wic_rm test case
meta/lib/oeqa/selftest/cases/wic.py | 30 +++++++++++++++++++
scripts/lib/wic/engine.py | 35 ++++++++++++++++++++++
scripts/lib/wic/help.py | 59 ++++++++++++++++++++++++++++++++++++-
scripts/wic | 20 +++++++++++++
4 files changed, 143 insertions(+), 1 deletion(-)
--
2.12.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/6] wic: add wic_init_parser_rm
2017-06-07 10:25 [PATCH v2 0/6] #11283: wic rm Ed Bartosh
@ 2017-06-07 10:25 ` Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 2/6] wic: add help and usage content for 'wic rm' Ed Bartosh
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ed Bartosh @ 2017-06-07 10:25 UTC (permalink / raw)
To: openembedded-core
Add parser for 'wic rm' subcommand.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/wic | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/wic b/scripts/wic
index 5e81fad726..fc192ec852 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -379,6 +379,12 @@ def wic_init_parser_cp(subparser):
subparser.add_argument("-n", "--native-sysroot",
help="path to the native sysroot containing the tools")
+def wic_init_parser_rm(subparser):
+ subparser.add_argument("path", type=imgpathtype,
+ help="path: <image>:<vfat partition><path>")
+ subparser.add_argument("-n", "--native-sysroot",
+ help="path to the native sysroot containing the tools")
+
def wic_init_parser_help(subparser):
helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage)
for helptopic in helptopics:
--
2.12.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/6] wic: add help and usage content for 'wic rm'
2017-06-07 10:25 [PATCH v2 0/6] #11283: wic rm Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 1/6] wic: add wic_init_parser_rm Ed Bartosh
@ 2017-06-07 10:25 ` Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 3/6] wic: add 'wic rm' command Ed Bartosh
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ed Bartosh @ 2017-06-07 10:25 UTC (permalink / raw)
To: openembedded-core
Added wic_rm_help and wic_rm_usage variables to help.py.
These variables contain help content that will be used in
'wic rm help' and 'wic rm --help' output.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/help.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index e93ac4b74c..23d943cc4c 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -395,7 +395,7 @@ DESCRIPTION
The second form of the command copies file or directory to the specified directory
on the vfat partition:
$ wic cp test tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1/efi/
- $ wic ls tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1/eti/
+ $ wic ls tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1/efi/
Volume in drive : is boot
Volume Serial Number is DB4C-FD4C
Directory for ::/efi
@@ -411,6 +411,63 @@ DESCRIPTION
containing the tools(parted and mtools) to use.
"""
+wic_rm_usage = """
+
+ Remove files or directories from the vfat partitions
+
+ usage: wic rm <image>:<vfat partition><path> [--native-sysroot <path>]
+
+ This command removes files or directories from the vfat partitions of partitioned
+ image.
+
+ See 'wic help rm' for more detailed instructions.
+
+"""
+
+wic_rm_help = """
+
+NAME
+ wic rm - remove files or directories from the vfat partitions
+
+SYNOPSIS
+ wic rm <src> <image>:<vfat partition><path>
+ wic rm <src> <image>:<vfat partition><path> --native-sysroot <path>
+
+DESCRIPTION
+ This command removes files or directories from the vfat partition of the
+ wic image:
+
+ $ wic ls ./tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1
+ Volume in drive : is boot
+ Volume Serial Number is 11D0-DE21
+ Directory for ::/
+
+ libcom32 c32 186500 2017-06-02 15:15
+ libutil c32 24148 2017-06-02 15:15
+ syslinux cfg 209 2017-06-02 15:15
+ vesamenu c32 27104 2017-06-02 15:15
+ vmlinuz 6926384 2017-06-02 15:15
+ 5 files 7 164 345 bytes
+ 16 582 656 bytes free
+
+ $ wic rm ./tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1/libutil.c32
+
+ $ wic ls ./tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic:1
+ Volume in drive : is boot
+ Volume Serial Number is 11D0-DE21
+ Directory for ::/
+
+ libcom32 c32 186500 2017-06-02 15:15
+ syslinux cfg 209 2017-06-02 15:15
+ vesamenu c32 27104 2017-06-02 15:15
+ vmlinuz 6926384 2017-06-02 15:15
+ 4 files 7 140 197 bytes
+ 16 607 232 bytes free
+
+ The -n option is used to specify the path to the native sysroot
+ containing the tools(parted and mtools) to use.
+"""
+
wic_plugins_help = """
NAME
--
2.12.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/6] wic: add 'wic rm' command
2017-06-07 10:25 [PATCH v2 0/6] #11283: wic rm Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 1/6] wic: add wic_init_parser_rm Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 2/6] wic: add help and usage content for 'wic rm' Ed Bartosh
@ 2017-06-07 10:25 ` Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 4/6] wic: implement removing files Ed Bartosh
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ed Bartosh @ 2017-06-07 10:25 UTC (permalink / raw)
To: openembedded-core
Added empty 'wic rm' command that does nothing.
The functionality will be added by the next commits.
[YOCTO #11283]
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/engine.py | 7 +++++++
scripts/wic | 14 ++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index a48c4adafb..9a8055c05c 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -340,6 +340,13 @@ def wic_cp(args, native_sysroot):
disk = Disk(args.dest.image, native_sysroot)
disk.copy(args.src, args.dest.part, args.dest.path)
+def wic_rm(args, native_sysroot):
+ """
+ Remove files or directories from the vfat partition of
+ partitioned image.
+ """
+ pass
+
def find_canned(scripts_path, file_name):
"""
Find a file either by its path or by name in the canned files dir.
diff --git a/scripts/wic b/scripts/wic
index fc192ec852..da14f4714a 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -248,6 +248,13 @@ def wic_cp_subcommand(args, usage_str):
"""
engine.wic_cp(args, args.native_sysroot)
+def wic_rm_subcommand(args, usage_str):
+ """
+ Command-line handling for removing files/dirs from images.
+ The real work is done by engine.wic_rm()
+ """
+ engine.wic_rm(args, args.native_sysroot)
+
def wic_help_subcommand(args, usage_str):
"""
Command-line handling for help subcommand to keep the current
@@ -286,6 +293,9 @@ helptopics = {
"cp": [wic_help_topic_subcommand,
wic_help_topic_usage,
hlp.wic_cp_help],
+ "rm": [wic_help_topic_subcommand,
+ wic_help_topic_usage,
+ hlp.wic_rm_help],
"list": [wic_help_topic_subcommand,
wic_help_topic_usage,
hlp.wic_list_help]
@@ -409,6 +419,10 @@ subcommands = {
hlp.wic_cp_usage,
hlp.wic_cp_help,
wic_init_parser_cp],
+ "rm": [wic_rm_subcommand,
+ hlp.wic_rm_usage,
+ hlp.wic_rm_help,
+ wic_init_parser_rm],
"help": [wic_help_subcommand,
wic_help_topic_usage,
hlp.wic_help_help,
--
2.12.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/6] wic: implement removing files
2017-06-07 10:25 [PATCH v2 0/6] #11283: wic rm Ed Bartosh
` (2 preceding siblings ...)
2017-06-07 10:25 ` [PATCH v2 3/6] wic: add 'wic rm' command Ed Bartosh
@ 2017-06-07 10:25 ` Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 5/6] wic: implement removing directories Ed Bartosh
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ed Bartosh @ 2017-06-07 10:25 UTC (permalink / raw)
To: openembedded-core
Added implementation of Disk.del method and wic_r
function that removes files from the vfat partition
using mdel utility.
[YOCTO #11283]
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/engine.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 9a8055c05c..6fc8bb72c3 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -238,6 +238,7 @@ class Disk:
self._partitions = None
self._mdir = None
self._mcopy = None
+ self._mdel = None
self._partimages = {}
# find parted
@@ -285,6 +286,10 @@ class Disk:
def mcopy(self):
return self._prop("mcopy")
+ @property
+ def mdel(self):
+ return self._prop("mdel")
+
def _get_part_image(self, pnum):
if pnum not in self.partitions:
raise WicError("Partition %s is not in the image")
@@ -318,6 +323,14 @@ class Disk:
exec_cmd(cmd)
self._put_part_image(pnum)
+ def remove(self, pnum, path):
+ """Remove files/dirs from the partition."""
+ cmd = "{} -i {} ::{}".format(self.mdel,
+ self._get_part_image(pnum),
+ path)
+ exec_cmd(cmd)
+ self._put_part_image(pnum)
+
def wic_ls(args, native_sysroot):
"""List contents of partitioned image or vfat partition."""
disk = Disk(args.path.image, native_sysroot)
@@ -345,7 +358,8 @@ def wic_rm(args, native_sysroot):
Remove files or directories from the vfat partition of
partitioned image.
"""
- pass
+ disk = Disk(args.path.image, native_sysroot)
+ disk.remove(args.path.part, args.path.path)
def find_canned(scripts_path, file_name):
"""
--
2.12.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 5/6] wic: implement removing directories
2017-06-07 10:25 [PATCH v2 0/6] #11283: wic rm Ed Bartosh
` (3 preceding siblings ...)
2017-06-07 10:25 ` [PATCH v2 4/6] wic: implement removing files Ed Bartosh
@ 2017-06-07 10:25 ` Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 6/6] selftest: add test_wic_rm test case Ed Bartosh
2017-06-07 10:31 ` ✗ patchtest: failure for #11283: wic rm (rev2) Patchwork
6 siblings, 0 replies; 8+ messages in thread
From: Ed Bartosh @ 2017-06-07 10:25 UTC (permalink / raw)
To: openembedded-core
Added support for removing directories using mdeltree
utility to Disk.del method
[YOCTO #11283]
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
scripts/lib/wic/engine.py | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 6fc8bb72c3..2c899dd386 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -239,6 +239,7 @@ class Disk:
self._mdir = None
self._mcopy = None
self._mdel = None
+ self._mdeltree = None
self._partimages = {}
# find parted
@@ -290,6 +291,10 @@ class Disk:
def mdel(self):
return self._prop("mdel")
+ @property
+ def mdeltree(self):
+ return self._prop("mdeltree")
+
def _get_part_image(self, pnum):
if pnum not in self.partitions:
raise WicError("Partition %s is not in the image")
@@ -325,10 +330,19 @@ class Disk:
def remove(self, pnum, path):
"""Remove files/dirs from the partition."""
- cmd = "{} -i {} ::{}".format(self.mdel,
- self._get_part_image(pnum),
- path)
- exec_cmd(cmd)
+ partimg = self._get_part_image(pnum)
+ cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
+ try:
+ exec_cmd(cmd)
+ except WicError as err:
+ if "not found" in str(err) or "non empty" in str(err):
+ # mdel outputs 'File ... not found' or 'directory .. non empty"
+ # try to use mdeltree as path could be a directory
+ cmd = "{} -i {} ::{}".format(self.mdeltree,
+ partimg, path)
+ exec_cmd(cmd)
+ else:
+ raise err
self._put_part_image(pnum)
def wic_ls(args, native_sysroot):
--
2.12.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 6/6] selftest: add test_wic_rm test case
2017-06-07 10:25 [PATCH v2 0/6] #11283: wic rm Ed Bartosh
` (4 preceding siblings ...)
2017-06-07 10:25 ` [PATCH v2 5/6] wic: implement removing directories Ed Bartosh
@ 2017-06-07 10:25 ` Ed Bartosh
2017-06-07 10:31 ` ✗ patchtest: failure for #11283: wic rm (rev2) Patchwork
6 siblings, 0 replies; 8+ messages in thread
From: Ed Bartosh @ 2017-06-07 10:25 UTC (permalink / raw)
To: openembedded-core
Added test case for "wic rm" functionality.
- remove file from vfat partition
- remove directory from vfat partition
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
meta/lib/oeqa/selftest/cases/wic.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index fa1a71c957..0e58a40ffc 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -891,3 +891,33 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
self.assertEqual(0, result.status)
self.assertEqual(8, len(result.output.split('\n')))
self.assertTrue(os.path.basename(testdir) in result.output)
+
+ def test_wic_rm(self):
+ """Test removing files and directories from the the wic image."""
+ self.assertEqual(0, runCmd("wic create mkefidisk "
+ "--image-name=core-image-minimal "
+ "-D -o %s" % self.resultdir).status)
+ images = glob(self.resultdir + "mkefidisk-*.direct")
+ self.assertEqual(1, len(images))
+
+ sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
+
+ # list directory content of the first partition
+ result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot))
+ self.assertEqual(0, result.status)
+ self.assertTrue('\nbzimage ' in result.output)
+ self.assertTrue('\nefi <DIR> ' in result.output)
+
+ # remove file
+ result = runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot))
+ self.assertEqual(0, result.status)
+
+ # remove directory
+ result = runCmd("wic rm %s:1/efi -n %s" % (images[0], sysroot))
+ self.assertEqual(0, result.status)
+
+ # check if they're removed
+ result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot))
+ self.assertEqual(0, result.status)
+ self.assertFalse('\nbzimage ' in result.output)
+ self.assertFalse('\nefi <DIR> ' in result.output)
--
2.12.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* ✗ patchtest: failure for #11283: wic rm (rev2)
2017-06-07 10:25 [PATCH v2 0/6] #11283: wic rm Ed Bartosh
` (5 preceding siblings ...)
2017-06-07 10:25 ` [PATCH v2 6/6] selftest: add test_wic_rm test case Ed Bartosh
@ 2017-06-07 10:31 ` Patchwork
6 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2017-06-07 10:31 UTC (permalink / raw)
To: Ed Bartosh; +Cc: openembedded-core
== Series Details ==
Series: #11283: wic rm (rev2)
Revision: 2
URL : https://patchwork.openembedded.org/series/7046/
State : failure
== Summary ==
Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:
* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at 49c255494c)
If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).
---
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-06-07 10:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-07 10:25 [PATCH v2 0/6] #11283: wic rm Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 1/6] wic: add wic_init_parser_rm Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 2/6] wic: add help and usage content for 'wic rm' Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 3/6] wic: add 'wic rm' command Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 4/6] wic: implement removing files Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 5/6] wic: implement removing directories Ed Bartosh
2017-06-07 10:25 ` [PATCH v2 6/6] selftest: add test_wic_rm test case Ed Bartosh
2017-06-07 10:31 ` ✗ patchtest: failure for #11283: wic rm (rev2) Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox