# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import os
+import subprocess
import shutil
import re
import tempfile
from mic import chroot, msger, rt_util
-from mic.utils import misc, fs_related, errors, runner, cmdln
+from mic.utils import misc, fs_related, errors, runner
from mic.conf import configmgr
from mic.plugin import pluginmgr
from mic.utils.partitionedfs import PartitionedMount
name = 'raw'
@classmethod
- @cmdln.option("--compress-disk-image", dest = "compress_image", type = 'choice',
- choices = ("gz", "bz2", "lzo"), default = None,
- help = "Same with --compress-image")
- @cmdln.option("--compress-image", dest = "compress_image", type = 'choice',
- choices = ("gz", "bz2", "lzo"), default = None,
- help = "Compress all raw images before package, Note: if you want "
- "to use 'lzo', package 'lzop' is needed to be installed manually.")
- @cmdln.option("--generate-bmap", action = "store_true", default = None,
- help = "also generate the block map file")
- @cmdln.option("--fstab-entry", dest = "fstab_entry", type = 'choice',
- choices = ("name", "uuid"), default = "uuid",
- help = "Set fstab entry, 'name' means using device names, "
- "'uuid' means using filesystem uuid")
- def do_create(self, subcmd, opts, *args):
+ def do_create(self, args):
"""${cmd_name}: create raw image
Usage:
${cmd_option_list}
"""
- if len(args) != 1:
- raise errors.Usage("Extra arguments given")
-
creatoropts = configmgr.create
- ksconf = args[0]
+ ksconf = args.ksfile
if creatoropts['runtime'] == "bootstrap":
configmgr._ksconf = ksconf
rt_util.bootstrap_mic()
- elif not rt_util.inbootstrap():
- try:
- fs_related.find_binary_path('mic-native')
- except errors.CreatorError:
- if not msger.ask("Subpackage \"mic-native\" has not been "
- "installed in your host system, still "
- "continue with \"native\" running mode?",
- False):
- raise errors.Abort("Abort because subpackage 'mic-native' "
- "has not been installed")
recording_pkgs = []
if len(creatoropts['record_pkgs']) > 0:
(creatoropts['pkgmgr'],
','.join(backends.keys())))
- creator = raw.RawImageCreator(creatoropts, pkgmgr, opts.compress_image,
- opts.generate_bmap, opts.fstab_entry)
+ creator = raw.RawImageCreator(creatoropts, pkgmgr, args.compress_image,
+ args.generate_bmap, args.fstab_entry)
if len(recording_pkgs) > 0:
creator._recording_pkgs = recording_pkgs
creator.install()
creator.configure(creatoropts["repomd"])
creator.copy_kernel()
+ creator.copy_attachment()
creator.unmount()
creator.generate_bmap()
creator.package(creatoropts["destdir"])
finally:
creator.cleanup()
+ #Run script of --run_script after image created
+ if creatoropts['run_script']:
+ cmd = creatoropts['run_script']
+ try:
+ runner.show(cmd)
+ except OSError,err:
+ msger.warning(str(err))
+
+
msger.info("Finished.")
return 0