sejishikong 发表于 2008-4-29 16:41:59

MagicInstaller的粗略解析

为了处理MagicInstaller的bug及为了以后移植的考虑,硬着头皮来看MagicInstaller(因为我不懂python)。MagicInstaller,以下简称MI
MI的主程序是由pygtk开发的,现在只支持rpm包,并且只支持光盘、硬盘的安装方式,并不支持网络安装,并且目前还不支持软件分包选择。
可以在这里下载到比较新的一个版本:http://apt.magiclinux.org/files/MagicInstaller.exp-2.0r4-fix.tar.bz2

将这个文件解压,会得到如下的一个目录

|-- AUTHORS <----作者,里面只有Charles Wang <[email protected]>,但实际上现在是levindu在做,已经和原来的有很大不同了。
|-- BUGS <---无内容
|-- Backup <----备份目录,暂时不用管
|-- COPYING <----版权文件,MI使用GPLv2协议
|-- MagicBooter <----MI的启动文件
|-- README <---MI的一些介绍,有些内容已经过时
|-- SConstruct <---scon的构建文件
|-- SConstruct-mb <---同上
|-- SConstruct-mi<---同上
|-- TODO <---同README
|-- bindir <---MI的主文件
|-- buildpkg <---建立MI环境需要的一些文件
|-- docs <---文档
|-- mi_config.py <---配置文件
|-- sample.specinfo.py <---specinfo.py的例子文件
|-- scripts <---脚本
|-- spec <---放置文件的目录
|-- src <---源码
|-- test <---测试目录
`-- tmp <---临时目录

上面的目录,以后在进一步的解析。

如果只是利用MI来定制自己的ISO,可以很简单的把需要的rpm包放在spec/packages里,然后运行scons就可以了。当然,一般情况下还需要修改spec/specinfo.py的,以后再讲。

MI的官方trac:http://trac.magiclinux.org/magicinstaller/,里面有一些levindu写的开发文档,有意向参与开发的,可以看看。

sejishikong 发表于 2008-4-29 20:24:51

接下来看spec这个目录,因为这个目录是对于定制iso最常用的。
在上面下载的文件里,这个目录只有一个文件就是specinfo.py
它是控制MI的一些参数的文件。文件内容如下:我添加上中文的注释

#!/usr/bin/python
#上面表明这是个python程序
### Global information ###
###全局信息###
# distname is used to specify the name of the installed distribution.
# distname 是指定发行版本名称的,你可以自己改
distname='MagicLinux'

# distver is used to specify the version of the installed distribution.
# distver 是指定发行版的版本的,也可以改,但是注意,这个版本号里不能有-
distver='2.1beta0'

# distkernelver is used to specify the kernel version which used by the
# installed distribution.
# distkernelver 是指定发行版本的内核版本,注意这个内核是指Magic本身的内核,有可能和MI的内核版本不一致
distkernelver='2.6.20.4'

# pkgtype is used to specify the package management scheme used by the
# installed distribution. Now only 'rpm' is supported.
# pkgtype是指定包类型的,现在只支持rpm包
pkgtype='rpm'

# pkgdirs is used to specify the directories which contain the packages
# which should be installed by MagicInstaller as a part of the installed
# distribution. Multiple directories can be separated by ':'. This value
# can be overrided through the command line argument of scons.
#pkgdirs是指定包位置的,默认就是在spec/packages,这个目录需要自己建立,也可以是链接到一个目录的链接
pkgdirs='spec/packages'

# langset is used to specify the language set supported in installation
# progress. It is a 'colon' separated string.
# langset 是指定安装程序的语言,可以指定多个,用:分隔,默认的是中文和英文,中文在前。
langset='zh_CN:en'

### Information provided for MagicBooter ###

# welcome message is used to show in the first message box for magicbooter
# which should be provided in English only. Note that this string will be
# placed into m4 command and put into C string, so be carefully about '\n'.
# 下面是指定MI的欢迎词,注意只能是英文
welcome="Welcome to test MagicLinux!"

# kmods_arrange is map which key is the boot/driver floppy disk name and
# the value is the modules which should be placed in. The item with 'boot'
# key specify the modules which should be distributed with boot floppy disk.
# In the module list, module name can be used directly, directory is also
# permitted. And item prefixed with '@' will be added forcely, otherwise
# the modules which are not exists in pcitable will be omitted.
# 下面这个设置一般不需要调整,你可以不管它。
# kernel 2.4
# kmods_arrange = {
#    "boot" : [ '@ext3.o', '@jfs.o', '@ntfs.o', '@reiserfs.o', '@vfat.o' ],
#    "scsi" : [ '@xfs.o', '@sd_mod.o', '@kernel/drivers/md', 'kernel/drivers/scsi' ],
#    "net" : ['@xfs.o', '@kernel/drivers/md', 'kernel/drivers/net' ]
# }
# kernel 2.6, fs as module
#kmods_arrange = {
#   "boot" : [ '@ext3', '@jfs', '@ntfs', '@reiserfs', '@vfat' ],
#   "scsi" : [ '@xfs', 'kernel/drivers/scsi' ],
##   "net" : ['@xfs', 'kernel/drivers/net' ]
#}
# kernel 2.6, fs builtin
kmods_arrange = {
   "boot" : [ ],
   "scsi" : [ 'kernel/drivers/scsi' ],
   "net" : ['kernel/drivers/net']
}

### Information about package arrangement ###

######################################################################
# volume_limit_list is used to divide the packages into several media.
# Because one CDROM can't store any data more than 650MB, and the current
# distribution always exceed this limitation, so there should be a way to
# arrange the packages into more then one CDROMs. volume_limit_list list
# the volume limitation for each media in bytes.
# 下面的设置是有关生成的ISO的大小的,单位是Bytes,因为MI可以生成分卷的安装盘,所以可以指定第一个,第二个,第三个等
# 但通常我们只做一张iso,所以只改第一个即可
volume_limit_list =

#下面的两段内容是和选择安装有关的,因为暂时还没实现,所以无用,不用管它

######################################################################
# placement_list is used to list the package that must be put in which media.
# For example:
#   [['mktemp-1.5-18.i386.rpm'], ['bash-2.05b-20.i386.rpm'], []]
#   which means 'mktemp' must be put into the first media, 'bash' must be put
#   into the first media or second media. and so on.
#
#placement_list = [[]]

######################################################################
# toplevel_groups is used to create groups for the user convenience.
# toplevel_groups is a map. The key is the map name, the value is the map
# package list. This script will resolve the dependency automatically and
# put it into the output result.
# Note that the key 'lock' has different meaning, the packages in 'lock'
# group will be installed forcely.
# For example:
# { 'lock':['bash-2.05b-20.i386.rpm'],
#   'gnome': ['gnome-desktop-2.2.0.1-4.i386.rpm',
#             'gnome-applets-2.2.0-8.i386.rpm',
#             ...]}
#
#toplevel_groups = {}

# 下面的内容是关于rpm的依赖的,这段是添加依赖。

######################################################################
# add_deps is used to add the lost dependencies.
# add_deps is a map which key is the package and the value is the list of
#   the packages that the package depends.
# For example:
#{ 'libacl1-2.2.4-1.i386.rpm' : ['libattr1-2.2.0-1.i386.rpm'] }
# 这里是给那些在制作rpm包时没写依赖关系,但安装的时候需要有顺序的包准备的。格式可以参考下面的,一般情况下,不用管它。
#add_deps = {'kernel-2.6.9-5mgc.i686.rpm' : ['mkinitrd-3.5.22-10mgc.i686.rpm'], 'elfutils-0.76-2.i686.rpm' : ['rpm-python-4.3.3-8mgc.i686.rpm']}

######################################################################
# remove_deps is used to resolve the loop dependencies.
# remove_deps is a map which key is the package and the value is the list of
#   the packages that the package shouldn't remove depends.
# For example:
#{ 'pam-0.75-49.i386.rpm' : ['initscripts-7.14-9.i386.rpm'] }
# 这里移掉不需要的依赖(有可能会影响安装),格式和上面的一样,一般情况下,不管它。
#remove_deps = {}

# 上面的内容主要是针对一些存在循环依赖问题的包
# For the detail to deal with loop dependencies between packages, refer to
# the comments and code in scripts/PkgArrange.py.


#下面一直到最后,都是和自动分区有关的内容,一般情况下我们不用自动分区,所以不用管它

######################################################################
# autopart_profile is used to add the auto-partition
# profile. autopart_profile is a map which key is the profile and the
# value is the description and partition definitions.
#
# Note that the profile name is used as a XML tag, so please use just
# letters and numbers. The description will be used to shown in a
# selection box, and translation is available by updating po files.
#
# The part tuple is a form of ("mountpoint", "filesystem", "size")

#- mountpoint can be the mount path of the partitionn or "SWAP" as a
#swap partition.

#- filesystem can be one of "ext2", "ext3", "reiserfs", "fat16",
#"fat32", "jfs", "xfs".
#
#- size can be size of "64M", "15G", or percents like "50%",
#"30%". If there's any percents size, the allocation is different,
#the percents are served as a proportion. For example: the free
#space is 12G, there're three percents partitions (10%, 90%, 20%)
#left, so there respective allocated size will be
#12G*10/(10+90+20) = 1G, 12G*90/(10+90+20)=9G, 12G*20/(10+90+20)=2G.
# For exammple:
# autopart_profile = {
#   'default' : ["Separated /boot, /, /home",
#                  ("/boot", "ext2", "64M"),
#                  ("/", "ext3", "5G"),
#                  ("/home", "ext3", "100%")],
#   'custom' :["Customed autopart profile",
#                  ("SWAP", "SWAP", "15G"),
#                  ("/", "ext3", "15G"),
#                  ("/usr/local", "ext3", "15G"),
#                  ("/tmp", "ext3", "15G"),
#                  ("/home", "ext3", "100%")]
#   }

#要是需要修改,可以参考下面的格式。

autopart_profile = {
    'default' : ["Single partition with swap",
               ("SWAP", "SWAP", "64M"),
               ("/", "ext3", "100%")],
   
    'common' : ["Separated /boot, /, /home",
               ("/boot", "ext2", "64M"),
               ("/", "ext3", "128M"),
               ("/home", "ext3", "0")],
   
    'custom' :["Customed autopart profile",
               ("SWAP", "SWAP", "15M"),
               ("/", "ext3", "15M"),
               ("/usr/local", "ext3", "15M"),
               ("/tmp", "ext3", "15M"),
               ("/home", "ext3", "0")]
    }



在spec这个目录,还可以存在另一个文件,就是post_install.sh,这个是在安装后执行的脚本,你可以自己建立,注意,这个脚本是在安装系统完成后,chroot进新系统执行的,并不是在MI的环境下执行,所以要考虑新系统下可以正常运行才,目前MagicLinux主要用它来修正一些在安装阶段没有正确执行的rpm脚本。但是你可以用它来做其它的事情,比如对系统的预配置等。

Fishbabyml 发表于 2008-7-4 16:54:13

今天看到了se兄的这个帖,就把MI源码下载下来了,正好我现在在学习PYTHON,可以好好去研究一下了,呵!

支持se兄,支持linux,支持magic!!
页: [1]
查看完整版本: MagicInstaller的粗略解析