MagicInstaller 制作 ISO 修正版下载
http://www.magiclinux.org/people/levindu/MagicInstaller/ToKanker/MagicInstaller.exp-1.3.tarhttp://www.magiclinux.org/people/levindu/MagicInstaller/ToKanker/MagicInstaller.exp-1.3.tar.md5sum
使用方法:
http://www.magiclinux.org/people/levindu/MagicInstaller/ToKanker/README
specinfo.py 和 post_install.sh 可以参照
http://www.magiclinux.org/people/levindu/MagicInstaller/ToKanker/specinfo.py
http://www.magiclinux.org/people/levindu/MagicInstaller/ToKanker/post_install.sh
大家自己在 spec 目录下建立 一个 packages 并把系统中的 rpm 放进去即可。
如果需要多包含一些工具在光盘中,可以在 spec 下加一个 addfiles 文件夹,并把需要添加的工具放在里面。如 loadlin.exe,install.bat 等。
希望有能力的朋友能做一下包的分组工作(即自定义安装),分组的方法见 specinfo.py。(据 sejishikong 测试有问题)
Magic Installer 的 svn 开发服务器地址:
svn co https://ako.3322.org/svn/repos/svn-MagicInstaller/trunk MagicInstaller 首发!谢谢kanker! to kanker
这个是不是zslevin刚刚修正过的! 是。 分组功能(选择安装)目前并不正常,如果分组,选择分组的安装的话,会停在搜索软件包那里.
在控制台的提示是:
AttributeError: mistep_takeactions instance has no attribute 'disk_map' 先留名关注,再去看看! 下载了,不过暂时没有用它,因为我RPM打包都没学好,特别是没能把在编译Qt时把插件一起打包进去。 呵,提醒一下大家,做包时要用 root 帐号。
还要注意的是,这个做包过程我们一般在 ML 上进行,其它平台如 redhat, redflag 我自己是没有试过,可能会有问题。
FAQ
===
1. 提示没有 scons 命令
上 http://www.scons.org 下载安装。 * Magic Installer ISO 版的使用说明
1. 将 MagicInstaller.iso.tar.bz2 解压后
2. 进入解压后的目录(以下的步骤均指在该目录下)
3. 修改 ./spec/packages 链接, 指向用来生成 ISO 的 RPM 的目录
4. 修改 ./spec/specinfo.py 文件, 这里是 ISO 配置的信息
5. OK, 直接运行 scons
6. 在 ./result 目录里可以见到生成好的 ISO, 就这么简单.
根本没有scons这个命令!?? result这个目录是不是要自己创建的!还是自动创建的? 发现同样是一直检测硬盘(还是检测sdb, 然后出错!)
明明zslevin给我测试的测试文件可以通过测试:
结果如下!
----device_probe_all() result----
[('/dev/sda', 156301488L, 'ATA ST380013AS')]
----get_all_partitions() result----
Device is /dev/sda
(1, , 0, 39070017L, 'fat32', 'N/A', 63L, 39070079L, )
(2, , 2, 117134640L, 'N/A', 'N/A', 39070080L, 156204719L, )
(5, [], 1, 58605057L, 'fat32', 'N/A', 39070143L, 97675199L, )
(6, [], 1, 20482812L, 'reiserfs', 'N/A', 97675263L, 118158074L, )
(7, [], 1, 1028097L, 'linux-swap', 'N/A', 118158138L, 119186234L, )
(8, [], 1, 22488102L, 'fat32', 'N/A', 119186298L, 141674399L, )
(9, , 1, 7181937L, 'fat32', 'N/A', 141674463L, 148856399L, )
(10, , 1, 7348257L, 'fat32', 'N/A', 148856463L, 156204719L, )
(3, , 0, 91665L, 'fat32', 'N/A', 156204720L, 156296384L, )
但是为什么新做的最简单iso仍然无法通过硬盘检测啊!
出错如下:magic.actions.server.log文件的内容Traceback (most recent call last):
File "/usr/bin/magic.actions.server", line 115, in ?
result = eval('long_operations.%s(mia, id, *params)' % method)
File "<string>", line 0, in ?
File "operations/parted.py", line 67, in device_probe_all
kudzu.PROBE_ALL))
File "operations/parted.py", line 64, in <lambda>
devlist = map(lambda hd: parted.PedDevice.get(os.path.join('/dev', hd.device)),
parted.error: Error: Error opening /dev/sdb: No medium found
现在求rc1 或beta3的mi--最好是rc1的mi!
苦!只有rc1和beta3的mi可以进行安装啊! 贴上mi生成的parted.py(由tmp/MagicInstaller.exp-1.31/MagicInstaller.exp/tmp/root.initrd/usr/share/MagicInstaller/operations/parted.py得到)
(不可以通过硬盘测试)
#!/usr/bin/python
# Copyright (C) 2003, Charles Wang.
# Author:Charles Wang <[email protected]>
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANT; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public LIcense for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, 59 Temple
# Place - Suite 330, Boston, MA 02111-1307, USA.
from gettext import gettext as _
import iconv
import sys
import kudzu
import parted
import isys
# Because the short operation and long operation are run in different process,
# they can't share the parted results. So all operations except status-free
# operation have to be 'long' even if it can terminate immediately.
if operation_type == 'short':
# Status-free operations.
def all_file_system_type():
fstype_list = []
fstype = parted.file_system_type_get_next()
while fstype:
if fstype_map.has_key(fstype.name):
fstype_list.append(fstype.name)
fstype = parted.file_system_type_get_next(fstype)
returnfstype_list
def all_disk_type():
dtype_list = []
dtype = parted.disk_type_get_next()
while dtype:
dtype_list.append(dtype.name)
dtype = parted.disk_type_get_next(dtype)
returndtype_list
elif operation_type == 'long':
# Status globals
parted_MIN_FREESPACE = 2048# 1M
all_harddisks = {}
# Status-Related operations.
def device_probe_all(mia, operid, dummy):
def get_device_list():
result = []
hd_list = kudzu.probe(kudzu.CLASS_HD,
kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC,
kudzu.PROBE_ALL)
for hd in hd_list:
try:
dev = parted.PedDevice.get(os.path.join('/dev/', hd.device))
except:
pass
else:
result.append(dev)
return result
global all_harddisks
mia.set_step(operid, 0, -1)
result = []
# The following commented code is implemented by kudzu.
devlist = get_device_list()
if devlist:
for dev in devlist:
newdisklabel = None
try:
disk = parted.PedDisk.new(dev)
except parted.error:
# For the disk without any disk label, create it.
newdisklabel = 'y'
disk = dev.disk_new_fresh(parted.disk_type_get('msdos'))
# Model might contain GB2312, it must be convert to Unicode.
model = iconv.iconv('gb2312', 'utf8', dev.model).encode('utf8')
result.append((dev.path, dev.length, model))
all_harddisks = (dev, disk, newdisklabel)
returnresult
def get_all_partitions(mia, operid, devpath):
def part2result(part):
flags = []
avaflags = []
label = 'N/A'
if part.is_active() != 0:
for f in range(parted.PARTITION_FIRST_FLAG,
parted.PARTITION_LAST_FLAG + 1):
if part.is_flag_available(f):
avaflags.append(f)
if part.get_flag(f):
flags.append(f)
if part.disk.type.check_feature(parted.DISK_TYPE_PARTITION_NAME):
label = part.get_name()
if part.fs_type:
fs_type_name = part.fs_type.name
else:
fs_type_name = 'N/A'
return (part.num, flags, part.type, part.geom.length,
fs_type_name, label, part.geom.start, part.geom.end, avaflags)
result = []
if all_harddisks.has_key(devpath):
disk = all_harddisks
if disk:
part = disk.next_partition()
while part:
if part.type & parted.PARTITION_METADATA == 0:
result.append(part2result(part))
part = disk.next_partition(part)
returnresult
def get_disk_type(mia, operid, devpath):
if all_harddisks.has_key(devpath):
disk = all_harddisks
if disk:
if disk.type.check_feature(parted.DISK_TYPE_PARTITION_NAME):
support_partition_name = 'true'
else:
support_partition_name = 'false'
return (disk.type.name, support_partition_name)
return('N/A', 'false')
def _get_left_bound(sector, disk):
under_sector = disk.get_partition_by_sector(sector)
if not under_sector:
returnsector
if under_sector.type & parted.PARTITION_FREESPACE:
returnunder_sector.geom.start
else:
returnsector
def _get_right_bound(sector, disk):
under_sector = disk.get_partition_by_sector(sector)
if not under_sector:
returnsector
if under_sector.type & parted.PARTITION_FREESPACE:
returnunder_sector.geom.end
else:
returnsector
def _grow_over_small_freespace(geom, disk):
if geom.length < parted_MIN_FREESPACE * 5:
returngeom
start = _get_left_bound(geom.start, disk)
if start >= geom.end:
returnNone
if geom.start - start < parted_MIN_FREESPACE:
geom.set_start(start)
end = _get_right_bound(geom.end, disk)
if end <= geom.start:
returnNone
if end - geom.end < parted_MIN_FREESPACE:
geom.set_end(end)
returngeom
def add_partition(mia, operid, devpath, parttype, fstype, start, end):
if all_harddisks.has_key(devpath):
(dev, disk, dirty_or_not) = all_harddisks
if disk:
constraint = dev.constraint_any()
if parttype == 'primary':
parttype = 0
elif parttype == 'extended':
parttype = parted.PARTITION_EXTENDED
elif parttype == 'logical':
parttype = parted.PARTITION_LOGICAL
if fstype != 'N/A':
fstype = parted.file_system_type_get(fstype)
else:
fstype = None
try:
newpart = disk.partition_new(parttype, fstype, start, end)
newgeom = _grow_over_small_freespace(newpart.geom, disk)
if newgeom:
newpart.geom.set_start(newgeom.start)
newpart.geom.set_end(newgeom.end)
disk.add_partition(newpart, constraint)
if fstype:
newpart.set_system(fstype)
exceptparted.error:
exc_info = sys.exc_info()
return (-1, str(exc_info))
all_harddisks = (dev, disk, 'y')
return (newpart.geom.start, '')
return (-1, _("Can't find the specified disk."))
def set_flags_and_label(mia, operid, devpath, part_start,
true_flags, false_flags, set_label, label):
if all_harddisks.has_key(devpath):
disk = all_harddisks
if disk:
part = disk.next_partition()
while part:
if part.geom.start == part_start:
for tf in true_flags:
part.set_flag(tf, 1)
for ff in false_flags:
part.set_flag(ff, 0)
if set_label == 'true':
part.set_name(label)
break
part = disk.next_partition(part)
all_harddisks = (all_harddisks, disk, 'y')
return0
def delete_partition(mia, operid, devpath, part_start):
if all_harddisks.has_key(devpath):
disk= all_harddisks
if disk:
part = disk.next_partition()
while part:
if part.geom.start == part_start:
disk.delete_partition(part)
break
part = disk.next_partition(part)
all_harddisks = (all_harddisks, disk, 'y')
return get_all_partitions(mia, operid, devpath)
def reload_partition_table(mia, operid, devpath):
if all_harddisks.has_key(devpath):
dev = all_harddisks
try:
all_harddisks = (dev, parted.PedDisk.new(dev), None)
except parted.error:
dltype = parted.disk_type_get('msdos')
all_harddisks = (dev, dev.disk_new_fresh(dltype), 'y')
return 0
def disk_new_fresh(mia, operid, devpath, dltype):
dltype = parted.disk_type_get(dltype)
if dltype and all_harddisks.has_key(devpath):
dev = all_harddisks
all_harddisks = (dev, dev.disk_new_fresh(dltype), 'y')
return 0
def get_all_dirty_disk(mia, operid, dummy):
mia.set_step(operid, 0, -1)
result = []
for devpath in all_harddisks.keys():
if all_harddisks:
result.append(devpath)
returnresult
def commit_devpath(mia, operid, devpath):
mia.set_step(operid, 0, -1)
if all_harddisks.has_key(devpath):
disk= all_harddisks
if disk:
try:
disk.commit()
all_harddisks = (all_harddisks, disk, None)
except parted.error, errmsg:
returnstr(errmsg)
return0
def format_partition(mia, operid, devpath, part_start, fstype):
mia.set_step(operid, 0, -1)
if not fstype_map.has_key(fstype):
errmsg = _('Unrecoginzed filesystem %s.')
return errmsg % fstype
if fstype_map == '':
errmsg = _('Format %s is not supported.')
return errmsg % fstype
if not all_harddisks.has_key(devpath):
return _('No such device: ') + devpath
disk = all_harddisks
if not disk:
return _('Not any partition table found on: ') + devpath
part = disk.next_partition()
while part:
if part.geom.start != part_start:
part = disk.next_partition(part)
continue
if fstype_map == 'internal':
fstype = parted.file_system_type_get(fstype)
try:
fs = part.geom.file_system_create(fstype)
del(fs)
part.set_system(fstype)
disk.commit()
return0
except parted.error, errmsg:
returnstr(errmsg)
else:
cmd = '%s %s%d' % (fstype_map, devpath, part.num)
r = os.system(cmd)
if r != 0:
errmsg = _('Run "%s" failed.')
returnerrmsg % cmd
else:
return0
return _('Not any partition found on position: ') + str(part_start)
def _gen_fstab(mount_all_list):
globaltgtsys_root
# Generate fstab.
mountmap = {}
for (mntdir, devfn, fstype) in mount_all_list:
if fstype == 'linux-swap':continue
if fstype in ('fat32', 'fat16'):
mountmap = (devfn, fstype_map,
'iocharset=cp936,umask=0,defaults', 0, 0)
elif mntdir == '/':
mountmap = (devfn, fstype_map,
'defaults', 1, 1)
else:
mountmap = (devfn, fstype_map,
'defaults', 0, 0)
mountmap['/dev/pts'] = ('none', 'devpts', 'gid=5,mode=620', 0, 0)
mountmap['/proc'] = ('none', 'proc', 'defaults', 0, 0)
mountmap['/sys'] = ('none', 'sysfs', 'defaults', 0, 0)
mountmap['/dev/shm'] = ('none', 'tmpfs', 'defaults', 0, 0)
fdlist = kudzu.probe(kudzu.CLASS_FLOPPY,
kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC,
kudzu.PROBE_ALL)
cdlist = kudzu.probe(kudzu.CLASS_CDROM,
kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC,
kudzu.PROBE_ALL)
for fd in fdlist:
mntdir = string.replace(fd.device, 'fd', '/mnt/floppy')
if mntdir == '/mnt/floppy0':mntdir = '/mnt/floppy'
mountmap = (os.path.join('/dev', fd.device),
'auto', 'iocharset=cp936,noauto,user,kudzu,rw,exec,sync', 0, 0)
os.system('mkdir -p %s' % os.path.join(tgtsys_root, mntdir))
if cdlist != []:
cddevlist = map(lambda cd: cd.device, cdlist)
cddevlist.sort()
for cnt in range(len(cddevlist)):
if cnt == 0:
mntdir = '/mnt/cdrom'
else:
mntdir = '/mnt/cdrom%d' % cnt
mountmap = (os.path.join('/dev', cddevlist),
'iso9660,udf', 'iocharset=cp936,noauto,user,kudzu,ro,exec', 0, 0)
devdir = os.path.join(tgtsys_root, 'dev')
os.system('mkdir -p %s' % devdir)
os.system('ln -s %s %s' % \
(cddevlist,
os.path.join(devdir,
os.path.basename(mntdir))))
os.system('mkdir -p %s' % os.path.join(tgtsys_root, mntdir))
cnt = cnt + 1
etcpath = os.path.join(tgtsys_root, 'etc')
if not os.path.isdir(etcpath):
os.makedirs(etcpath)
try:
fstab = file(os.path.join(etcpath, 'fstab'), 'w')
mdkeys = mountmap.keys()
mdkeys.sort()
for mntdir in mdkeys:
(dev, fstype, opts, v1, v2) = mountmap
fstab.write('%-15s %-23s %-11s %-15s %d %d\n' % \
(dev, mntdir, fstype, opts, v1, v2))
for (mntdir, devfn, fstype) in mount_all_list:
if fstype == 'linux-swap':
fstab.write('%-15s %-23s %-11s %-15s %d %d\n' % \
(devfn, 'swap', 'swap', 'defaults', 0, 0))
fstab.close()
except Exception, errmsg:
dolog('Generate fstab failed: %s\n' % str(errmsg))
def mount_all_tgtpart(mia, operid, mount_all_list, firstcall):
global USE_UDEV
if os.path.exists('/tmpfs/debug/nomnttgt'):
dolog('TURN ON: nomnttgt\n')
else:
# Mount all target partition as the user will.
cnt = 0
mia.set_step(operid, cnt, len(mount_all_list))
for (mntpoint, devfn, fstype) in mount_all_list:
if fstype == 'linux-swap':
if firstcall:
try:
isys.swapon(devfn)
except SystemError, em:
errmsg = _('swapon(%s) failed: %s')
errmsg = errmsg % (devfn, str(em))
returnstr(em)
else:
realpath = os.path.join(tgtsys_root, mntpoint)
if not os.path.isdir(realpath):
try:
os.makedirs(os.path.join(tgtsys_root, mntpoint))
except OSError, em:
errmsg = _('Can not make directory %s: %s')
errmsg = errmsg % (realpath, str(em))
returnerrmsg
try:
isys.mount(fstype_map, devfn, realpath, 0, 0)
except SystemError, em:
errmsg = _('Mount %s on %s as %s failed: %s')
errmsg = errmsg % (devfn, realpath, fstype, str(em))
returnerrmsg
cnt = cnt + 1
mia.set_step(operid, cnt, len(mount_all_list))
# Mount /proc.
procpath = os.path.join(tgtsys_root, 'proc')
if not os.path.isdir(procpath):
os.makedirs(procpath)
if not os.path.exists(os.path.join(procpath, 'cmdline')):
isys.mount('proc', 'proc', procpath, 0, 0)
if firstcall:
_gen_fstab(mount_all_list)
if USE_UDEV:
dolog('Copy device files to target system.')
devdir = os.path.join(tgtsys_root, 'dev')
if not os.path.isdir(devdir):
os.makedirs(devdir)
os.system('cp -a /dev/* %s' % devdir)
return0
def umount_all_tgtpart(mia, operid, mount_all_list, lastcall):
# Umount proc.
procdir = os.path.join(tgtsys_root, 'proc')
try:
isys.umount(procdir)
except Exception, errmsg:
dolog('Umount %s failed: %s\n' % (procdir, str(errmsg)))
if os.path.exists('/tmpfs/debug/nomnttgt'):
dolog('TURN ON: nomnttgt\n')
return 0
# Copy the installation log into the target system.
if lastcall:
logdir = os.path.join(tgtsys_root, 'var/log/MagicInstaller')
os.system('mkdir -p %s' % logdir)
os.system('cp /tmpfs/var/log/* %s' % logdir)
os.system('cp /tmpfs/grub.* %s' % logdir)
os.system('cp %s/* %s' % (MBRoot, logdir))
# Umount all filesystems and swapoff all swaps.
cnt = 0
mount_all_list.reverse()
mia.set_step(operid, cnt, len(mount_all_list))
for (mntpoint, devfn, fstype) in mount_all_list:
if fstype == 'linux-swap':
if lastcall:
try:
isys.swapoff(devfn)
except SystemError, em:
errmsg = _('swapoff(%s) failed: %s')
errmsg = errmsg % (devfn, str(em))
returnerrmsg
else:
realpath = os.path.join(tgtsys_root, mntpoint)
try:
isys.umount(realpath)
except SystemError, em:
errmsg = _('UMount %s failed: %s')
errmsg = errmsg % (realpath, str(em))
returnerrmsg
cnt = cnt + 1
mia.set_step(operid, cnt, len(mount_all_list))
return0 测时时使用的t_parted.py(可以通过硬盘测试)
#!/usr/bin/python
# Copyright (C) 2003, Charles Wang.
# Author:Charles Wang <[email protected]>
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANT; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public LIcense for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, 59 Temple
# Place - Suite 330, Boston, MA 02111-1307, USA.
import os
import kudzu
import sys
sys.path.insert(0, '.')
import parted
all_harddisks = {}
def device_probe_all():
def get_device_list():
result = []
hd_list = kudzu.probe(kudzu.CLASS_HD,
kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC,
kudzu.PROBE_ALL)
for hd in hd_list:
try:
dev = parted.PedDevice.get(os.path.join('/dev/', hd.device))
except:
pass
else:
result.append(dev)
return result
global all_harddisks
result = []
# The following commented code is implemented by kudzu.
devlist = get_device_list()
if devlist:
for dev in devlist:
newdisklabel = None
try:
disk = parted.PedDisk.new(dev)
except parted.error:
# For the disk without any disk label, create it.
print 'Warning: parted.error in device_probe_all()'
newdisklabel = 'y'
disk = dev.disk_new_fresh(parted.disk_type_get('msdos'))
model = dev.model
result.append((dev.path, dev.length, model))
all_harddisks = (dev, disk, newdisklabel)
returnresult
def get_all_partitions(devpath):
def part2result(part):
flags = []
avaflags = []
label = 'N/A'
if part.is_active() != 0:
for f in range(parted.PARTITION_FIRST_FLAG,
parted.PARTITION_LAST_FLAG + 1):
if part.is_flag_available(f):
avaflags.append(f)
if part.get_flag(f):
flags.append(f)
if part.disk.type.check_feature(parted.DISK_TYPE_PARTITION_NAME):
label = part.get_name()
if part.fs_type:
fs_type_name = part.fs_type.name
else:
fs_type_name = 'N/A'
return (part.num, flags, part.type, part.geom.length,
fs_type_name, label, part.geom.start, part.geom.end, avaflags)
result = []
if all_harddisks.has_key(devpath):
disk = all_harddisks
if disk:
part = disk.next_partition()
while part:
if part.type & parted.PARTITION_METADATA == 0:
result.append(part2result(part))
part = disk.next_partition(part)
returnresult
print '----device_probe_all() result----'
print device_probe_all()
print '----get_all_partitions() result----'
for devpath in all_harddisks.keys():
print 'Device is %s' % devpath
for item in get_all_partitions(devpath):
print item 制作mi的系统是ml2.0的rc1(最高只能安装到rc1)!
制作mi过程很顺利!但是得到的iso还是不能够跳过硬盘检测! 试了sata增强模式,无法发现iso.
再试sata模式,发现可以发现iso(但是把硬盘识别为hda的),和rc1一样!
好不容易搞出的2.0正式版iso,要设成sata模式才可以发现iso,但是识别为hda,安装后却无法启动!已经把fstab、mtab里面的hda都改为sda了!还是无法启动!(但是rc1却是可以启动的!)
我晕!可能又要刻盘才可以安装了!