call copy_attachment() after configure() and move attachment files 31/160431/4
authorDohyung Kim <dohyung2.kim@samsung.com>
Wed, 15 Nov 2017 08:48:39 +0000 (17:48 +0900)
committerDohyung Kim <dohyung2.kim@samsung.com>
Fri, 26 Jan 2018 03:19:28 +0000 (03:19 +0000)
- 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 <dohyung2.kim@samsung.com>
mic/imager/baseimager.py
mic/imager/loop.py
plugins/imager/fs_plugin.py
plugins/imager/loop_plugin.py
plugins/imager/qcow_plugin.py
plugins/imager/raw_plugin.py

index 843fdd5..8f8b17d 100755 (executable)
@@ -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.
index 1e44343..fd4830c 100755 (executable)
@@ -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:
index b2701a0..a8b480b 100755 (executable)
@@ -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()
index 6034a29..8815fe4 100755 (executable)
@@ -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()
index 39dbad7..a1d808a 100755 (executable)
@@ -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()
index 1524e74..ef537a4 100755 (executable)
@@ -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"])