summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mic/imager/baseimager.py7
-rw-r--r--plugins/imager/fs_plugin.py17
-rw-r--r--plugins/imager/livecd_plugin.py16
-rw-r--r--plugins/imager/liveusb_plugin.py16
-rw-r--r--plugins/imager/loop_plugin.py16
-rw-r--r--plugins/imager/raw_plugin.py13
6 files changed, 35 insertions, 50 deletions
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py
index 55fd011..ebf99be 100644
--- a/mic/imager/baseimager.py
+++ b/mic/imager/baseimager.py
@@ -63,18 +63,21 @@ class BaseImageCreator(object):
# A pykickstart.KickstartParser instance."""
self.ks = createopts['ks']
+ self.destdir = os.path.abspath(os.path.expanduser(createopts["outdir"]))
+
# A name for the image."""
self.name = createopts['name']
if createopts['release']:
self.name += '-' + createopts['release']
+ if os.path.exists(self.destdir) and msger.ask('Image dir: %s already exists, '\
+ 'need to delete it?' % self.destdir):
+ shutil.rmtree(self.destdir, ignore_errors = True)
# The directory in which all temporary files will be created."""
self.tmpdir = createopts['tmpdir']
self.cachedir = createopts['cachedir']
- self.destdir = createopts['outdir']
-
self.target_arch = createopts['arch']
self._local_pkgs_path = createopts['local_pkgs_path']
diff --git a/plugins/imager/fs_plugin.py b/plugins/imager/fs_plugin.py
index f49cfe7..967cb54 100644
--- a/plugins/imager/fs_plugin.py
+++ b/plugins/imager/fs_plugin.py
@@ -75,15 +75,12 @@ class FsPlugin(ImagerPlugin):
if len(recording_pkgs) > 0:
creator._recording_pkgs = recording_pkgs
- destdir = os.path.abspath(os.path.expanduser(creatoropts["outdir"]))
- fsdir = os.path.join(destdir, creator.name)
-
- if not os.path.exists(destdir):
- os.makedirs(destdir)
- elif os.path.exists(fsdir):
- if msger.ask('The target dir: %s already exists, need to delete it?' % fsdir):
- import shutil
- shutil.rmtree(fsdir)
+ if creatoropts['release'] is None:
+ fsdir = os.path.join(creator.destdir, creator.name)
+ if os.path.exists(fsdir):
+ if msger.ask('The target dir: %s already exists, need to delete it?' % fsdir):
+ import shutil
+ shutil.rmtree(fsdir)
try:
creator.check_depend_tools()
@@ -99,7 +96,7 @@ class FsPlugin(ImagerPlugin):
creator.configure(creatoropts["repomd"])
creator.unmount()
- creator.package(destdir)
+ creator.package(creatoropts["outdir"])
if creatoropts['release'] is not None:
creator.release_output(ksconf, creatoropts['outdir'], creatoropts['release'])
creator.print_outimage_info()
diff --git a/plugins/imager/livecd_plugin.py b/plugins/imager/livecd_plugin.py
index 9b67cf5..43622cc 100644
--- a/plugins/imager/livecd_plugin.py
+++ b/plugins/imager/livecd_plugin.py
@@ -79,17 +79,11 @@ class LiveCDPlugin(ImagerPlugin):
if len(recording_pkgs) > 0:
creator._recording_pkgs = recording_pkgs
- destdir = os.path.abspath(os.path.expanduser(creatoropts["outdir"]))
- if creatoropts['release'] is not None:
- imagefile = "%s.img" % os.path.join(destdir, creator.name)
- else:
- imagefile = "%s.iso" % os.path.join(destdir, creator.name)
-
- if not os.path.exists(destdir):
- os.makedirs(destdir)
- elif os.path.exists(imagefile):
- if msger.ask('The target image: %s already exists, need to delete it?' % imagefile):
- os.unlink(imagefile)
+ if creatoropts['release'] is None:
+ imagefile = "%s.iso" % os.path.join(creator.destdir, creator.name)
+ if os.path.exists(imagefile):
+ if msger.ask('The target image: %s already exists, need to delete it?' % imagefile):
+ os.unlink(imagefile)
try:
creator.check_depend_tools()
diff --git a/plugins/imager/liveusb_plugin.py b/plugins/imager/liveusb_plugin.py
index a8da871..70659a0 100644
--- a/plugins/imager/liveusb_plugin.py
+++ b/plugins/imager/liveusb_plugin.py
@@ -81,17 +81,11 @@ class LiveUSBPlugin(ImagerPlugin):
if len(recording_pkgs) > 0:
creator._recording_pkgs = recording_pkgs
- destdir = os.path.abspath(os.path.expanduser(creatoropts["outdir"]))
- if creatoropts['release'] is not None:
- imagefile = "%s.img" % os.path.join(destdir, creator.name)
- else:
- imagefile = "%s.usbimg" % os.path.join(destdir, creator.name)
-
- if not os.path.exists(destdir):
- os.makedirs(destdir)
- elif os.path.exists(imagefile):
- if msger.ask('The target image: %s already exists, need to delete it?' % imagefile):
- os.unlink(imagefile)
+ if creatoropts['release'] is None:
+ imagefile = "%s.usbimg" % os.path.join(creator.destdir, creator.name)
+ if os.path.exists(imagefile):
+ if msger.ask('The target image: %s already exists, need to delete it?' % imagefile):
+ os.unlink(imagefile)
try:
creator.check_depend_tools()
diff --git a/plugins/imager/loop_plugin.py b/plugins/imager/loop_plugin.py
index 81d9ce8..96660b8 100644
--- a/plugins/imager/loop_plugin.py
+++ b/plugins/imager/loop_plugin.py
@@ -76,14 +76,14 @@ class LoopPlugin(ImagerPlugin):
if len(recording_pkgs) > 0:
creator._recording_pkgs = recording_pkgs
- destdir = os.path.abspath(os.path.expanduser(creatoropts["outdir"]))
- imagefile = "%s.img" % os.path.join(destdir, creator.name)
-
- if not os.path.exists(destdir):
- os.makedirs(destdir)
- elif os.path.exists(imagefile):
- if msger.ask('The target image: %s already exists, need to delete it?' % imagefile):
- os.unlink(imagefile)
+ if creatoropts['release'] is None:
+ if opts.taring_to:
+ imagefile = "%s.tar" % os.path.join(creator.destdir, opts.taring_to)
+ else:
+ imagefile = "%s.img" % os.path.join(creator.destdir, creator.name)
+ if os.path.exists(imagefile):
+ if msger.ask('The target image: %s already exists, need to delete it?' % imagefile):
+ os.unlink(imagefile)
try:
creator.check_depend_tools()
diff --git a/plugins/imager/raw_plugin.py b/plugins/imager/raw_plugin.py
index 0e9a3fc..6276241 100644
--- a/plugins/imager/raw_plugin.py
+++ b/plugins/imager/raw_plugin.py
@@ -78,14 +78,11 @@ class RawPlugin(ImagerPlugin):
if len(recording_pkgs) > 0:
creator._recording_pkgs = recording_pkgs
- destdir = os.path.abspath(os.path.expanduser(creatoropts["outdir"]))
- imagefile = "%s-sda.raw" % os.path.join(destdir, creator.name)
-
- if not os.path.exists(destdir):
- os.makedirs(destdir)
- elif os.path.exists(imagefile):
- if msger.ask('The target image: %s already exists, need to delete it?' % imagefile):
- os.unlink(imagefile)
+ if creatoropts['release'] is None:
+ imagefile = "%s-sda.raw" % os.path.join(creator.destdir, creator.name)
+ if os.path.exists(imagefile):
+ if msger.ask('The target image: %s already exists, need to delete it?' % imagefile):
+ os.unlink(imagefile)
try:
creator.check_depend_tools()