summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/engine.py
AgeCommit message (Collapse)Author
2021-11-21wic: use shutil.whichMingli Yu
Use shutil.which to find the executable instead to silence the below warning: $ cat tmp/work/intel_x86_64-poky-linux/core-image-base/1.0-r5/temp/log.do_image_wic [snip] DEBUG: Executing shell function do_image_wic /path/layers/oe-core/scripts/wic:27: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives from distutils import spawn INFO: Creating image(s)... [snip] [RP: Added conversion for missed function reference] Signed-off-by: Mingli Yu <mingli.yu@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-04-25wic: use Filesystem UUID when expand swap partitionLee Chee Yang
part.get("uuid") return the Partition UUID from the partition table instead of Filesystem UUID. This lead to swap partition UUID not match/change when wic write expand swap partition. change it to read the filesystem UUID using blkid. The output from blkid should looks like this: wic-partvzhiwq3s: LABEL="swap1" UUID="04e55c19-3f3f-4491-9e32-44eea8daa827" VERSION="1" TYPE="swap" USAGE="other" [YOCTO #13313] Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-03-02wic/engine: lets display an error not a tracebackArmin Kuster
If the requested partition does not exist in this request "wic ls {path}:pnum" display a nice message not a trackback Also fix displaying the pnum and not "%s" Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-03-01wic/engine: dump the partition table in JSON format onlyPierre-Jean Texier
since commit 03154d2cf25c1d5ce908da9e72d324004b8d5722 ("sfdisk: add -J between mutually exclusive options") in util-linux [1], the '-J' can't be used with the '-d' option anymore. So, since we're using json format output, drop the '-d' option. Fixes: ERROR: _exec_cmd: <snip>/usr/sbin/sfdisk -dJ <snip>/core-image-minimal-qemux86-64.wic returned '1' instead of 0 output: sfdisk: mutually exclusive arguments: --list-free --json --dump [1] - https://github.com/karelzak/util-linux/commit/03154d2cf25c1d5ce908da9e72d324004b8d5722#diff-31d5cc325380dbdafe64d0e019846f12 Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-11-27wic: 'wic cp' to copy from imageChee Yang Lee
currently 'wic cp' only works for copy file from local storage to wic image. enhance 'wic cp' to copy file/directory from wic image to local storage. include selftest and 'wic help' updates. [YOCTO#12169] Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-11-21wic: rm with -r flag supportChee Yang Lee
wic currently unable to remove non-empty directory in ext* partition. enable wic rm to remove non-empty directory and all the sub-content with -r flag. update help documents for 'wic rm'. [YOCTO #12404] Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-10-23wic/engine: use 'linux-swap' for swap file systemChee Yang Lee
[YOCTO #13312] see https://bugzilla.yoctoproject.org/show_bug.cgi?id=13312 wic/engine.Disk._get_part_image was looking at variable fstypes for supported fstype which is 'swap' but image build with 'linux-swap'. supported fstype should be 'linux-swap'. Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-06-07wic/engine: include .wks.in in wic search and listChee Yang Lee
allow wic to list and search for kickstart file in .wks.in extension. basename show by wic list images to fully exclude extension. Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-09meta/lib+scripts: Convert to SPDX license headersRichard Purdie
This adds SPDX license headers in place of the wide assortment of things currently in our script headers. We default to GPL-2.0-only except for the oeqa code where it was clearly submitted and marked as MIT on the most part or some scripts which had the "or later" GPL versioning. The patch also drops other obsolete bits of file headers where they were encoountered such as editor modelines, obsolete maintainer information or the phrase "All rights reserved" which is now obsolete and not required in copyright headers (in this case its actually confusing for licensing as all rights were not reserved). More work is needed for OE-Core but this takes care of the bulk of the scripts and meta/lib directories. The top level LICENSE files are tweaked to match the new structure and the SPDX naming. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-04-03wic/engine: Add missing newlineRichard Purdie
On some hosts the wic.Wic2.test_wic_cp_ext selftest was failing as files weren't being copied into the rootfs with "wic cp". This was due to a bug added by: http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=89d4a8df074598cfb3a76e41db7c45d845afd961 where there should be a second newline added at the end of the expression due to the difference in the way echo -e and printf behave. [YOCTO #13237] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-02-15wic/engine: Fix missing parted autobuilder failuresRichard Purdie
OE-Core rev: a88bcbae850a2e6d182291d3f8e167aabdbe4842 broke the ability to find parted as it may be in sbin which is not in PATH for some users on some distros. Iterate on the original patch to fix this and also fix the original problem. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-02-14wic/engine.py: Load paths from PATH environment variableWilliam Bourque
Load self.paths from environment variable and if it fails, fall back to hardcoded list. This is required for users that would need to load different e2fsprogs binaries if their system's ones are not recent enought Signed-off-by: William Bourque <wbourque@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-02-14scripts/lib/wic/engine: Fix cp's target path for ext* filesystemsLeonardo Augusto
Python subprocess' shell=True defaults to /bin/sh[1][2], which often refers to a POSIX-compliant shell. As the -e flag is not defined in the POSIX standard[3], some shells may interpret "-e" as the first argument to the echo command, causing the rest of the command line to fail. In this particular case, "echo -e 'cd {}'" is interpreted as "-e cd {}", which causes the first line of the command to fail, and causing cp to always place the source file in the filesystem's root. Replacing "echo -e" for a printf command makes this more portable. This issue only affects "wic cp" for ext* filesystems. [1] https://docs.python.org/2/library/subprocess.html [2] https://docs.python.org/3/library/subprocess.html [3] http://pubs.opengroup.org/onlinepubs/9699919799 Signed-off-by: Leonardo Augusto <leobsd@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-10-12wic: make engine.py:get_partitions() resilient to parted/dmidecode stderr outputGeoff Parker
Running wic commands on Debian 10 systems fail in scripts/lib/wic/engine.py:get_partitions() due to new stderr output captured when trying to parse the output from /sbin/parted as a non-root user. The parted command calls the dmidecode utility, which produces this error as a non-root user: /sys/firmware/dmi/tables/smbios_entry_point: Permission denied /dev/mem: Permission denied scripts/lib/wic/engine.py:get_partitions() calls misc.py:exec_cmd(), a subprocess wrapper which returns a combined stderr and sdtdout. These messages to stderr confuse the partition table parser in get_partitions(). This patch has the partition table parser ignore lines before the expected "BYT;" header string. Running wic in Debian 9 does not have this issue. Signed-off-by: Geoff Parker <geoffhp@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-10-10wic: Support for changing the imager.Davis, Michael
Signed-off-by: Michael Davis <michael.davis@essvote.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-07-26wic/engine: improve error reporting when using rm with wicAnuj Mittal
When trying to delete something from an ext partition using debugfs, we don't show any error to the user when that operation fails. Change this behavior to show the error generated by debugfs. Also, fallback to use rmdir in case we are trying to delete a directory. However, unlike mdeltree that is used for a FAT partition, there's no easy way to delete a non empty directory. Show an error instead when that happens so user can take appropriate action. Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2018-07-26logging: use warning instead warnChen Qi
The warn method is deprecated. We should use the documented warning instead. Quoting from the python's official doc: """ Note: There is an obsolete method warn which is functionally identical to warning. As warn is deprecated, please do not use it - use warning instead. """ Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2018-07-18wic/engine: use up all free space when expanding partitionsAnuj Mittal
Currently we just divide up the free space by the number of partitions that need to be re-sized. This leads to problems when a user has explicitly specified a subset of partitions (but not all) that need to re-sized along with the sizes. As an example, for an image with 3 partitions, if we use: wic write image.wic /dev/sdb --expand 1:10G This would lead to paritions 2 and 3 each being re-sized to one thirds of the free space instead of half. Change the behavior to use up all the free space. Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2018-07-18wic/engine: fix errors when expanding partitionsAnuj Mittal
The UEFI spec implies that GPT partitions should be assumed to be on a 2048 sector boundary (for a 512 byte sector) and the current logic just divides the free sectors available by the number of partitions that need re-sizing, which may or may not align and the final result might overshoot the limits imposed after alignment. Since we are expanding already aligned partitions, just divide up the free space in multiples of 2048. Also use the exec_cmd wrapper instead of the subprocess call directly. Fixes [YOCTO #12840] Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2018-06-04wic/engine.py: improve error message when required tools are missingAnuj Mittal
Instead of showing that command 'None' was found, show the name of actual command that wasn't found on the host machine or at the native sysroot path provided by user. Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-09-11wic: implement ext fs support for 'wic rm'Ed Bartosh
Implemented removing files or directories from the ext partition using debugfs tool. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2017-09-11wic: implement ext fs support for 'wic cp'Ed Bartosh
Implemented copying files to the ext partition using debugfs tool. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2017-09-11wic: implement ext fs support for 'wic ls'Ed Bartosh
Implemented listing directory contents for ext file system using debugfs tool. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2017-08-27wic: always read image partitionsEd Bartosh
Got rid of lazy evaluation of self.partitions property. It's not needed because partitions of the source image should be always read. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-27wic: implement 'wic write' commandEd Bartosh
This command writes image to the media or another file with the possibility to expand partitions to fill free target space. [YOCTO #11278] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-27wic: extend list of used toolsEd Bartosh
Added sfdisk, e2fsck, mkswap, resize2fs, mkdosfs to the list of used tools in Disk class. They're going to be used in 'wic write' implementation. Added dependency to util-linux to wic-tools to ensure that sfdisk and mkswap are available from wic-tools native sysroot. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-27wic: added 'fstypes' parameter to Disk.__init__Ed Bartosh
This parameter specifies list of supported filesystems. So far only 'fat' is supported, but 'wic write' is going to support at least 'fat', 'ext' and 'swap'. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-27wic: convert partition number to intEd Bartosh
Converted partition number to int in order to use it as an index in the list of partitions. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-27wic: get more info from the 'parted print' outputEd Bartosh
Got partition type and sector sizes from the output of 'parted print'. This info may be used in the implementation of 'wic write' command. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-27wic: reimplement getting paths of used toolsEd Bartosh
So far every used tool have to have separate property and private attribute in the Disk class. This is too verbose, considering that there will be much more tools used. Reimplemented getting tools paths using custom __getattr__ method. This is much more compact and readable. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-23wic: flatten directory structureEd Bartosh
Moved misc.py from wic/utils/ to wic/ Removed wic/utils directory Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2017-06-14wic: implement removing directoriesEd Bartosh
Added support for removing directories using mdeltree utility to Disk.del method [YOCTO #11283] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14wic: implement removing filesEd Bartosh
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> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14wic: add 'wic rm' commandEd Bartosh
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> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14wic: fully implement 'wic cp'Ed Bartosh
Added implementation of Disk.copy method and wic_cp function that copies files/directories to the vfat partition of the partitioned image. [YOCTO #11283] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14wic: add Disk._put_part_image methodEd Bartosh
This method copies partition image into the wic image. It will be used in 'wic cp' and 'wic rm' subcommands to copy changed partition back into wic image. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14wic: add mcopy propertyEd Bartosh
Added property that points to the mcopy executable. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14wic: add Disk._prop helperEd Bartosh
Added generic helper to use in property methods to access commands in a lazy manner. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14wic: add 'wic cp' commandEd Bartosh
Added empty 'wic cp' 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> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14engine: implement listing wic imagesEd Bartosh
Implemented 'wic ls' functionality: - list image partitions - list directory content of vfat partitions [YOCTO #11283] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14wic: add 'wic ls' commandEd Bartosh
Added empty 'wic ls' command that does nothing. The functionality will be added by the next commits. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-05-21wic: Use argparse instead of optparseAndreas J. Reichel
* optparse is deprecated and will not be developed further (see: https://docs.python.org/2/library/optparse.html) * argparse supports subcommands, which simplifies definition of arguments and options * reimplement help mechanism through sub-subcommands [YOCTO #9636] Signed-off-by: Andreas Reichel <andreas.reichel.ext@siemens.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2017-03-04wic: move PluginMgr class to pluginbaseEd Bartosh
As PluginMgr class contains only one method it's better to move it to pluginbase to have all plugin related APIs in one module. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-03-04wic: remove PluginMgr.get_source_pluginsEd Bartosh
Used get_plugins('source') instead of get_source_plugins to unify and simplify API to get plugins. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-03-04wic: use PluginMgr directlyEd Bartosh
Instead of making a singleton object of PluginMgr class it's simpler to use PluginMgr class directly as any class is a singleton. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-03-04wic: move WicError to lib/wic/__init__.pyEd Bartosh
Removed unused exceptions from error.py Moved definition of WicError to lib/wic/__init__.py Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-03-04wic: raise WicError in core modulesEd Bartosh
Replaced sys.exit with raising WicError in the core wic modules. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-03-04wic: remove msger moduleEd Bartosh
Removed custom logger module msger as it's replaced by wic logger. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-03-04wic: use wic logger in core modulesEd Bartosh
Replaced msger with wic logger in the core wic modules. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-02-15wic: remove unused argument scripts_pathEd Bartosh
There is no need to pass scripts_path from main wic module down the stack as it's not used there. Removed scripts_path argument from DirectPlugin class and wic_create function. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>