update README.rst
[platform/upstream/mic.git] / README.rst
1 =====
2  mic
3 =====
4
5 Overview
6 ========
7 MIC means Image Creator and it's used to create images for Tizen. The tool offers three major functions:
8
9 - image creation
10 - image conversion
11 - chrooting into an image
12
13 The tool is derived mainly from MIC2, which is used to create MeeGo images. With great improvements on many features, it has become clear, friendly, and flexible. It provides a python plugin mechanism for developers, to expand image type or image options, and even to hook.
14
15 With the MIC tool, users can create different types of images for different verticals, including live CD images, live USB images, raw images for KVM, loop images for IVI platforms, and fs images for chrooting. Also, users can work in a chroot environment, based on an existing live image using MIC's enhanced chrooting. Besides, MIC enables transforming an image to another image format, a very useful function for those sensitive to image format.
16
17 Installation
18 ============
19 MIC runs natively in many mainstream Linux distributions, including:
20
21 - Ubuntu (LTS and one latest non-LTS version --- 12.04 and 11.10)
22 - openSUSE (the latest version --- 12.1)
23 - Fedora (the latest version --- 17)
24
25 Binary Installation
26 -------------------
27
28 To install the MIC package, get the corresponding repository at:
29 http://download.tizen.org/tools/
30
31 If none of the distributions available in the list are the one you want, install MIC from source code.
32
33 Ubuntu Installation
34 ~~~~~~~~~~~~~~~~~~~~~~~~~~
35 1. Append repository  source:
36 ::
37
38   $ sudo vi /etc/apt/sources.list
39
40 Append the following line:
41
42 for Ubuntu 12.04:
43 ::
44
45  deb  http://download.tizen.org/tools/xUbuntu_12.04/
46
47 for Ubuntu11.10:
48 ::
49
50  deb  http://download.tizen.org/tools/xUbuntu_11.10/
51
52 2. Update repository list:
53 ::
54
55   $ sudo apt-get update
56
57 3. Install mic:
58 ::
59
60   $ sudo apt-get install mic
61
62 OpenSUSE Installation
63 ~~~~~~~~~~~~~~~~~~~~~
64 1. Add Tools Building repository:
65 ::
66
67   $ sudo zypper addrepo http://download.tizen.org/tools/openSUSE12.1/ tools-building
68
69
70 2. Update repository list:
71 ::
72
73   $ sudo zypper refresh
74
75 3. Install mic:
76 ::
77
78   $ sudo zypper install mic
79
80 Fedora Installation
81 ~~~~~~~~~~~~~~~~~~~
82 1. Add The Tools Building repository:
83 ::
84
85   $ sudo cat  /etc/yum.repos.d/tools-building.repo
86   > [Tools]
87   > name=Tools project for mic, gbs, etc. (Fedora_17)
88   > baseurl=http://download.tizen.org/tools/Fedora_17/
89   > enabled=1
90   > gpgcheck=0
91
92 2. Update repository cache:
93 ::
94
95   $ sudo yum makecache
96
97 3. Install Mic:
98 ::
99
100   $ sudo yum install mic --nogpgcheck
101
102 Source Installation
103 -------------------
104 Before you install MIC from the source, make sure you installed all the MIC's dependencies manually.
105
106 Enable Bootstrap Environment
107 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108 If your mic is higher than 0.15, it means mic would use bootstrap as default. This is the recommended way to install MIC source. The dependencies are:
109 ::
110
111   - rpm
112   - rpm-python
113   - python
114   - python-xml
115   - python-urlgrabber
116
117 Take Ubuntu 12.04 as an example, you should install the dependencies with apt-get:
118 ::
119
120    $ sudo apt-get install rpm python-rpm python-urlgrabber
121
122 For OpenSUSE, you can install the dependencies with zypper:
123 ::
124
125    $ sudo zypper install rpm-python python-xml python-urlgrabber
126
127 Using Native Envionment
128 ~~~~~~~~~~~~~~~~~~~~~~~
129 If you want MIC to run natively in your host, you should install more dependencies to make it work. For Ubuntu 12.04, you should install these packages with apt-get:
130 ::
131
132   $ sudo apt-get install python-rpm bzip2 dmsetup dosfstools e2fsprogs isomd5sum genisoimage \
133    > kpartx parted psmisc sqashfs-tools qemu-user-static extlinux syslinux yum python-m2crypto
134
135 To get the MIC source, go `here
136 <https://github.com/otcshare/mic/downloads>`_  or git clone from github
137
138 ::
139
140  $ git clone https://github.com/01org/mic
141
142 Then go to the MIC source directory, and run 'make install' to install MIC from source:
143
144 ::
145
146   $ cd mic
147   $ sudo make install
148
149
150 Quick Start
151 ============
152
153 How to create an image
154 -----------------------
155
156 **Prepare kickstart file**
157
158 To create an image, you need a proper ks file.
159 Here's a simple example:
160 ::
161
162   # filename: tizen-min.ks
163   lang en_US.UTF-8
164   keyboard us
165   timezone --utc America/Los_Angeles
166
167   part / --size 1824 --ondisk sda --fstype=ext3
168
169   rootpw tizen
170   bootloader  --timeout=0  --append="rootdelay=5"
171
172   desktop --autologinuser=tizen
173   user --name tizen  --groups audio,video --password 'tizen'
174
175   repo --name=Tizen-base --baseurl=http://download.tizen.org/snapshots/trunk/latest/repos/base/ia32/packages/
176   repo --name=Tizen-main --baseurl=http://download.tizen.org/snapshots/trunk/latest/repos/main/ia32/packages/
177
178   %packages --ignoremissing
179    @tizen-bootstrap
180   %end
181
182   %post
183   rm -rf /var/lib/rpm/__db*
184   rpm --rebuilddb
185   %end
186
187   %post --nochroot
188   %end
189
190 The ks file above can be used to create a minimum Tizen image. For other repositories, you can replace with the appropriate repository url. For example:
191 ::
192
193   repo --name=REPO-NAME --baseurl=https://username:passwd@yourrepo.com/ia32/packages/ --save  --ssl_verify=no
194
195 **Create an loop image**
196
197 To create an image, run MIC in the terminal:
198 ::
199
200  $ sudo mic create loop tizen-min.ks
201
202 How to add/remove packages
203 --------------------------
204
205 You can specific the packages you plan to install in the '%packages' section in ks file. Packages can be specified by group/pattern or by individual package name. The definition of the groups/pattern can be referred to in the repodata/\*comps.xml or repodata/pattern.xml file at the download server. For example: http://download.tizen.org/snapshots/latest/repos/base/ia32/packages/repodata/_.
206
207 The %packages section is required to end with '%end'. Also, multiple '%packages' sections are allowed. Additionally, individual packages may be specified using globs. For example:
208 ::
209
210   %packages
211   ...
212   @Tizen Core            # add a group named Tizen Core, and all the packages in this group would be added
213   e17-*                  # add all the packages with name starting with "e17-"
214   kernel                 # add kernel package
215   nss-server.armv7hl     # add nss-server with arch armv7hl
216   -passwd                # remove the package passwd
217   ...
218   %end
219
220 Use local rpm package
221 ---------------------
222
223 "How can I install my own rpm into the image, so I can test my package with the image?"
224 In such a case, using local package path would be very helpful. For example, if your rpm 'hello.rpm' is under directory 'localpath', run MIC like below:
225
226 ::
227
228     $ sudo mic create loop test.ks --local-pkgs-path=localpath
229
230 From the output, MIC will tell you "Marked 'hellop.rpm' as installed", and it will install hello.rpm in the image. Be sure your rpm is not in the repo of ks file and that your rpm's version is newer or equal to the repo rpm version.
231
232 How to set proxy
233 ----------------
234
235 **Proxy variable in bash**
236
237 It's common to use the proxy variable in bash. In general, you can set the following environment variables to enable proxy support:
238
239 ::
240
241   export http_proxy=http://proxy.com:port
242   export https_proxy=http://proxy.com:port
243   export ftp_proxy=http://proxy.com:port
244   export no_proxy=localhost,127.0.0.0/8,.company.com
245
246 You don't need all the variables. Check what you do need. When your repo url in your ks file starts with 'https', MIC will use https_proxy. Be especially aware of when you set no_proxy (it indicates which domain should be accessed directly). Don't leave blank space in the string.
247
248 Because MIC needs sudo privilege, set /etc/sudoers, to keep the proxy environment, and add those proxy variables to "env_keep":
249
250 ::
251
252    Defaults        env_keep += "http_proxy https_proxy ftp_proxy no_proxy"
253
254 Note: Use "visudo" to modify /etc/sudoers
255
256 However, if you don't want to change your /etc/sudoers, there is an alternative for you to set the proxy in mic.conf. See the next section.
257
258 **Proxy setting in mic.conf**
259
260 The proxy environment variables may disturb other program, so if you would like to enable proxy support only for MIC, set the proxy in /etc/mic/mic.conf like this:
261
262 ::
263
264   [create]
265    ; settings for create subcommand
266    tmpdir= /var/tmp/mic
267    cachedir= /var/tmp/mic/cache
268    outdir= .
269    pkgmgr = zypp
270    proxy = http://proxy.yourcompany.com:8080/
271    no_proxy = localhost,127.0.0.0/8,.yourcompany.com
272
273 **Proxy setting in ks file**
274
275 It's likely that you will need to enable proxy support only for a special repo url, and other things would remain at their existing proxy setting.
276 Here's how to handle that case:
277
278 ::
279
280   repo --name=oss --baseurl=http://www.example.com/repos/oss/packages --proxy=http://host:port
281
282 Chroot an image
283 ----------------
284
285 When you want to run commands inside an image, just chroot it first. Be sure your image has bash installed inside:
286
287 ::
288
289     $ sudo mic chroot tizen-min.img
290
291 Convert an image to another format
292 ----------------------------------
293
294 **Convert livecd to liveusb**
295
296 To convert a livecd image to liveusb:
297
298 ::
299
300   $ sudo mic convert test.iso liveusb
301
302 **Convert liveusb to livecd**
303
304 To convert a liveusb to livecd:
305
306 ::
307
308   $ sudo mic convert test.usbimg livecd
309
310 Basic Usage
311 ============
312 MIC is used to create and manipulate images for Linux distributions. It is composed of three subcommands: create, convert, and chroot.
313
314 Create
315 -------------------
316
317 This command is used to create various images, including live CD, live USB, loop, and raw.
318
319 **Usage:**
320
321 ::
322
323   mic create(cr) SUBCOMMAND <ksfile> [OPTION]
324
325 **Sub-commands:**
326
327 ::
328
329    help(?)            give detailed help on a specific sub-command
330    fs                 create fs image, which is also chroot directory
331    livecd             create live CD image, used for CD booting
332    liveusb            create live USB image, used for USB booting
333    loop               create loop image, including multi-partitions
334    raw                create raw image, containing multi-partitions
335
336 **Options:**
337
338 ::
339
340    -h, --help          Show this help message and exit
341    --logfile=LOGFILE   Path of logfile
342    -c CONFIG, --config=CONFIG
343                        Specify config file for MIC
344    -k CACHEDIR, --cachedir=CACHEDIR
345                        Cache directory to store downloaded files
346    -o OUTDIR, --outdir=OUTDIR
347                        Output directory
348    -A ARCH, --arch=ARCH
349                        Specify repo architecture
350    --release=RID       Generate a release of RID with all necessary files.
351                        When @BUILD_ID@ is contained in kickstart file, it
352                        will be replaced by RID.
353    --record-pkgs=RECORD_PKGS
354                        Record the info of installed packages. Multiple values
355                        can be specified which joined by ",", valid values:
356                        "name", "content", "license".
357    --pkgmgr=PKGMGR     Specify backend package manager
358    --local-pkgs-path=LOCAL_PKGS_PATH
359                        Path for local pkgs(rpms) to be installed
360    --compress-disk-image=COMPRESS_DISK_IMAGE
361                        Sets the disk image compression. Note: The available
362                        values might depend on the used filesystem type.
363    --copy-kernel       Copy kernel files from image /boot directory to the
364                        image output directory.
365
366 **Examples:**
367
368 ::
369
370    mic cr loop tizen.ks
371    mic cr livecd tizen.ks --release=latest
372    mic cr fs tizen.ks --local-pkgs-path=localrpm
373
374
375 Chroot
376 -------------------
377
378 This command is used to chroot inside the image. It's a great enhancement of the chroot command in the Linux system.
379
380 **Usage:**
381
382 ::
383
384   mic chroot(ch) <imgfile>
385
386 **Options:**
387
388 ::
389
390    -h, --help          show this help message and exit
391    -s SAVETO, --saveto=SAVETO
392                        Save the unpacked image to specified dir
393
394 **Examples:**
395
396 ::
397
398    mic ch loop.img
399    mic ch tizen.iso
400    mic ch -s tizenfs tizen.usbimg
401
402 Convert
403 -------------------
404
405 This command is used for converting an image to another format.
406
407 **Usage:**
408
409 ::
410
411    mic convert(cv) <imagefile> <destformat>
412
413 **Options:**
414
415 ::
416
417    -h, --help   Show this help message and exit
418    -S, --shell  Launch shell before packaging the converted image
419
420 **Examples:**
421
422 ::
423
424    mic cv tizen.iso liveusb
425    mic cv tizen.usbimg livecd
426    mic cv --shell tizen.iso liveusb
427
428 What's BootStrap?
429 =================
430 When some important packages (like rpm) of the distribution (Tizen) is much different with native environment, the image created by native environment may be not bootable. Then a bootstrap environment will be required to create the image.
431
432 To create an image of one distribution (Tizen), MIC will create a bootstrap for this distribution (Tizen) at first, and then create the image by chrooting this bootstrap. This way is called "Bootstrap Mode" for MIC. And from 0.15 on, MIC will use this mode by default.
433
434 Advanced Usage
435 ==============
436 The advanced usage is exclusively for bootstrap. Please skip it if you don't care about it.
437
438 The major reason for using bootstrap is if some important packages (like rpm) are customized a lot in the repo in which you want to create image, and mic must use the customized rpm to create images, or the images can't be booted. So MIC will create a bootstrap using the repo in the ks file at first, then create the image through chrooting, which can make MIC use the chroot environment with the customized rpm.
439
440 Now MIC will use bootstrap mode to create an image by default. To meet your requirement, you can also change the bootstrap settings (/etc/mic/bootstrap.conf):
441
442 ::
443
444   [main]
445   distro_name = tizen  # which distro will be used for creating bootstrap
446   rootdir = /var/tmp/mic-bootstrap  # which dir will be located when creating bootstrap
447   enable = true # whether to enable the bootstrap mode
448   [tizen] # the supported distro for creating bootstrap
449   optional:  # which packages will be optional when creating bootstrap for this distro
450   packages:  # which packages will be required when creating bootstrap for this distro
451
452
453 FAQ
454 ============
455
456 Q: When creating an image, MIC shows "Error <creator>: URLGrabber error: http://www.example.com/latest/repos/oss/ia32/packages/repodata/repomd.xml"
457
458 A: Perhaps your network has some issues, or your proxy doesn't work. Try another proxy or find out the network issue.
459
460 Q: MIC complains "Error <repo>: found 1 resolver problem, abort!"
461
462 A: This is not an issue with MIC, but with the repo you used. Make sure the packages in the repo you used have proper dependencies.
463
464 Q: I used '-A i586' to create an i586 image, but it showed "nothing provided ....". What's wrong with it?
465
466 A: Use '-A i686'. i586 is lower than i686, so many packages will be missing from the installation.
467
468 Q: MIC shows in the log: "file /usr/share/whatever conflicts between attempted installs of somepackageA and somepackageB"
469
470 A: There are conflicts between some packages in the repo you used, but this is not an issue with MIC. Please make sure you are using a proper repo.
471
472 Q: Error shows: Command 'modprobe' is not available in Fedora 17.
473
474 A: In Fedora 17, when you use sudo, the PATH variable will be changed and you will lose some important paths. Run 'export PATH=/sbin:$PATH' before running MIC.
475
476 Known Issues
477 ============
478
479 Nonsupport zypp backend in Fedora 17
480 ------------------------------------
481 As libsat-solver changed to libsolv in Fedora 17, zypp backend can't work well for some dependency issues. Use yum as the backend in Fedora 17 distribution.
482
483 Unable to install syslinux bootloader
484 --------------------------------------
485
486 In some new Linux distributions, the "syslinux" package in their official software repositories is version 4.04. It causes a segfault, which is a fatal bug, and MIC will fail with syslinux installation errors.
487
488 The solution is to install the patched "syslinux" package in MeeGo or Tizen's tools repos, until the official released one has been fixed
489
490 Failed to create btrfs image in OpenSUSE
491 ----------------------------------------
492
493 When creating a btrfs image in OpenSUSE, it hangs, showing image kernel panic. This issue impacts OpenSUSE distributions: 12.1, etc.
494
495 Failed to create an image (and the password in the repo URL contains "@")
496 --------------------------------------------------------------------------
497
498 MIC cannot support passwords that contain the char "@", but this will be fixed soon. Example:
499
500 ::
501
502   repo --name=Tizen-base --baseurl=https://username:passwd@example.com/arch/packages/ --save  --ssl_verify=no
503
504
505 Bug report and Contacts
506 =========================
507 The source code is tracked at github.com: https://github.com/01org/mic
508
509 Report issues for bugs or feature requests at JIRA: https://bugs.tizen.org, or at the github page directly.