From 12bbfb287cc135f9a520684e923f65dc33a1384c Mon Sep 17 00:00:00 2001 From: Fabio Berton Date: Tue, 18 Apr 2017 11:57:32 -0300 Subject: [PATCH] wic: Add option to not change fstab Create an option to wic do not change fstab file, so fstab file from base-files recipe will be the same that in final image. Change-Id: I6c023ffd32aa8966dab10ff0ecb311a08c34722c Signed-off-by: Fabio Berton Signed-off-by: Otavio Salvador --- scripts/lib/wic/creator.py | 2 ++ scripts/lib/wic/engine.py | 6 +++++- scripts/lib/wic/imager/direct.py | 9 ++++++--- scripts/lib/wic/plugins/imager/direct_plugin.py | 3 ++- scripts/wic | 5 ++++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/scripts/lib/wic/creator.py b/scripts/lib/wic/creator.py index 8f7d1503f5..3039ec67c7 100644 --- a/scripts/lib/wic/creator.py +++ b/scripts/lib/wic/creator.py @@ -70,6 +70,8 @@ class Creator(): help='Setup tmpdir as tmpfs to accelerate, experimental' ' feature, use it if you have more than 4G memory') optparser.add_option('', '--bmap', action='store_true', help='generate .bmap') + optparser.add_option('', '--no-fstab-update', action='store_true', + help='Do not change fstab file.') return optparser def postoptparse(self, options): diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index 5b104631ca..c47936c808 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py @@ -145,7 +145,7 @@ def list_source_plugins(): def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, native_sysroot, scripts_path, image_output_dir, - compressor, bmap, debug): + compressor, bmap, no_fstab_update, debug): """Create image wks_file - user-defined OE kickstart file @@ -157,6 +157,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, image_output_dir - dirname to create for image compressor - compressor utility to compress the image bmap - enable generation of .bmap + no_fstab_update - Do not change fstab file. Normally, the values for the build artifacts values are determined by 'wic -e' from the output of the 'bitbake -e' command given an @@ -192,6 +193,9 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, if bmap: cmdline.append('--bmap') + if no_fstab_update: + cmdline.append('--no-fstab-update') + crobj.main(cmdline) print("\nThe image(s) were created using OE kickstart file:\n %s" % wks_file) diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py index edf5e5d221..b9f51478c8 100644 --- a/scripts/lib/wic/imager/direct.py +++ b/scripts/lib/wic/imager/direct.py @@ -73,7 +73,7 @@ class DirectImageCreator(BaseImageCreator): def __init__(self, oe_builddir, image_output_dir, rootfs_dir, bootimg_dir, kernel_dir, native_sysroot, compressor, creatoropts=None, - bmap=False): + bmap=False, no_fstab_update=False): """ Initialize a DirectImageCreator instance. @@ -96,6 +96,7 @@ class DirectImageCreator(BaseImageCreator): self.native_sysroot = native_sysroot self.compressor = compressor self.bmap = bmap + self.no_fstab_update = no_fstab_update def __get_part_num(self, num, parts): """calculate the real partition number, accounting for partitions not @@ -260,7 +261,10 @@ class DirectImageCreator(BaseImageCreator): disk_id = disk_ids[part.disk] part.uuid = '%0x-%02d' % (disk_id, self.__get_part_num(num, parts)) - fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) + if self.no_fstab_update: + fstab_path = None + else: + fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) shutil.rmtree(self.workdir) os.mkdir(self.workdir) @@ -416,4 +420,3 @@ class DirectImageCreator(BaseImageCreator): self.__image.cleanup() except ImageError as err: msger.warning("%s" % err) - diff --git a/scripts/lib/wic/plugins/imager/direct_plugin.py b/scripts/lib/wic/plugins/imager/direct_plugin.py index 8fe3930804..0d42592215 100644 --- a/scripts/lib/wic/plugins/imager/direct_plugin.py +++ b/scripts/lib/wic/plugins/imager/direct_plugin.py @@ -87,7 +87,8 @@ class DirectPlugin(ImagerPlugin): native_sysroot, compressor, creatoropts, - opts.bmap) + opts.bmap, + opts.no_fstab_update) try: creator.create() diff --git a/scripts/wic b/scripts/wic index fe2c33f0e7..3689a6f01d 100755 --- a/scripts/wic +++ b/scripts/wic @@ -114,6 +114,8 @@ def wic_create_subcommand(args, usage_str): dest='compressor', help="compress image with specified compressor") parser.add_option("-m", "--bmap", action="store_true", help="generate .bmap") + parser.add_option("", "--no-fstab-update" ,action="store_true", + help="Do not change fstab file.") parser.add_option("-v", "--vars", dest='vars_dir', help="directory with .env files that store " "bitbake variables") @@ -244,7 +246,8 @@ def wic_create_subcommand(args, usage_str): print("Creating image(s)...\n") engine.wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, native_sysroot, scripts_path, image_output_dir, - options.compressor, options.bmap, options.debug) + options.compressor, options.bmap, options.no_fstab_update, + options.debug) def wic_list_subcommand(args, usage_str): -- 2.40.1