self.do_genchecksum(os.path.join(destdir, f))
def print_outimage_info(self):
- msger.info("Your new image can be found here:")
+ msg = "Your new image can be found here:\n"
self.outimage.sort()
for file in self.outimage:
- msger.raw(os.path.abspath(file))
+ msg += ' %s\n' % os.path.abspath(file)
+
+ msger.info(msg)
def check_depend_tools(self):
for tool in self._dep_checks:
usbloop.add_partition(usbimgsize/1024/1024, "/dev/sdb", "/", fstype, boot=True)
- try:
- usbloop.mount()
- except MountError, e:
- raise CreatorError("Failed mount disks : %s" % e)
+ usbloop.mount()
try:
fs_related.makedirs(usbmnt + "/LiveOS")
syslinux_path = "/usr/lib/syslinux"
else:
raise CreatorError("syslinux not installed : "
- "cannot find syslinux installation path")
+ "cannot find syslinux installation path")
for f in ("isolinux.bin", "vesamenu.c32"):
path = os.path.join(syslinux_path, f)
import stat
import shutil
-import urlgrabber.progress as progress
+from urlgrabber import progress
from mic import kickstart, msger
from mic.utils import fs_related
for p in parts:
self.__instloop.add_partition(int(p.size), p.disk, p.mountpoint, p.fstype, fsopts = p.fsopts, boot = p.active)
- try:
- self.__instloop.mount()
- except MountError, e:
- raise CreatorError("Failed mount disks : %s" % e)
-
+ self.__instloop.mount()
self._create_mkinitrd_config()
def _get_required_packages(self):
if rc != 0 and 1 == 0:
raise MountError("Unable to set bootable flag to %sp%d" % (loopdev, (bootdevnum + 1)))
-
#Ensure all data is flushed to disk before doing syslinux install
msger.run('sync', True)
ret = msger.run(args)
if ret != 0:
- raise SquashfsError("'%s' exited with error (%d)" %
- (string.join(args, " "), ret))
+ raise SquashfsError("'%s' exited with error (%d)" % (' '.join(args), ret))
def resize2fs(fs, size):
resize2fs = find_binary_path("resize2fs")
def lounsetup(self):
if self.losetup:
- rc = msger.run([self.losetupcmd, "-d", self.loopdev])
+ msger.run([self.losetupcmd, "-d", self.loopdev])
self.losetup = False
self.loopdev = None
rc = msger.run([self.losetupcmd, "-d", self.device])
self.device = None
-
-
class SparseLoopbackDisk(LoopbackDisk):
"""A Disk backed by a sparse file via the loop module."""
def __init__(self, lofile, size):
"-m", "1", "-b", str(self.blocksize),
self.disk.device]) # str(self.disk.size / self.blocksize)])
if rc != 0:
- raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device))
+ raise MountError("Error creating %s filesystem on disk %s" % (self.fstype, self.disk.device))
dev_null = os.open("/dev/null", os.O_WRONLY)
try:
if msger.run(args) != 0:
self.cowloop.cleanup()
self.imgloop.cleanup()
- raise SnapshotError("Could not create snapshot device using: " +
- string.join(args, " "))
+ raise SnapshotError("Could not create snapshot device using: " + ' '.join(args))
self.__created = True
fmt = self._makefmt(percent)
msg = fmt % ("Installing")
if msg != self.lastmsg:
- sys.stdout.write(msg)
- sys.stdout.flush()
+ msger.info(msg)
self.lastmsg = msg
if self.total_installed == self.total_actions:
- sys.stdout.write("\n")
+ msger.raw()
elif what == rpm.RPMCALLBACK_UNINST_START:
pass
cb.tsInfo = self.tsInfo
cb.filelog = False
+ msger.warning('\nCaution, do NOT interrupt the installation, else mic cannot finish the cleanup.')
ret = self.runTransaction(cb)
self._cleanupRpmdbLocks(self.conf.installroot)
return ret
creator.package(destdir)
outimage = creator.outimage
creator.print_outimage_info()
- except errors.CreatorError, e:
+ except errors.CreatorError:
raise
finally:
creator.cleanup()
cfgmgr.setProperty("ksconf", ksconf)
creatoropts = cfgmgr.create
- if creatoropts['arch'].startswith('arm'):
+ if creatoropts['arch'] and creatoropts['arch'].startswith('arm'):
msger.warning('livecd cannot support arm images, Quit')
return
# 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 == creatoropts['pkgmgr']:
pkgmgr = pcls
break
if not pkgmgr:
- raise errors.CreatorError("Can't find backend %s" % pkgmgr)
+ raise errors.CreatorError("Can't find package manager: %s" % creatoropts['pkgmgr'])
creator = livecd.LiveCDImageCreator(creatoropts, pkgmgr)
try:
creator.print_outimage_info()
outimage = creator.outimage
- except errors.CreatorError, e:
+ except errors.CreatorError:
raise
finally:
creator.cleanup()
try:
extloop.mount()
- except errors.MountError, e:
+ except errors.MountError:
extloop.cleanup()
shutil.rmtree(extmnt, ignore_errors = True)
shutil.rmtree(os_image_dir, ignore_errors = True)
- raise errors.CreatorError("Failed to loopback mount '%s' : %s" %(os_image, e))
+ raise
try:
chroot.chroot(extmnt, None, "/bin/env HOME=/root /bin/bash")
imgloop = fs_related.DiskMount(fs_related.LoopbackDisk(img, 0), imgmnt)
try:
imgloop.mount()
- except errors.MountError, e:
+ except errors.MountError:
imgloop.cleanup()
- raise errors.CreatorError("Failed to loopback mount '%s' : %s" %(img, e))
+ raise
# legacy LiveOS filesystem layout support, remove for F9 or F10
if os.path.exists(imgmnt + "/squashfs.img"):
creatoropts = cfgmgr.create
cfgmgr.setProperty("ksconf", args[0])
- if creatoropts['arch'].startswith('arm'):
+ if creatoropts['arch'] and creatoropts['arch'].startswith('arm'):
msger.warning('liveusb cannot support arm images, Quit')
return
# 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 == creatoropts['pkgmgr']:
pkgmgr = pcls
break
+ if not pkgmgr:
+ raise errors.CreatorError("Can't find package manager: %s" % creatoropts['pkgmgr'])
+
creator = liveusb.LiveUSBImageCreator(creatoropts, pkgmgr)
try:
creator.check_depend_tools()
creator.print_outimage_info()
outimage = creator.outimage
- except errors.CreatorError, e:
+ except errors.CreatorError:
raise
finally:
creator.cleanup()
try:
extloop.mount()
- except errors.MountError, e:
+ except errors.MountError:
extloop.cleanup()
shutil.rmtree(extmnt, ignore_errors = True)
- raise errors.CreatorError("Failed to loopback mount '%s' : %s" %(os_image, e))
+ raise
try:
chroot.chroot(extmnt, None, "/bin/env HOME=/root /bin/bash")
imgloop.add_partition(imgsize/1024/1024, "/dev/sdb", "/", "vfat", boot=False)
try:
imgloop.mount()
- except errors.MountError, e:
+ except errors.MountError:
imgloop.cleanup()
- raise errors.CreatorError("Failed to loopback mount '%s' : %s" %(img, e))
+ raise
# legacy LiveOS filesystem layout support, remove for F9 or F10
if os.path.exists(imgmnt + "/squashfs.img"):
# 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 == creatoropts['pkgmgr']:
pkgmgr = pcls
break
if not pkgmgr:
- raise errors.CreatorError("Can't find backend %s" % pkgmgr)
+ raise errors.CreatorError("Can't find package manager: %s" % creatoropts['pkgmgr'])
creator = loop.LoopImageCreator(creatoropts, pkgmgr)
try:
creator.configure(creatoropts["repomd"])
creator.unmount()
creator.package(creatoropts["outdir"])
- except errors.CreatorError, e:
+ except errors.CreatorError:
raise
finally:
creator.cleanup()
try:
extloop.mount()
- except errors.MountError, e:
+ except errors.MountError:
extloop.cleanup()
shutil.rmtree(extmnt, ignore_errors = True)
- raise errors.CreatorError("Failed to loopback mount '%s' : %s" %(img, e))
+ raise
try:
chroot.chroot(extmnt, None, "/bin/env HOME=/root /bin/bash")
# 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 == creatoropts['pkgmgr']:
pkgmgr = pcls
break
if not pkgmgr:
- raise errors.CreatorError("Can't find backend %s" % pkgmgr)
+ raise errors.CreatorError("Can't find package manager: %s" % creatoropts['pkgmgr'])
creator = raw.RawImageCreator(creatoropts, pkgmgr)
try:
creator.print_outimage_info()
outimage = creator.outimage
- except errors.CreatorError, e:
+ except errors.CreatorError:
raise
finally:
creator.cleanup()
try:
imgloop.mount()
- except errors.MountError, e:
+ except errors.MountError:
imgloop.cleanup()
- raise errors.CreatorError("Failed to loopback mount '%s' : %s" % (img, e))
+ raise
try:
chroot.chroot(imgmnt, None, "/bin/env HOME=/root /bin/bash")
try:
srcloop.mount()
- except errors.MountError, e:
+ except errors.MountError:
srcloop.cleanup()
- raise errors.CreatorError("Failed to loopback mount '%s' : %s" %
- (srcimg, e))
+ raise
image = os.path.join(tempfile.mkdtemp(dir = "/var/tmp", prefix = "tmp"), "target.img")
args = ['dd', "if=%s" % srcloop.partitions[0]['device'], "of=%s" % image]