self._fsopts = None
def package(self, destdir = "."):
-
- destdir = os.path.abspath(os.path.expanduser(destdir))
- if not os.path.exists(destdir):
- os.makedirs(destdir)
+ fsdir = os.path.join(destdir, self.name)
if self._recording_pkgs:
self._save_recording_pkgs(destdir)
- msger.info("Copying %s to %s ..." % (self._instroot, destdir + "/" + self.name))
-
- args = ['cp', "-af", self._instroot, destdir + "/" + self.name ]
- msger.run(args)
+ msger.info("Copying %s to %s ..." % (self._instroot, fsdir))
+ msger.run(['cp', "-af", self._instroot, fsdir])
- ignores = ["/dev/fd", "/dev/stdin", "/dev/stdout", "/dev/stderr", "/etc/mtab"]
- for exclude in ignores:
- if os.path.exists(destdir + "/" + self.name + exclude):
- os.unlink(destdir + "/" + self.name + exclude)
+ for exclude in ["/dev/fd", "/dev/stdin", "/dev/stdout", "/dev/stderr", "/etc/mtab"]:
+ if os.path.exists(fsdir + exclude):
+ os.unlink(fsdir + exclude)
- self.outimage.append(destdir + "/" + self.name)
+ self.outimage.append(fsdir)
'normal': 1,
'verbose': 2,
'debug': 3,
+ 'never': 4,
}
LOG_LEVEL = 1
head = head.lstrip()
newline = True
- if msg:
+ if msg is not None:
stream.write('%s%s' % (head, msg))
if newline:
stream.write('\n')
sys.exit(1)
def ask(msg, default=True):
- _color_print('Q', ASK_COLOR, '')
+ _color_print('\rQ', ASK_COLOR, '')
try:
if default:
msg += '(Y/n) '
def pause(msg=None):
if INTERACTIVE:
- _color_print('Q', ASK_COLOR, '')
- if not msg:
+ _color_print('\rQ', ASK_COLOR, '')
+ if msg is None:
msg = 'press <ENTER> to continue ...'
raw_input(msg)
# with the express permission of Red Hat, Inc.
#
+import os
+
from mic import configmgr, pluginmgr, chroot, msger
from mic.utils import cmdln, errors
from mic.imager import fs
# try to find the pkgmgr
pkgmgr = None
- plgmgr = pluginmgr.PluginMgr()
- for (key, pcls) in plgmgr.get_plugins('backend').iteritems():
+ for (key, pcls) in pluginmgr.PluginMgr().get_plugins('backend').iteritems():
if key == createopts['pkgmgr']:
pkgmgr = pcls
break
raise CreatorError("Can't find backend plugin: %s" % createopts['pkgmgr'])
creator = fs.FsImageCreator(createopts, pkgmgr)
+
+ destdir = os.path.abspath(os.path.expanduser(createopts["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)
+
try:
creator.check_depend_tools()
creator.mount(None, createopts["cachedir"])
creator.configure(createopts["repomd"])
creator.unmount()
- creator.package(createopts["outdir"])
+ creator.package(destdir)
outimage = creator.outimage
creator.print_outimage_info()
except errors.CreatorError, e: