现在的位置: 首页 > 综合 > 正文

MIC Image Creator使用说明

2013年08月08日 ⁄ 综合 ⁄ 共 6275字 ⁄ 字号 评论关闭
文章目录

1 概述

Mic工具是用来给tizen制作镜像文件的工具。通过此工具,我们可以制作各位类型的镜像文件,如live CD镜像,live USB镜像,针对KVM的raw镜像,针对IVI平台的loop镜像,及chroot的fs镜像。也可以通过MIC的增加指令chroot指令,chroot into到镜像文件中。

除此之外,MIC工具还可以将上述各种镜像文件之间进行格式转换, 这是非常有用的工具。

2 安装MIC工具

使用如下指令即可安装MIC工具:

$ sudo apt-get install mic

查看MIC工具的当前版本:

$ mic --version
mic 0.19.1 (Ubuntu 12.04 precise)

3 MIC工具的使用方法

MIC工具主要提供三种功能:

  • 创建不同格式的镜像文件
  • 将镜像文件从一种格式转换到另一种格式
  • chroot into 到一个镜像文件中

3.1 获取MIC的帮助信息

你可以使用$ mic --help指令或$ mic <subcmd> --help指令来获取MIC工具的帮助信息。

以下是几种获取MIC帮助信息的方法:

  • $ man mic
  • mic --help
  • mic create --help
  • mic help create
  • mic create loop --help
  • mic create help loop

3.2 MIC支持的几种镜像文件格式

3.2.1 Loop

1> 第一个Loop对应着的一个分区

2> 一个Loop镜像文件内包含着一个文件系统.

3> 在一个kickstartfile文件中可描述多个分区,针对这种情况,mic工具将会生成多个Loop镜像文件。

4> 多个Loop镜像文件可以打包成一个archive文件。

3.2.2 Raw

1> Raw有点像硬盘数据。

2> 包含分区表和所有分区。

3> 可以直接启动此类型镜像。

3.2.3 Livecd/liveusb

主要用于ia32,可以将其烧录到CD或U盘

3.2.4 fs

1> fs即文件系统。

2> MIC工具可以安装所有的tizen文件到一指定目录,此目录可直接用作chroot目录。

4 制作镜像文件

4.1 基本使用

4.1.1 创建镜像文件的指令

如下:

mic create(cr) SUBCOMMAND <ksfile> [OPTION]

4.1.2 指定镜像文件格式类型子命令

 help(?)            give detailed help on a specific sub-command
 fs                 create fs image, which is also a chroot directory
 livecd             create live CD image, used for CD booting
 liveusb            create live USB image, used for USB booting
 loop               create loop image, including multi-partitions
 raw                create raw image, containing multi-partitions

4.1.3 ksfile

kickstart为一简单的文本文件,它包含镜像分区, 设置, Bootloader, 安装包等,每类型都有对应的关键字。

tizen在发布时,通常会同时发布其对应的ksfile,如:http://download.tizen.org/releases/daily/2.0alpha/ivi-wayland/tizen-2.0alpha_20130522.2/images/ivi-wayland-release/ivi-wayland-release.ks

4.1.4 mic选项

   -h, --help          Show this help message and exit
   --logfile=LOGFILE   Path of logfile
   -c CONFIG, --config=CONFIG
                       Specify config file for MIC
   -k CACHEDIR, --cachedir=CACHEDIR
                       Cache directory to store downloaded files
   -o OUTDIR, --outdir=OUTDIR
                       Output directory
   -A ARCH, --arch=ARCH
                       Specify repo architecture
   --release=RID       Generate a release of RID with all necessary files.
                       When @BUILD_ID@ is contained in kickstart file, it
                       will be replaced by RID.
   --record-pkgs=RECORD_PKGS
                       Record the info of installed packages. Multiple values
                       can be specified which joined by ",", valid values:
                       "name", "content", "license", "vcs".
   --pkgmgr=PKGMGR     Specify backend package manager
   --local-pkgs-path=LOCAL_PKGS_PATH
                       Path for local pkgs(rpms) to be installed
   --pack-to=PACK_TO   Pack the images together into the specified achive,
                       extension supported: .zip, .tar, .tar.gz, .tar.bz2,
                       etc. by default, .tar will be used
   --copy-kernel       Copy kernel files from image /boot directory to the
                       image output directory.
   --install-pkgs=INSTALL_PKGS
                        Specify what type of packages to be installed, valid:
                        source, debuginfo, debugsource

4.1.5 其它选项

   --runtime=RUNTIME_MODE
                       Sets runtime mode, the default is bootstrap mode, valid
                       values: "native", "bootstrap". "native" means mic uses
                       localhost environment to create image, while "bootstrap"
                       means mic uses one tizen chroot environment to create image.
    --compress-image=COMPRESS_IMAGE (for loop & raw)
                       Sets the disk image compression. Note: The available
                       values might depend on the used filesystem type.
   --compress-disk-image=COMPRESS_IMAGE
                       Same with --compress-image
   --shrink (for loop)
                       Whether to shrink loop images to minimal size
   --generate-bmap (for raw)
                       Generate the block map file
   --fstab-entry=FSTAB_ENTRY (for raw)
                        Set fstab entry, 'name' means using device names,
                        'uuid' means using filesystem uuid

4.1.6 示例

创建一个loop镜像文件:

$ mic cr loop tizen.ks

4.2 如何创建一个镜像文件

4.2.1 准备kickstart文件

