summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJF Ding <Jian-feng.Ding@intel.com>2011-07-21 06:07:16 +0800
committerJF Ding <Jian-feng.Ding@intel.com>2011-07-21 06:07:16 +0800
commitb49ffc03b01c4bd6429cf795ce3a50f8c5f22cbc (patch)
tree140e5c643e281ae8c4125b353b038ef4abc0d1b7 /tools
downloadmic-b49ffc03b01c4bd6429cf795ce3a50f8c5f22cbc.tar.gz
mic-b49ffc03b01c4bd6429cf795ce3a50f8c5f22cbc.tar.bz2
mic-b49ffc03b01c4bd6429cf795ce3a50f8c5f22cbc.zip
initial import code into git
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mic-image-create67
-rwxr-xr-xtools/micng35
-rwxr-xr-xtools/micng.ref120
3 files changed, 222 insertions, 0 deletions
diff --git a/tools/mic-image-create b/tools/mic-image-create
new file mode 100755
index 0000000..49bf4b4
--- /dev/null
+++ b/tools/mic-image-create
@@ -0,0 +1,67 @@
+#!/usr/bin/python -t
+
+import sys, os, os.path, string
+import micng.utils.argparse as argparse
+import micng.configmgr as configmgr
+import micng.pluginmgr as pluginmgr
+
+class Creator(object):
+ name = 'create'
+
+ def __init__(self):
+ self.configmgr = configmgr.getConfigMgr()
+ self.pluginmgr = pluginmgr.PluginMgr()
+ self.pluginmgr.loadPlugins()
+ self.plugincmds = self.pluginmgr.getPluginByCateg('imager')
+
+ def main(self, argv=None):
+# import pdb
+# pdb.set_trace()
+ if os.getuid() != 0:
+ print "Please run the program as root"
+ return 0
+ prog = os.path.basename(sys.argv[0])
+ parser = argparse.ArgumentParser(
+ usage='%s [COMMONOPT] <subcommand> [SUBOPT] ARGS' % prog,
+ )
+ parser.add_argument('-k', '--cache', dest='cache', help='cache diretory')
+ parser.add_argument('-o', '--outdir', dest='outdir', help='output diretory')
+ parser.add_argument('-t', '--tmpdir', dest='tmpdir', help='temp diretory')
+
+
+ subparsers = parser.add_subparsers(title='subcommands')
+ for subcmd, klass in self.plugincmds:
+ subcmd_help = 'create ' + subcmd + ' image'
+ subcmd_parser = subparsers.add_parser(
+ subcmd,
+ usage=prog+' [COMMONOPT] '+subcmd+' [SUBOPT] ARGS',
+ help=subcmd_help
+ )
+ if hasattr(klass, 'do_options'):
+ add_subopt = getattr(klass, 'do_options')
+ add_subopt(subcmd_parser)
+ if hasattr(klass, 'do_create'):
+ do_create = getattr(klass, 'do_create')
+ subcmd_parser.set_defaults(func=do_create)
+
+ if not argv:
+ parser.print_help()
+ return True
+
+ args = parser.parse_args(argv)
+ if args.outdir:
+ self.configmgr.setProperty('outdir', args.outdir)
+ if args.tmpdir:
+ self.configmgr.setProperty('tmpdir', args.tmpdir)
+ if args.cache:
+ self.configmgr.setProperty('cache', args.cache)
+# print 'outdir', self.configmgr.getProperty('outdir')
+# print 'tmpdir', self.configmgr.getProperty('tmpdir')
+# print 'cache', self.configmgr.getProperty('cache')
+ args.func(args)
+ return True
+
+if __name__ == "__main__":
+ create = Creator()
+ ret = create.main(sys.argv[1:])
+ sys.exit(ret)
diff --git a/tools/micng b/tools/micng
new file mode 100755
index 0000000..ea98dbd
--- /dev/null
+++ b/tools/micng
@@ -0,0 +1,35 @@
+#!/usr/bin/python -t
+
+import sys, os
+import subprocess
+import micng.utils.cmdln as cmdln
+
+class Mic(cmdln.Cmdln):
+ def run_subcmd(self, subcmd, opts, args):
+ creator = "mic-image-create"
+ tools = {
+ "cr":creator, "create":creator,
+ }
+
+ argv = [tools[subcmd]]
+ argv.extend(args)
+ subprocess.call(argv)
+
+ @cmdln.alias("cr")
+ def do_create(self, argv):
+ """${cmd_name}: create image
+
+ ${cmd_usage}
+ ${cmd_option_list}
+ """
+ self.run_subcmd("create", None, argv[1:])
+
+ @cmdln.alias("cv")
+ def do_convert(self, argv):
+ """${cmd_name}: convert an image format to another one
+ """
+
+if __name__ == "__main__":
+ mic = Mic()
+ ret = mic.main()
+ sys.exit(ret)
diff --git a/tools/micng.ref b/tools/micng.ref
new file mode 100755
index 0000000..5d2ad7b
--- /dev/null
+++ b/tools/micng.ref
@@ -0,0 +1,120 @@
+#!/usr/bin/python
+
+# Copyright (C) 2010 Intel Inc. All rights reserved.
+# This program is free software; it may be used, copied, modified
+# and distributed under the terms of the GNU General Public Licence,
+# either version 2, or version 3 (at your option).
+
+import sys
+import mic3.cmdln as cmdln
+import optparse as _optparse
+
+try:
+ import mic3.__version__
+ VERSION = mic3.__version__.version
+except:
+ VERSION = 'unknown'
+
+class MIC3(cmdln.Cmdln):
+ """Usage: mic [GLOBALOPTS] SUBCOMMAND [OPTS] [ARGS...]
+ or: mic help SUBCOMMAND
+
+ MeeGo Image Tool.
+ Type 'mic help <subcommand>' for help on a specific subcommand.
+
+ ${command_list}
+ ${help_list}
+ global ${option_list}
+ For additional information, see
+ * http://www.meego.com/
+ """
+
+ name = 'mic'
+ version = VERSION
+
+ @cmdln.option("-v", "--verbose", action="store_true",
+ help="print extra information")
+
+ def get_cmd_help(self, cmdname):
+ doc = self._get_cmd_handler(cmdname).__doc__
+ doc = self._help_reindent(doc)
+ doc = self._help_preprocess(doc, cmdname)
+ doc = doc.rstrip() + '\n' # trim down trailing space
+ return self._str(doc)
+
+ """ create image """
+ @cmdln.alias('cr')
+ @cmdln.option("-c", "--config", type="string", dest="config",
+ help="Path to kickstart config file")
+
+ @cmdln.option("-f", "--format", type="string", dest="format",
+ help="Image format, you can specify as fs, livecd, liveusb, loop, raw, nand, mrstnand, ubi, jffs2, vdi or vmdk")
+
+ @cmdln.option("-t", "--tmpdir", type="string",
+ dest="tmpdir",
+ help="Temporary directory to use (default: /var/tmp)")
+ @cmdln.option("-k", "--cache", type="string",
+ dest="cachedir", default=None,
+ help="Cache directory to use (default: private cache)")
+ @cmdln.option("-o", "--outdir", type="string",
+ dest="outdir", default=None,
+ help="Output directory to use (default: current work dir)")
+ @cmdln.option("", "--release", type="string",
+ dest="release", default=None,
+ help="Generate a MeeGo release with all necessary files for publishing.")
+ @cmdln.option("", "--genchecksum", action="store_true",
+ dest="genchecksum", default=False,
+ help="Generate checksum for image file if this option is provided")
+ @cmdln.option("-P", "--prefix", type="string",
+ dest="prefix", default=None,
+ help="Image name prefix (default: meego)")
+ @cmdln.option("-S", "--suffix", type="string",
+ dest="suffix", default=None,
+ help="Image name suffix (default: date stamp)")
+ @cmdln.option("-a", "--arch", type="string",
+ dest="arch", default=None,
+ help="Specify target arch of image, for example: arm")
+ @cmdln.option("", "--use-comps", action="store_true",
+ dest="use_comps", default=False,
+ help="Use comps instead of patterns if comps exists")
+ @cmdln.option("", "--record-pkgs", type="string",
+ dest="record_pkgs", default=None,
+ help="Record the installed packages, valid values: name, content")
+ @cmdln.option("", "--fstype", type="string",
+ dest="fstype", default="vfat",
+ help="File system type for live USB file image, ext3 or vfat, the default is vfat.")
+ @cmdln.option("", "--overlay-size-mb", type="int", default=64,
+ help="Overlay size in MB as unit, it means how size changes you can save in your live USB disk.")
+ @cmdln.option('-d', '--debug', action='store_true',
+ help='Output debugging information')
+ @cmdln.option('-v', '--verbose', dest='verbose', action='store_true',
+ help='Output verbose information')
+ @cmdln.option('', '--logfile', type="string", dest="file",
+ help='Save debug information to FILE')
+ @cmdln.option("", "--save-kernel", action="store_true",
+ dest="save_kernel", default=False,
+ help="Save kernel image file into outdir")
+ @cmdln.option("", "--pkgmgr", type="string",
+ help="Specify the package manager, the available package managers have zypper and yum currently.")
+ @cmdln.option("", "--volumeid", type="string", default=None,
+ help="Specify volume id, valid only for livecd")
+ def do_create(self, subcmd, opts, *args):
+ """${cmd_name}: Create an image
+
+ This command is used to create various images, including
+ live CD, live USB, loop, raw/KVM/QEMU, VMWare/vmdk,
+ VirtualBox/vdi, Moorestown/mrstnand, jffs2 and ubi.
+
+ Examples:
+ mic create # create an image according to the default config
+ mic create --format=liveusb # create a live USB image
+
+ ${cmd_usage}
+ ${cmd_option_list}
+ """
+
+ print subcmd, opts, args
+
+if __name__ == "__main__":
+ mic = MIC3()
+ sys.exit(mic.main(sys.argv))