QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2945|回复: 2

MagicInstaller的粗略解析

[复制链接]
发表于 2008-4-29 16:41:59 | 显示全部楼层 |阅读模式
为了处理MagicInstaller的bug及为了以后移植的考虑,硬着头皮来看MagicInstaller(因为我不懂python)。MagicInstaller,以下简称MI
MI的主程序是由pygtk开发的,现在只支持rpm包,并且只支持光盘、硬盘的安装方式,并不支持网络安装,并且目前还不支持软件分包选择。
可以在这里下载到比较新的一个版本:http://apt.magiclinux.org/files/ ... p-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写的开发文档,有意向参与开发的,可以看看。
 楼主| 发表于 2008-4-29 20:24:51 | 显示全部楼层
接下来看spec这个目录,因为这个目录是对于定制iso最常用的。
在上面下载的文件里,这个目录只有一个文件就是specinfo.py
它是控制MI的一些参数的文件。文件内容如下:我添加上中文的注释

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

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

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

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

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

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

  29. ### Information provided for MagicBooter ###

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

  35. # kmods_arrange is map which key is the boot/driver floppy disk name and
  36. # the value is the modules which should be placed in. The item with 'boot'
  37. # key specify the modules which should be distributed with boot floppy disk.
  38. # In the module list, module name can be used directly, directory is also
  39. # permitted. And item prefixed with '@' will be added forcely, otherwise
  40. # the modules which are not exists in pcitable will be omitted.
  41. # 下面这个设置一般不需要调整,你可以不管它。
  42. # kernel 2.4
  43. # kmods_arrange = {
  44. #    "boot" : [ '@ext3.o', '@jfs.o', '@ntfs.o', '@reiserfs.o', '@vfat.o' ],
  45. #    "scsi" : [ '@xfs.o', '@sd_mod.o', '@kernel/drivers/md', 'kernel/drivers/scsi' ],
  46. #    "net" : ['@xfs.o', '@kernel/drivers/md', 'kernel/drivers/net' ]
  47. # }
  48. # kernel 2.6, fs as module
  49. #kmods_arrange = {
  50. #   "boot" : [ '@ext3', '@jfs', '@ntfs', '@reiserfs', '@vfat' ],
  51. #   "scsi" : [ '@xfs', 'kernel/drivers/scsi' ],
  52. ##   "net" : ['@xfs', 'kernel/drivers/net' ]
  53. #}
  54. # kernel 2.6, fs builtin
  55. kmods_arrange = {
  56.    "boot" : [ ],
  57.    "scsi" : [ 'kernel/drivers/scsi' ],
  58.    "net" : ['kernel/drivers/net']
  59. }

  60. ### Information about package arrangement ###

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

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

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

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

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

  94. ######################################################################
  95. # add_deps is used to add the lost dependencies.
  96. # add_deps is a map which key is the package and the value is the list of
  97. #   the packages that the package depends.
  98. # For example:
  99. #  { 'libacl1-2.2.4-1.i386.rpm' : ['libattr1-2.2.0-1.i386.rpm'] }
  100. # 这里是给那些在制作rpm包时没写依赖关系,但安装的时候需要有顺序的包准备的。格式可以参考下面的,一般情况下,不用管它。
  101. #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']}

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

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


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

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

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

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

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

  149. autopart_profile = {
  150.     'default' : ["Single partition with swap",
  151.                  ("SWAP", "SWAP", "64M"),
  152.                  ("/", "ext3", "100%")],
  153.    
  154.     'common' : ["Separated /boot, /, /home",
  155.                  ("/boot", "ext2", "64M"),
  156.                  ("/", "ext3", "128M"),
  157.                  ("/home", "ext3", "0")],
  158.    
  159.     'custom' :  ["Customed autopart profile",
  160.                  ("SWAP", "SWAP", "15M"),
  161.                  ("/", "ext3", "15M"),
  162.                  ("/usr/local", "ext3", "15M"),
  163.                  ("/tmp", "ext3", "15M"),
  164.                  ("/home", "ext3", "0")]
  165.     }

复制代码


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

使用道具 举报

发表于 2008-7-4 16:54:13 | 显示全部楼层
今天看到了se兄的这个帖,就把MI源码下载下来了,正好我现在在学习PYTHON,可以好好去研究一下了,呵!

支持se兄,支持linux,支持magic!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-25 21:27 , Processed in 0.053494 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表