aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/imager
AgeCommit message (Collapse)Author
2016-11-06wic: call os.ftruncate instead of running truncateEd Bartosh
Replaced running of truncate utility with the standard library call os.ftruncate (From OE-Core rev: 1ba6101ceaee354816e690d44bc9a5dd8dcf4011) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-10-07wic: rewrite MBR disk identifierEd Bartosh
Disk identifier created by parted doesn't match the one we generated and used in bootloader config. We need to rewrite it to make our image bootable. Modified involved API and data structures to access previously generated disk identifiers after MBR is initialized. Written disk identifiers to MBR. (From OE-Core rev: 221d3bdd6e0ab8a4d25e2c96bd976cbec4e76681) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-10-07wic: generate PARTUUID for MDOS partitionsEd Bartosh
Added generation of partition UUIDs for MSDOS partitions. UUID for MSDOS partitions is <disk identifier>-<partition number>, where disk identifier is a random 4 bytes long number. It's usually generated when MBR/partition table is initialized. As UUID is used to point to the root partition in bootloader config we need to generate it before the MBR is initialized. After MBR is created we need to rewrite system identifier to match it with what is used in bootloader config. This will be implemented in the next commit. (From OE-Core rev: 6ecc6addf4080eda75a15af077816c81c6bf70a5) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-19wic: implement --bmap optionEd Bartosh
This option enables generation of <image>.bmap file for the result image using native bmaptool. [YOCTO #9413] (From OE-Core rev: d64c7b37c40b052510419b4d6629b83319c833e4) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-14wic: use new syntax of 'except' statementEd Bartosh
New syntax 'except Exception as err' is supported by Python >= 2.7. Old syntax 'except Exception, err' is not supported by Python 3. Used new syntax to be able to run wic on Python 3. [YOCTO #9412] (From OE-Core rev: 15e88714d6b0a93f72e8a19b083fcc1f2006e128) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-14wic: remove with_statement importsEd Bartosh
'with' statement is not used in baseimager.py It's supported by Python 2.7, which is included into all target distros. Other wic modules use this statement. Removed useless 'from __future__ import with_statement' from wic code. (From OE-Core rev: 528a1f20939589949831efbb4de6336776efe7d5) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-14wic: don't inherit classes from objectEd Bartosh
All classes in Python3 are new style classes and don't need to be inherited from object. Wic code works fine without this inheritance even with Python2, so it's harmless to remove it. [YOCTO #9412] (From OE-Core rev: a146b03ee7d0aa5bc1722da5977a5952782b69bf) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-14wic: don't use dict.keys and dict.has_keyEd Bartosh
Replaced calls of dict.keys and dict.has_key methods with the 'key in dict' statement. 'key in dict' is more pythonic, faster and readable. dict.has_key doesn't exist in Python 3. [YOCTO #9412] (From OE-Core rev: 003df7dfb932c551953fbf1bd769b3c31bd16fb4) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-06wic: moved DiskImage to direct.pyEd Bartosh
Moved DiskImage class from utils/fs_related.py to imager/direct.py as it's only used there. Removed fs_related module as it doesn't contain anything except of DiskImage. (From OE-Core rev: b3cc471790784c28f9362fcd6fc6a81c4316754c) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-04-29wic: add system_id argument to Image.add_partitionEd Bartosh
Added new argument to add_partition call to pass partition system id down the stack. [YOCTO #9096] (From OE-Core rev: f2733df697192c0010c17b7bbb02f8679cb8f313) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-20wic: do not remove build dir in source pluginsEd Bartosh
Interesting bug was found during implementation of 'include' parser command. Build directory was removed in do_configure_partition method of bootimg- source plugins. This can cause removal of previously prepared partition images if /boot partition is mentioned after other partitions in .ks file. Moved work directory removal to direct.py before processing partitions. (From OE-Core rev: ba98262573cf1600e0d477317f51d488b5f8c4bd) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-18wic: get rid of 2 gettersEd Bartosh
Used partitions and configfile bootloader attributes instead of using getters get_bootloader_file and get_partitions. (From OE-Core rev: d34dd190e1da00ca8c9b2cb0adba15b9f0de2920) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-18wic: 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. (From OE-Core rev: 51ec52a62ce49d1a1a83489379990f78cfe849f9) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-18wic: adjust code for new data structureEd Bartosh
New data structure is less nested than old one. Adjusted bootloader and partitions fields: self.ks.handler.bootloader -> self.ks.bootoader self.ks.handler.partitions -> self.ks.partitions (From OE-Core rev: b46da0731e3f7016d0ab2a67967f07c7e199f219) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-18wic: use new kickstart parserEd Bartosh
Used KickStart parser class instead of pykickstart API. This commit breaks wic as data structures and field names provided by new API are a bit different from old ones. This issue will be addressed in the following commits. (From OE-Core rev: f72439d321220b724bfe2b4a92fed46c2c19fb3f) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-23wic: fix partition size calculationEd Bartosh
It was wrongly assumed that part.size is meagured in Mb. In fact it's in Kb, so there is no need to convert bitbake variable ROOTFS_SIZE as it's also in Kb. (From OE-Core rev: 3703ecb4aa5267e6d7330e7978cc7c3bb2250ead) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-09wic: round variable before converting to intEd Bartosh
Wic uses bitbake variable ROOTFS_SIZE to set correspondent partition size. This variable is a literal representing float value. Wic crashes trying to convert it to int with the error: invalid literal for int() with base 10: '10166.0' Fixed this by converting variable to float and rounding result. This should work for int and float literals. (From OE-Core rev: 3479e299b5f11dfcd3f5f97c4ad3e0449f6c6d6a) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-03wic: fix short variable namesEd Bartosh
Made short variable names longer and more readable. Fixed pylint warnings "Invalid variable name" and "Invalid argument name". (From OE-Core rev: 872cb0d5d79b26f34e6b35d7be8870d245021be4) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-03wic: fix pylint warning redefined-builtinEd Bartosh
Renamed variables named as Python builtin functions. (From OE-Core rev: bed98142e3e47ac2862ccf8fe3e4bdeabfc91172) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-03wic: fix pylint warning unused-variableEd Bartosh
Removed or reworked code with unused variables. (From OE-Core rev: 3644b9f5ca25dfc61d4f5eda0f073c8a879b492b) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-30wic: use bitbake variable ROOTFS_SIZEEd Bartosh
If bitbake image is referenced in .ks file and --size is not used there wic uses ROOTFS_SIZE variable to set minimum partition size. ROOTFS_SIZE is calculated in meta/lib/oe/image.py when rootfs is created. The calculation is done using other image parameters: IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT, IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE. (From OE-Core rev: 173d440c14ee3140ae08c6a87decc9b2f4c9e391) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-02wic: Code cleanup: unused importsEd Bartosh
Fixed pylint warning unused-import (From OE-Core rev: e77fda5fb6cb0a35308e4620ca4602715a471fbe) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-02wic: Code cleanup: long lines, identation and whitespacesEd Bartosh
Fixed pylint warnings bad-continuation, bad-continuation and line-too-long. (From OE-Core rev: db43e59f41b6bc19152cd4743585a3217015e272) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-02wic: Refactor fstab update codeEd Bartosh
Made the code to backup and restore fstab only if it's modified. Cleaned up the code. Made it more pythonic. Improved code readability by moving code from several tiny methods into one place. (From OE-Core rev: e663b1857fd2975585003bfa4739f8f84c652708) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-02wic: Include mount point into image reportEd Bartosh
Wic doesn't show any information for the partition if label is not set. Fixed this by adding mount point to the report. (From OE-Core rev: 36be9c1f7a6fded146a6f1c268455d826d78f97b) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-06-27wic: Implement image compressingEd Bartosh
Implemented compressing result image with specified compressor. Updated reporting code to show compressed image. [YOCTO #7593] (From OE-Core rev: 31791fa7a168e6b6fb030aeb338c8233b4735af1) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-06-27wic: Add new argument to direct pluginEd Bartosh
Added 'compressor' argument to Direct plugin API to pass a name of compressor utility. (From OE-Core rev: 34c583274c2908351e3a84dd629302f1975f2f0d) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-06-11wic: Add parameter 'uuid' to Image.add_partition methodEd Bartosh
With this parameter it's possible to pass generated UUID into Image class to set it for partition when it's created. (From OE-Core rev: e4bc71fa78b0d7a60aa85b8eb09a053545b61b84) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-06-11wic: Refactored getting root device nameEd Bartosh
Replaced DirectImageCreator._get_boot_config private method with a 'rootdev' property. Simplified the code and API. Used 'uuid' property instead of incorrectly used 'part_type'. (From OE-Core rev: 4a303007149ea1205bbd454e70810e7dfa343d4c) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-06-11wic: Make _ptable_format publicEd Bartosh
Names with one leasding underscore considered protected in Python. _ptable_format is accessed outside of its class. Made it public by removing underscore. This pylint warning should be fixed now: Access to a protected member _ptable_format of a client class (From OE-Core rev: 72599b5500ebdd0c418a0ef1e2c93c833bd31d75) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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. (From OE-Core rev: 13416c1941f5dc8abcdb0073f2104a89eae2d6f1) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-14wic: use native partedEd Bartosh
Used exec_native_cmd instead of find_binary_path to run parted. Got rid of find_binary_path as it's not used anywhere else. There are several tools wic is trying to find not only in sysroot, but also in host root. Parted is a special as on some distros it's installed in /usr/sbin, which is not in the user's PATH. This makes wic to fail with error "External command 'parted' not found, exiting." [YOCTO #7122] (From OE-Core rev: 76adf38c0d8e0faf04a5ecb3fcfbe831c85bb81f) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-13wic:code cleanup: No space allowedEd Bartosh
Fixed pylint warning 'No space allowed around keyword argument assignment' (From OE-Core rev: e07dd9b9c71960fbeded162ed52fbce06de620e9) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-09wic: code cleanup: unused importsEd Bartosh
Fixed pylint warning 'Unused import' (From OE-Core rev: dfde8bdae3ae151ffed5777b920d24c774e5da2c) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-03-10wic: fix fstab generationAlexandre Belloni
Commit 0a6668f6e60b4195ff4163c00fc972bacdb27b4b still included some debug and is not working properly as the new fstab is generated too late. (From OE-Core rev: eea80d25c0902bb16ed3425888857d3cc5486376) Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-02-14wic: remove useless calls to __write_fstabAlexandre Belloni
__write_fstab() is already iterating over parts. There is now need to call it fort each parts. (From OE-Core rev: 0a6668f6e60b4195ff4163c00fc972bacdb27b4b) Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-02-14wic: allow creation of partitions not in tableAlexandre Belloni
For some architectures it is necessary to reserve space on disk without it being present in the partition table. For example, u-boot on i.mx is placed at an offset of 1kB on the sdcard. While it would be possible to create a partition at that offset and place u-boot there, it would then be necessary to update the default u-boot environment to use partition 2 on the mmc instead of partition 1. (From OE-Core rev: 233b631ece5ee14d057932c146327065064b5196) Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-12-25wic: account for mmcblk device partition namingMaciej Borzecki
MMC block device partitions are named differently than other block devices and use the scheme: mmcblk<devnum>p<partnum>, ex: mmcblk0p1, mmcblk0p2. The current code generates incorrect parition names missing 'p' infix for fstab entries. The patch resolves this problem. (From OE-Core rev: e2664f563921467fe38bb74f4dd2a41eb004ee9f) Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl> Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-11-12scripts: use '/usr/bin/env' in shebangs with pythonMartin Hundebøll
To support yocto on systems with python3 as default version, scripts should use /usr/bin/env python in the shebang, as this allows the use of a fake env to mimic python2 as default version. This patch simply replaces occurrences of #!/usr/bin/python with #!/usr/bin/env python and was done with this oneliner: git grep -lE '^#!/usr/bin/python' | xargs \ sed -i 's|/usr/bin/python|/usr/bin/env python|' (From OE-Core rev: 6d3de22a19657a413e01d7bb5fd74d16c00dc696) Signed-off-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-10-30wic: Remove special-case bootimg_dirTom Zanussi
The first iterations of wic very shortsightedly catered to two specific use-cases and added special-purpose params for those cases so that they could be directly given their corresponding boot artifacts. (hdddir and staging_data_dir). As more use-cases are added, it becomes rather obvious that such a scheme doens't scale, and additionally causes confusion for plugin writers. This removes those special cases and states explicitly in the help text that plugins are responsible for locating their own boot artifacts. (From OE-Core rev: 6ba3eb5ff7c47aee6b3419fb3a348a634fe74ac9) 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. (From OE-Core rev: 598b120406dc1d2b7e377bd1ab6f0acbef034b22) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>