X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fimager%2Fraw_plugin.py;h=ef537a42e5edb8a3daf81e18c2261ef996528681;hb=7db9b0c91a5b26f96a86ec10dfad261a7d781f3b;hp=636003c6dcc86ff417db5c962ebc13d327906ccd;hpb=985d3a30fce314e13215818c75f6b6b3876dceec;p=tools%2Fmic.git diff --git a/plugins/imager/raw_plugin.py b/plugins/imager/raw_plugin.py old mode 100644 new mode 100755 index 636003c..ef537a4 --- a/plugins/imager/raw_plugin.py +++ b/plugins/imager/raw_plugin.py @@ -16,12 +16,13 @@ # 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 @@ -33,20 +34,7 @@ class RawPlugin(ImagerPlugin): 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: @@ -55,25 +43,12 @@ class RawPlugin(ImagerPlugin): ${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: @@ -87,11 +62,6 @@ class RawPlugin(ImagerPlugin): configmgr._ksconf = ksconf - # Called After setting the configmgr._ksconf as the creatoropts['name'] is reset there. - if creatoropts['release'] is not None: - creatoropts['outdir'] = "%s/%s/images/%s/" % (creatoropts['outdir'], - creatoropts['release'], creatoropts['name']) - # try to find the pkgmgr pkgmgr = None backends = pluginmgr.get_plugins('backend') @@ -112,8 +82,8 @@ class RawPlugin(ImagerPlugin): (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 @@ -131,12 +101,13 @@ class RawPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() + creator.copy_attachment() creator.unmount() creator.generate_bmap() - creator.package(creatoropts["outdir"]) + creator.package(creatoropts["destdir"]) creator.create_manifest() if creatoropts['release'] is not None: - creator.release_output(ksconf, creatoropts['outdir'], creatoropts['release']) + creator.release_output(ksconf, creatoropts['destdir'], creatoropts['release']) creator.print_outimage_info() except errors.CreatorError: @@ -144,6 +115,15 @@ class RawPlugin(ImagerPlugin): 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