在使用MIC工具创建镜像镜像文件之前,你需要准备一个kickstart文件,这里是一个简单的kickstart文件内容:

# filename: tizen-min.ks
lang en_US.UTF-8
keyboard us
timezone --utc America/Los_Angeles

part / --size 1824 --ondisk sda --fstype=ext3

rootpw tizen
bootloader  --timeout=0  --append="rootdelay=5"

desktop --autologinuser=tizen
user --name tizen  --groups audio,video --password 'tizen'

repo --name=Tizen-base --baseurl=http://download.tizen.org/snapshots/trunk/common/latest/repos/base/ia32/packages/
repo --name=Tizen-main --baseurl=http://download.tizen.org/snapshots/trunk/common/latest/repos/main/ia32/packages/

%packages --ignoremissing
@tizen-bootstrap
%end

%post
rm -rf /var/lib/rpm/__db*
rpm --rebuilddb
%end

%post --nochroot
%end

上述的ks文件可以用来创建一个最小的tizen镜像,至于其它资料库,你可以使用网上精确的资料库地址来替换它。

例如:

repo --name=REPO-NAME --baseurl=https://username:passwd@yourrepo.com/ia32/packages/ --save  --ssl_verify=no

4.2.2 创建Loop镜像

在终端运行如下指令可创建一个loop镜像:

$ sudo mic create loop tizen-min.ks

4.3 使用本地RPM包创建镜像

也许你会问:如何安装我自己的RPM包到镜像中?以此方便我测试这些包是否正常。

在这种情况下,你可以使用本地路径。例如,你如你的hello.rpm包在本地目录localpath下,那么运行如下指令:

$ sudo mic create loop test.ks --local-pkgs-path=localpath

从输出信息中可以看到,MIC工具会告诉你hello.rpm已经被标志为已安装,它即将安装到镜像中。你必须得确保你的RPM包没在包ks文件中包含或是rpm包的版本不低于repo相相对应包的版本。

4.4 指定创建Achive的格式

MIC工具可以指定即将创建的镜像文件的achive格式,如 .zip, .tar, .tar.gz, .tar.bz2等,默认情况下为.tar格式。

$ sudo mic create loop test.ks --pack-to=@NAME@.tar.gz

4.5 chroot

此指令用来chroot into到镜像文件中,在Linux系统下,它是一个非常有用的加强指令。

4.5.1 使用

mic chroot(ch) <imgfile>

4.5.2 选项

   -h, --help          Show this help message and exit
   -s SAVETO, --saveto=SAVETO
                       Save the unpacked image to a specified dir

4.5.3 示例

   mic ch loop.img
   mic ch tizen.iso
   mic ch -s tizenfs tizen.usbimg

4.6 转换

此指令用来将镜像文件从一种格式转换成另一个格式.

4.6.1 使用

  mic convert(cv) <imagefile> <destformat>

4.6.2 选项

   -h, --help   Show this help message and exit
   -S, --shell  Launch shell before packaging the converted image

4.6.3 示例

   mic cv tizen.iso liveusb
   mic cv tizen.usbimg livecd
   mic cv --shell tizen.iso liveusb

5 如何自定义镜像文件

这一章将介绍如何通过修改ks文件来订制你自己的镜像文件。你可下载kickstart文件,然后修改它,如;http://download.tizen.org/releases/daily/trunk/ivi/latest/images/ivi-min-pc/ivi-min-pc-tizen_20120926.2.ks

5.1 指定资料库

你可以指定哪个资料库用来创建镜像文件,可以包含本地的资料库:

例如:http://download.tizen.org/releases/daily/trunk/ivi/latest/images/ivi-min-pc/ivi-min-pc-tizen_20120926.2.ks

repo --name=Tizen-main --baseurl=https://download.tizen.org/snapshots/trunk/common/@BUILD_ID@/repos/main/armv7l/packages/ --save  --ssl_verify=no

repo --name=Tizen-base --baseurl=https://download.tizen.org/snapshots/trunk/common/@BUILD_ID@/repos/base/armv7l/packages/ --save  --ssl_verify=no

repo --name=mylocal--baseurl=/loca/repo/path/

5.2 指定访问repo的用户名和密码

如果远程的repo资料库需要用户名和密码,那么你得在kickstart文件中指明你的用户名和密码,如:

repo --name=REPO-NAME --baseurl=https://username:passwd@yourrepo.com/ia32/packages/ --save  --ssl_verify=no

5.3 如何增加/移除包

你可以在ks文件中的'%packages'处指明你要安装哪些包,你可以单个指出它们,也可以以组的方式指出。

关于组的定义你可以参考下载服务器中的repodata/*comps.xml 或 repodata/pattern.xml 文件,如:

http://download.tizen.org/snapshots/trunk/common/latest/repos/base/ia32/packages/repodata/

%packages必须以%end结束,也可以同时指出多个%packages,此外,单个包可能以globs方式指出,如:

 %packages
 ...
 @Tizen Core            # add a group named Tizen Core, and all the packages in this group would be added
 e17-*                  # add all the packages with name starting with "e17-"
 kernel                 # add kernel package
 nss-server.armv7hl     # add nss-server with arch armv7hl
 -passwd                # remove the package passwd
 ...
 %end

5.4 制作完镜像后自动运行脚本

在创建完镜像文件后,你也可以指出自动运行脚本,如:

%post
rpm -rebuilddb
%end

更多有关kickstart文件的信息请参考:http://fedoraproject.org/wiki/Anaconda/Kickstart

抱歉!评论已关闭.