|
发表于 2007-10-17 11:37:18
|
显示全部楼层
apt-get update #更新源
apt-get install mkisofs debootstrap unionfs-modules-`uname -r`
#获取需要的软件
# Step 1 : make directory
# 第一步,建立制作的目录
export workdir=/tmp/cdi
#设置变量,以后就可以使用$workdir代替/tmp/cdi
mkdir -p $workdir/{roiso,rwiso,newiso,scripts,bootstrap}
#建目录/tmp/cdi,并建立roiso,rwiso,newiso,scripts,bootstrap
# Step 2 : download the d-i image and make it(iso) writable with unionfs
#第二步,下载安装镜像并挂载使他能修改
cd $workdir #进入工作目录
#export http_proxy=http://192.168.213.1:5865/
#如果需要代理上网,请去掉上面的#号,并修改地址
#下载 ISO文件,如果你电脑上已经有了,可以直接挂载
wget http://debian.cn99.com/debian-cd ... r1-i386-netinst.iso
#挂载镜像
mount -o loop $workdir/debian-40r1-i386-netinst.iso $workdir/roiso
#挂载到不同目录,并给予 newiso rwiso可写权限
mount -t unionfs -o dirs=$workdir/rwiso=rw workdir/roiso/=ro unionfs $workdir/newiso
# Step 3a : download the indices file ( to update the pool)
#下载索引文件,用户更新软件库
cd $workdir/scripts/
wget http://debian.cn99.com/debian/indices/override.etch.contrib.gz
wget http://debian.cn99.com/debian/in ... etch.contrib.src.gz
wget http://debian.cn99.com/debian/in ... ch.extra.contrib.gz
wget http://debian.cn99.com/debian/indices/override.etch.extra.main.gz
wget http://debian.cn99.com/debian/in ... h.extra.non-free.gz
wget http://debian.cn99.com/debian/in ... debian-installer.gz
wget http://debian.cn99.com/debian/indices/override.etch.main.gz
wget http://debian.cn99.com/debian/indices/override.etch.main.src.gz
wget http://debian.cn99.com/debian/indices/override.etch.non-free.gz
wget http://debian.cn99.com/debian/in ... tch.non-free.src.gz
gunzip *.gz
#export http_proxy=
# Step 3b : create the configration for the apt-ftparchive
#扩展配置文件,以便在后面使用apt-ftparchive定制光盘的库索引文件
cd $workdir/scripts/
cat >>apt.conf <<EOF #以下内容为修改的apt.confn内容
APT {
FTPArchive {
Release {
Origin "Debian";
Label "Debian";
Suite "stable";
Version "4.0";
Codename "etch";
Architectures "i386";
Components "main contrib non-free";
Description "Debian STABLE distribution - Released";
};
};
};
EOF
#我对上面做了更改,因为etch已经是正式版了,而且我定制的包含了non-free的内容,所以加入了
cat >>config_binary <<EOF #把下面的内容写入config_binary
Dir {
ArchiveDir "$workdir/newiso/";
OverrideDir "$workdir/scripts/";
CacheDir "$workdir/";
};
TreeDefault {
Directory "pool/";
};
BinDirectory "pool/main" {
Packages "dists/etch/main/binary-i386/Packages";
BinOverride "override.etch.main";
ExtraOverride "override.etch.extra.main";
};
BinDirectory "pool/contrib" {
Packages "dists/etch/contrib/binary-i386/Packages";
BinOverride "override.etch.contrib";
ExtraOverride "override.etch.extra.contrib";
};
#我在这里增加一段
BinDirectory "pool/non-free" {
Packages "dists/etch/contrib/binary-i386/Packages";
BinOverride "override.etch.non-free";
ExtraOverride "override.etch.extra.non-free";
};
#段落格式介绍下
#BinDirectory "pool/non-free" { 二进制文件目录,一般为non-free main contrib
#BinOverride "override.etch.non-free";对应上面下载的包名字
#ExtraOverride "override.etch.extra.non-free";对应上面下载的包名字
#};
Default {
Packages {
Extensions ".deb"; #使用.deb包
Compress ". gzip"; #解压缩使用gzip
};
Contents {
Compress "gzip";#解压缩使用gzip
};
};
EOF
cat >>config_installer <<EOF
#将下面的内容写入config_installer 这个是为安装准备的,使用UDEB文件,一般情况下不使用contrib,non-free
Dir {
ArchiveDir "$workdir/newiso/";
OverrideDir "$workdir/scripts/";
CacheDir "$workdir/";
};
TreeDefault {
Directory "pool/";
};
BinDirectory "pool/main" {
Packages "dists/etch/main/debian-installer/binary-i386/Packages";
BinOverride "override.etch.main";
ExtraOverride "override.etch.extra.main";
};
Default {
Packages {
Extensions ".udeb";
Compress ". gzip"
};
Contents {
Compress "gzip"
};
};
EOF
# Step 4 : build the bootstrap and download the extra package
# move the downloaded deb to the d-i ISO 's pool
# 构建bootstrap系统,下载需要的其他包
#基本就是在使用光盘的软件在bootstrap目录构建一个基本的系统,然后在下载安装你需要的软件的包,使用apt-get解决依赖问题
cd $workdir #进入工作目录
debootstrap etch $workdir/bootstrap http://debian.cn99.com/debian/
#debootstrap etch $workdir/bootstrap http://127.0.0.1:9999/debian/
#上面这一部我不知道做啥的,那位给个解答,我观察的结果是设置bootstrap系统的sources.list,而且,在这一步后,你可以暂停,然后修改bootstrap/etc/apt/sources.list,因为我发现他里面只有main,我加入了我希望有的mplayer源,non-free,和contrib
chroot $workdir/bootstrap apt-get update #对bootstrap进行源更新,这就是上面为啥我要加mplayer源的结果
chroot $workdir/bootstrap apt-get -y install apt-move #安装apt-move,对于-y,我想很多人都明白了,这是默认安装选y的,免得执行中老是按Y
chroot $workdir/bootstrap apt-get clean #清楚bootstrap里的缓存文件,这样你的/var/cache/apt/archive目录里就只有后面下载的软件包,避免和源光盘重复
chroot $workdir/bootstrap apt-get -y install --download-only eject file sudo vim-tiny console-common kbd locales gdm xfce4 desktop-base x-window-system-core xresprobe #这部就是定制软件,注意,只下载,并自动解决依赖问题
chroot $workdir/bootstrap apt-move update#按源的方式放置软件,就是放到pool下,分main non-free contrib 然后再用字母开头分目录,看过debian.cn99.com的源结构就知道了
cp -a $workdir/bootstrap/mirrors/debian/pool $workdir/newiso/ 把分好类的软件拷贝到newiso目录,这是我们将打包为光盘的目录
chroot $workdir/bootstrap apt-get clean #清除bootstrap目录的缓存,他们已经完成任务了,可以退休了
# Step 5 : update Release file and indices #重置新目录的软件库索引文件
cd $workdir/newiso
apt-ftparchive -c $workdir/scripts/apt.conf generate $workdir/scripts/config_installer
apt-ftparchive -c $workdir/scripts/apt.conf generate $workdir/scripts/config_binary
apt-ftparchive -c $workdir/scripts/apt.conf release dists/etch > ./dists/etch/Release
#大家注意没,上面的就是第三步我们做的几个配置文件,如果你在上面没有加入non-free,你会发现,你的光盘里如果有non-free,但使用apt-get 发现不了
# Step 6a : create the preseed.cfg to auto-install the extra packages
#这一步比较关键,我们需要系统自动安装些啥软件就这里了
cd $workdir/newiso/.disk/
#进入newiso的.disk,这是个隐藏文件夹
cat >>preseed.cfg <<EOF
#用下面的内容定制安装完基本系统后需要装的软件.
# Individual additional packages to install
d-i pkgsel/include string eject file sudo vim-tiny console-common kbd locales gdm xfce4 desktop-base x-window-system-core xresprobe
#上面的格式是这样的 :d-i pkgsel/include string 在这后面加入你要安装的软件包名字
tasksel tasksel/first multiselect standard, xfce-desktop#这里的xfce-desktop可以修改的,我就改成了gnome-desktop
EOF
# Step 6b : append the boot parameter to include the preseed.cfg
#追加上面的定制文件到安装引导,这样可以不用修改isolinux
cd $workdir/newiso/isolinux
#sed isolinux.cfg to append : preseed/file=/cdrom/preseed.cfg #在引导的项目加入preseed/file=/cdrom/.disk/preseed.cfg使他执行
cp isolinux.cfg isolinux.cfg.org
sed -e '15,28s:gz:gz preseed/file=/cdrom/.disk/preseed.cfg:g' isolinux.cfg.org > isolinux.cfg
#上面这一步,就是在每个启动的选项后加入这个配置文件,在安装完基本系统后,他会安装我们定制的文件
#大家到这里就可以看看你们的/newiso下的isolinux.cfg
#为啥没安装,我开始也认为错了,知道我明白这只是改了光盘的启动,如果我们硬盘安装的话,根本在启动的时候没追加这个项目,所以,我们制作的光盘如果硬盘安装#,肯定执行不了了
# Step 7 : create the ISO
#建立ISO文件
cd $workdir
mkisofs -o ./cdi.iso -r -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat ./newiso/
#mkisofs -o 建立的文件名.iso -r -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin(光盘启动文件) -c isolinux/boot.cat ./newiso/(对newiso目录操作)
# Step 8 :清除垃圾
umount $workdir/newiso $workdir/roiso
#mv $workdir/cdi.iso ~
#rm -rf $workdir
最后,我们上一步制作的ISO在/tmp里,重启就没有了.如果你满意的话,把他放到你的其他目录 |
|