From 7db9b0c91a5b26f96a86ec10dfad261a7d781f3b Mon Sep 17 00:00:00 2001 From: Dohyung Kim Date: Wed, 15 Nov 2017 17:48:39 +0900 Subject: [PATCH] call copy_attachment() after configure() and move attachment files - Call BaseImager.copy_attachment() after BaseImager.configure() Post scripts on configure() cannot access attachment files which come from install_root. So call copy_attachment() after running post scripts. - Move attachment files not copy. If copying attachment files from install_root, then attachment files remain in install_root. So use mv instead of cp for deduplication. Change-Id: Ie7a1d516331e29eaba975bc186b9644b96c17fbc Signed-off-by: Dohyung Kim --- mic/imager/baseimager.py | 2 +- mic/imager/loop.py | 6 +++--- plugins/imager/fs_plugin.py | 1 + plugins/imager/loop_plugin.py | 1 + plugins/imager/qcow_plugin.py | 1 + plugins/imager/raw_plugin.py | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 843fdd5..8f8b17d 100755 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -1153,7 +1153,7 @@ class BaseImageCreator(object): pass def postinstall(self): - self.copy_attachment() + pass def _get_sign_scripts_env(self): """Return an environment dict for %post-umount scripts. diff --git a/mic/imager/loop.py b/mic/imager/loop.py index 1e44343..fd4830c 100755 --- a/mic/imager/loop.py +++ b/mic/imager/loop.py @@ -497,13 +497,13 @@ class LoopImageCreator(BaseImageCreator): self._check_imgdir() - msger.info("Copying attachment files...") + msger.info("Moving attachment files...") for item in self._attachment: if not os.path.exists(item): continue dpath = os.path.join(self._imgdir, os.path.basename(item)) - msger.verbose("Copy attachment %s to %s" % (item, dpath)) - shutil.copy(item, dpath) + msger.verbose("Move attachment %s to %s" % (item, dpath)) + shutil.move(item, dpath) def create_manifest(self): if self.compress_image: diff --git a/plugins/imager/fs_plugin.py b/plugins/imager/fs_plugin.py index b2701a0..a8b480b 100755 --- a/plugins/imager/fs_plugin.py +++ b/plugins/imager/fs_plugin.py @@ -103,6 +103,7 @@ class FsPlugin(ImagerPlugin): creator.configure(creatoropts["repomd"]) creator.copy_kernel() + creator.copy_attachment() creator.unmount() creator.package(creatoropts["destdir"]) creator.create_manifest() diff --git a/plugins/imager/loop_plugin.py b/plugins/imager/loop_plugin.py index 6034a29..8815fe4 100755 --- a/plugins/imager/loop_plugin.py +++ b/plugins/imager/loop_plugin.py @@ -103,6 +103,7 @@ class LoopPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() + creator.copy_attachment() creator.create_cpio_image() creator.unmount() creator.copy_cpio_image() diff --git a/plugins/imager/qcow_plugin.py b/plugins/imager/qcow_plugin.py index 39dbad7..a1d808a 100755 --- a/plugins/imager/qcow_plugin.py +++ b/plugins/imager/qcow_plugin.py @@ -134,6 +134,7 @@ class QcowPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() + creator.copy_attachment() creator.create_cpio_image() creator.unmount() creator.copy_cpio_image() diff --git a/plugins/imager/raw_plugin.py b/plugins/imager/raw_plugin.py index 1524e74..ef537a4 100755 --- a/plugins/imager/raw_plugin.py +++ b/plugins/imager/raw_plugin.py @@ -101,6 +101,7 @@ class RawPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() + creator.copy_attachment() creator.unmount() creator.generate_bmap() creator.package(creatoropts["destdir"]) -- 2.7.4