summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/rootfs.py
AgeCommit message (Collapse)Author
2020-04-26wic: rootfs: Combine path_validation in one functionRicardo Ribalda Delgado
Combine all the common path validation in a function to avoid code duplication. Cc: Paul Barker <pbarker@konsulko.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-04-26wic: root: Add an opt. destination on include-pathRicardo Ribalda Delgado
Allow specifying an optional destination to include-path and make the option aware of permissions and owners. It is very useful for making a partition that contains the rootfs for a host and a target Eg: / -> Roofs for the host /export/ -> Rootfs for the target (which will netboot) Although today we support making a partition for "/export" this might not be compatible with some upgrade systems, or we might be limited by the number of partitions. With this patch we can use something like: part / --source rootfs --fstype=ext4 --include-path core-image-minimal-mtdutils export/ --include-path hello on the .wks file. Cc: Paul Barker <pbarker@konsulko.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-04-26wic: Continue if excluded_path does not existRicardo Ribalda Delgado
If an excuded path does not exist, continue without an error. This allows to seamleasly reuse .wks among different projects. Eg: part / --source rootfs --fstype=ext4 --exclude-path=opt/private_keys Where /opt/private_keys in only populated by some of the image.bb files. Cc: Paul Barker <pbarker@konsulko.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-04-26wic: Add --change-directory argumentRicardo Ribalda Delgado
This option allows to specify which part of a rootfs is going to be included, the same way the -C argument on tar. Thanks to this option we can make sure the permissions and usernames on the target partition are respected, and also simplify the creation of splitted partitons, not neeting to invoke external vars or using .wks.in files. Eg: part / --source rootfs --ondisk sda --fstype=ext4 --exclude-path=etc/    part /etc --source rootfs --fstype=ext4 --change-directory=etc Cc: Paul Barker <pbarker@konsulko.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-04-26wic: Fix permissions when using exclude or include pathRicardo Ribalda Delgado
When parameters include_path or exclude_path are passed to the rootfs plugin, it will copy the partition content into a folder and make all the modifications there. This is done using copyhardlinktree(), which does not take into consideration the content of the pseudo folder, which contains the information about the right permissions and ownership of the folders. This results in a rootfs owned by the user that is running the wic command (usually UID 1000), which makes some rootfs unbootable. This bug can be easily triggerd with the following .wks part / --source rootfs --fstype=ext4 --exclude-path=home And this sequence: $ wic create test-permissions -e core-image-minimal -o test/ $ sudo mount test/test-permissions-202004080823-sda.direct.p1 /mnt $ ls -la /mnt/etc/shadow To fix this we copy the content of the pseudo folders to the new folder and modify the pseudo database using the "pseudo -B" command. If the rootfs is not a rootfs generated by bitbake a warning is shown making the user aware that the permissions on the target might not match what he expects. WARNING: /tmp/test/../pseudo folder does not exist. Usernames and permissions will be invalid Cc: Paul Barker <pbarker@konsulko.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-04-07Revert "wic: Fix permissions when using exclude or include path"Richard Purdie
This reverts commit 36993eea89d1c011397b7692b9b8d61b499d0171. After discussion on the mailing list it was felt these changes were not ready yet.
2020-04-07Revert "wic: Add --embed-rootfs argument"Richard Purdie
This reverts commit efdcf94801f6abe8e4099e324d9a3deccd8d4384. After discussion on the mailing list it was felt these changes were not ready yet.
2020-04-06wic: Add --embed-rootfs argumentRicardo Ribalda Delgado
This option adds the content of a rootfs on a specific location on the rootfs. It is very useful for making a partition that contains the rootfs for a host and a target Eg: / -> Roofs for the host /export/ -> Rootfs for the target (which will netboot) Although today we support making a partition for "/export" this might not be compatible with some upgrade systems, or we might be limited by the number of partitions. With this patch we can use something like: part / --source rootfs --embed-rootfs target-image /export --embed-rootfs target-image2 /export2 on the .wks file. Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-04-06wic: Fix permissions when using exclude or include pathRicardo Ribalda Delgado
When parameters include_path or exclude_path are passed to the rootfs plugin, it will copy the partition content into a folder and make all the modifications there. This is done using copyhardlinktree(), which does not take into consideration the content of the pseudo folder, which contains the information about the right permissions and ownership of the folders. This results in a rootfs owned by the user that is running the wic command (usually UID 1000), which makes some rootfs unbootable. To fix this we copy the content of the pseudo folders to the new folder and modify the pseudo database using the "pseudo -B" command. Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-10wic: Add --include-path argumentPaul Barker
This option adds the contents of the given path to a partition built with the rootfs source plugin. The path is relative to the directory in which wic is running not the rootfs itself so use of an absolute path is recommended. This option is most useful when multiple copies of the rootfs are added to an image and it is required to add extra content to only one of these copies. This option only has an effect with the rootfs source plugin. Signed-off-by: Paul Barker <pbarker@konsulko.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>
2017-07-30wic: rootfs: make copied rootfs uniqueEd Bartosh
Used unique suffix (line number from .wks file) for the copied rootfs directory to avoid possible conflicts. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-07-30wic: rootfs: fix rootfs path reportingEd Bartosh
wic gets rootfs paths from partition object property 'rootfs_dir' and shows them in final report. rootfs plugin sets this property to the temporary path, which causes temporary paths appearing in the report. Changed the code to prevent storing temporary rootfs path in part.rootfs_dir. This should fix the report. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-07-30wic: use absolute paths in rootfs pluginEd Bartosh
Using relative paths can cause copyhardlinktree API to fail as it changes current directory when working. Converted all paths to absolute paths using os.path.realpath. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-23wic: code cleanupEd Bartosh
Split long lines. Removed unused imports. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
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-06wic: Remove obsolete reference to msger logger.Kristian Amlie
This was overlooked when msger was removed in 28014087b8091. Signed-off-by: Kristian Amlie <kristian.amlie@mender.io> Signed-off-by: Ross Burton <ross.burton@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 wic pluginsEd Bartosh
Replaced sys.exit with raising WicError in wic plugins. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-03-04wic: use wic logger in wic source pluginsEd Bartosh
Replaced msger with wic logger in wic source plugins. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-02-15wic: Add --exclude-path option to rootfs source plugin.Kristian Amlie
It will omit the given path from the resulting partition, and if the given path ends in a slash, it will only delete the content, and keep the directory. Since mkfs only accepts whole directories as input, we need to copy the rootfs directory to the workdir so that we can selectively delete files from it. Since we want to use the copyhardlinktree() function, we need to put the generic oe lib in the module search path. Signed-off-by: Kristian Amlie <kristian.amlie@mender.io> Signed-off-by: Ross Burton <ross.burton@intel.com>
2017-02-02wic: code cleanupEd Bartosh
Fixed indentation, unused imports, trailing lines etc. [YOCTO #10619] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2017-02-02wic: move oe/misc.py one level upEd Bartosh
Flattened directory structure: moved wic/utils/oe/misc.py -> wic/utils/misc.py [YOCTO #10619] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2016-01-17wic: get rid of get_rootfs and set_rootfsEd Bartosh
Got rid of get_rootfs and set_rootfs java-like getter and setter. Renamed rootfs to rootfs_dir to be consistent with the name of kickstart parameter --rootfs-dir. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-02wic: Refactor getting bitbake variablesEd Bartosh
Wic gets bitbake variables by parsing output of 'bitbake -e' command. This implementation improves this procedure as it runs 'bitbake -e' only when API is called and does it only once, i.e. in a "lazy" way. As parsing results are cached 'bitbake -e' is run only once and results are parsed only once per requested set of variables. get_bitbake_var became the only API call. It replaces find_artifacts, find_artifact, find_bitbake_env_lines, get_bitbake_env_lines, set_bitbake_env_lines and get_line_val calls making API much more clear. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
2015-06-23wic: Add missing docstrings to plugin classesEd Bartosh
Docstings from plugin classes are used as part of output of 'wic help plugins'. Adding them makes help page more informative. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-06-23wic: Code cleanup: bad-classmethod-argumentEd Bartosh
Fixed wrong name for the first argument in class methods. Pylint complains about the issue this way: Class method should have 'cls' as first argument Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-04-24wic: code cleanup: wildcard importsEd Bartosh
Here is what PEP8(Style Guide for Python Code) says about this: Wildcard imports (from <module> import *) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-08wic: code cleanup: unused importsEd Bartosh
Fixed pylint warning 'Unused import' Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-08-15wic: Add sourceparam param to partition plugin methodsTom Zanussi
The sourceparam param allows source plugins to be parameterized generically (via --sourceparams="key=val[,key=val], implemented previously). Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-08-11wic: Rename /mic to /wicTom Zanussi
As well as any other stray instances of mic in the codebase that can be removed. We don't really need to carry around legacy naming, and the history is in git. Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>