initial import code into git
[platform/upstream/mic.git] / tools / micng.ref
1 #!/usr/bin/python
2
3 # Copyright (C) 2010 Intel Inc.  All rights reserved.
4 # This program is free software; it may be used, copied, modified
5 # and distributed under the terms of the GNU General Public Licence,
6 # either version 2, or version 3 (at your option).
7
8 import sys
9 import mic3.cmdln as cmdln
10 import optparse as _optparse
11
12 try:
13     import mic3.__version__
14     VERSION = mic3.__version__.version
15 except:
16     VERSION = 'unknown'
17
18 class MIC3(cmdln.Cmdln):
19     """Usage: mic [GLOBALOPTS] SUBCOMMAND [OPTS] [ARGS...]
20     or: mic help SUBCOMMAND
21
22     MeeGo Image Tool.
23     Type 'mic help <subcommand>' for help on a specific subcommand.
24
25     ${command_list}
26     ${help_list}
27     global ${option_list}
28     For additional information, see
29     * http://www.meego.com/
30     """
31
32     name = 'mic'
33     version = VERSION
34
35     @cmdln.option("-v", "--verbose", action="store_true",
36                            help="print extra information")
37
38     def get_cmd_help(self, cmdname):
39         doc = self._get_cmd_handler(cmdname).__doc__
40         doc = self._help_reindent(doc)
41         doc = self._help_preprocess(doc, cmdname)
42         doc = doc.rstrip() + '\n' # trim down trailing space
43         return self._str(doc)
44
45     """ create image """
46     @cmdln.alias('cr')
47     @cmdln.option("-c", "--config", type="string", dest="config",
48                     help="Path to kickstart config file")
49
50     @cmdln.option("-f", "--format", type="string", dest="format",
51                     help="Image format, you can specify as fs, livecd, liveusb, loop, raw, nand, mrstnand, ubi, jffs2, vdi or vmdk")
52
53     @cmdln.option("-t", "--tmpdir", type="string",
54                       dest="tmpdir",
55                       help="Temporary directory to use (default: /var/tmp)")
56     @cmdln.option("-k", "--cache", type="string",
57                       dest="cachedir", default=None,
58                       help="Cache directory to use (default: private cache)")
59     @cmdln.option("-o", "--outdir", type="string",
60                       dest="outdir", default=None,
61                       help="Output directory to use (default: current work dir)")
62     @cmdln.option("", "--release", type="string",
63                       dest="release", default=None,
64                       help="Generate a MeeGo release with all necessary files for publishing.")
65     @cmdln.option("", "--genchecksum", action="store_true",
66                       dest="genchecksum", default=False,
67                       help="Generate checksum for image file if this option is provided")
68     @cmdln.option("-P", "--prefix", type="string",
69                       dest="prefix", default=None,
70                       help="Image name prefix (default: meego)")
71     @cmdln.option("-S", "--suffix", type="string",
72                       dest="suffix", default=None,
73                       help="Image name suffix (default: date stamp)")
74     @cmdln.option("-a", "--arch", type="string",
75                       dest="arch", default=None,
76                       help="Specify target arch of image, for example: arm")
77     @cmdln.option("", "--use-comps", action="store_true",
78                       dest="use_comps", default=False,
79                       help="Use comps instead of patterns if comps exists")
80     @cmdln.option("", "--record-pkgs", type="string",
81                       dest="record_pkgs", default=None,
82                       help="Record the installed packages, valid values: name, content")
83     @cmdln.option("", "--fstype", type="string",
84                       dest="fstype", default="vfat",
85                       help="File system type for live USB file image, ext3 or vfat, the default is vfat.")
86     @cmdln.option("", "--overlay-size-mb", type="int", default=64,
87                       help="Overlay size in MB as unit, it means how size changes you can save in your live USB disk.")
88     @cmdln.option('-d', '--debug', action='store_true',
89                       help='Output debugging information')
90     @cmdln.option('-v', '--verbose', dest='verbose', action='store_true',
91                       help='Output verbose information')
92     @cmdln.option('', '--logfile', type="string", dest="file",
93                       help='Save debug information to FILE')
94     @cmdln.option("", "--save-kernel", action="store_true",
95                       dest="save_kernel", default=False,
96                       help="Save kernel image file into outdir")
97     @cmdln.option("", "--pkgmgr", type="string",
98                       help="Specify the package manager, the available package managers have zypper and yum currently.")
99     @cmdln.option("", "--volumeid", type="string", default=None,
100                       help="Specify volume id, valid only for livecd")
101     def do_create(self, subcmd, opts, *args):
102         """${cmd_name}: Create an image
103
104         This command is used to create various images, including
105         live CD, live USB, loop, raw/KVM/QEMU, VMWare/vmdk,
106         VirtualBox/vdi, Moorestown/mrstnand, jffs2 and ubi.
107
108         Examples:
109            mic create                         # create an image according to the default config
110            mic create --format=liveusb        # create a live USB image
111
112         ${cmd_usage}
113         ${cmd_option_list}
114         """
115
116         print subcmd, opts, args
117
118 if __name__ == "__main__":
119     mic = MIC3()
120     sys.exit(mic.main(sys.argv))