定制Ubuntu安装CD:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Lpzgbd留言 | 贡献
New page: 定制Ubuntu安装CD 原文出处:https://wiki.ubuntu.com/InstallCDCustomizationHowTo 原文作者:未知 授权许可:创作共用协议 翻译人员:ctqucl 校对人员:...
 
Oneleaf留言 | 贡献
无编辑摘要
第1行: 第1行:
定制Ubuntu安装CD
== 定制Ubuntu安装CD ==
 
----
原文出处:https://wiki.ubuntu.com/InstallCDCustomizationHowTo
原文出处:https://wiki.ubuntu.com/InstallCDCustomizationHowTo


原文作者:未知
原文作者:未知


授权许可:创作共用协议
授权许可:[http://www.creativecommons.cn/licenses/by-nc-sa/1.0/ 创作共用协议]


翻译人员:ctqucl
翻译人员:ctqucl
第14行: 第14行:


文章状态:
文章状态:
----


定制Ubuntu CD的过程并不复杂,但是她有一些繁琐和过分的讲究。我对这过程的所知并不完美,因此,希望有人可以作适当修改。
定制Ubuntu CD的过程并不复杂,但是她有一些繁琐和过分的讲究。我对这过程的所知并不完美,因此,希望有人可以作适当修改。


安装CD有三个主要部分:
安装CD有三个主要部分:
 
* 启动引导器:(如ISOLINUX用于amd64/i386,yaboot用于powerpc)开机时内核映象的选择与配置;
    * 启动引导器:(如ISOLINUX用于amd64/i386,yaboot用于powerpc)开机时内核映象的选择与配置;
* Debian安装程序(d-i):其实就是一个特殊的微Ubuntu系统;
    * Debian安装程序(d-i):其实就是一个特殊的微Ubuntu系统;
* Debian软件库:放在"pool"和"dists"目录,它将占据光盘的大部分空间。
    * Debian软件库:放在"pool"和"dists"目录,它将占据光盘的大部分空间。  
 
建立这个新的CD就包涵了这三部分的修改。
建立这个新的CD就包涵了这三部分的修改。


用"Presseed"文件修改安装行为
=== 用"Presseed"文件修改安装行为 ===


当CD 启动时,Linux内核就被装载且开始安装任务。安装程序的行为可以用一个"preseed"文件来修改,这些文件给Debian安装程序(d-i)回答如何配置软件包或其它相关的问题。如果您仔细看你的安装CD,您会找到这些选项(例如server,expert,oem)都有对应的preseed文件。
当CD启动时,Linux内核就被装载且开始安装任务。安装程序的行为可以用一个"preseed"文件来修改,这些文件给Debian安装程序(d-i)回答如何配置软件包或其它相关的问题。如果您仔细看你的安装CD,您会找到这些选项(例如server,expert,oem)都有对应的preseed文件。


所以,假设您想在一群的相同配置电脑上安装breezy,并且您已经知道安装时必问问题的答案(您所在的国家和时区,您你的键盘布局,您的网络设置,您需要如何分区等等)。您可以通过"preseed"在一简单的配置文件里回答这些问题.
所以,假设您想在一群的相同配置电脑上安装breezy,并且您已经知道安装时必问问题的答案(您所在的国家和时区,您你的键盘布局,您的网络设置,您需要如何分区等等)。您可以通过"preseed"在一简单的配置文件里回答这些问题.


改变isolinux.cfg确定您的preseed
==== 改变isolinux.cfg确定您的preseed ====


首先,您必须告诉"d-i"找到您的preseed文件的正确位置。在标准的光盘上有个/preseed目录;您可以把您的这些文件放这里。您要修改启动引导器的配置文件/isolinux/isolinux.cfg中的相关内核参数,来告诉"d-i"找到这个文件。我的文件里有下列行:
首先,您必须告诉"d-i"找到您的preseed文件的正确位置。在标准的光盘上有个/preseed目录;您可以把您的这些文件放这里。您要修改启动引导器的配置文件/isolinux/isolinux.cfg中的相关内核参数,来告诉"d-i"找到这个文件。我的文件里有下列行:


<pre><nowiki>
DEFAULT /install/vmlinuz
DEFAULT /install/vmlinuz
APPEND  preseed/file=/cdrom/preseed/learnexchange.seed kbd-chooser/method=us debian-installer/locale=en_CA vga=normal initrd=/install/initrd.gz ramdisk_size=16384 root=/dev/rd/0 DEBCONF_PRIORITY=critical debconf/priority=critical rw --
APPEND  preseed/file=/cdrom/preseed/learnexchange.seed kbd-chooser/method=us debian-installer/locale=en_CA vga=normal initrd=/install/initrd.gz ramdisk_size=16384 root=/dev/rd/0 DEBCONF_PRIORITY=critical debconf/priority=critical rw --
</nowiki></pre>


"DEFAULT" 是指我在boot提示符下直接按回车键装载的内核。APPEND 包涵了要传给内核的参数。preseed/file 是这儿最重要的参数;接着的那两个指出我的键盘布局用及本地为加拿大;DEBCONF_PRIORITY 用来确定我不想看到不必要的配置软件包提问。
"DEFAULT"是指我在boot提示符下直接按回车键装载的内核。APPEND 包涵了要传给内核的参数。preseed/file 是这儿最重要的参数;接着的那两个指出我的键盘布局用及本地为加拿大;DEBCONF_PRIORITY 用来确定我不想看到不必要的配置软件包提问。


根据你的情况小心修改这文件.
根据你的情况小心修改这文件.


写preseed文件
==== 写preseed文件 ====


这里有很多实例;看看这个在安装盘里的--server.seed:
这里有很多实例;看看这个在安装盘里的--server.seed:
 
<pre><nowiki>
# Don't install usplash.
d-i    base-installer/kernel/linux/extra-packages-2.6  string
d-i    base-installer/kernel/linux/extra-packages-2.6  string
# Desktop system not installed; don't waste time and disk space copying it.
d-i    archive-copier/desktop-task    string ubuntu-standard
d-i    archive-copier/desktop-task    string ubuntu-standard
d-i    archive-copier/ship-task        string
d-i    archive-copier/ship-task        string
# Only install the standard system and language packs in the second stage.
base-config    base-config/package-selection  string ~t^ubuntu-standard$
base-config    base-config/package-selection  string ~t^ubuntu-standard$
base-config    base-config/language-pack-patterns      string language-pack-$LL
base-config    base-config/language-pack-patterns      string language-pack-$LL
# No language support packages.
base-config    base-config/install-language-support    boolean false
base-config    base-config/install-language-support    boolean false
</nowiki></pre>


(Note that the version of this file on breezy CD images was buggy: it set base-config/package-selection to "~tubuntu-standard" rather than "~t^ubuntu-standard$". Use the new version in preference; the old one will break with Ubuntu 6.04.)
(Note that the version of this file on breezy CD images was buggy: it set base-config/package-selection to "~tubuntu-standard" rather than "~t^ubuntu-standard$". Use the new version in preference; the old one will break with Ubuntu 6.04.)


首先注意格式,有 4 个部分:
首先注意格式,有 4 个部分:  


  1. 取得变量的程序名称
** 取得变量的程序名称
  2. 答案的变量名
** 答案的变量名
  3. 变量类型
** 变量类型
  4. 变量值  
** 变量值


两个要注意的地方:现在,d-i 期望有精确的类型和值;在breezy这个版本不支持用 \ 来处理多行(新的版本支持)。
两个要注意的地方:现在,d-i 期望有精确的类型和值;在breezy这个版本不支持用 \ 来处理多行(新的版本支持)。


我建议您从一些现有的 preseed 来修改--这儿有一个可以用的 点击。 如果您没能在这儿找到,那就试着执行这些命令:
我建议您从一些现有的 preseed 来修改--这儿有一个可以用的
[http://archive.ubuntu.com/ubuntu/dists/breezy/main/installer-i386/current/doc/manual/en/apcs01.html 点击]。 如果您没能在这儿找到,那就试着执行这些命令:


<pre><nowiki>
debconf-get-selections --installer > somefile.txt
debconf-get-selections --installer > somefile.txt
debconf-get-selections >> somefile.txt
debconf-get-selections >> somefile.txt
</nowiki></pre>


这会输出一个您在安装时候作出的选择的列表;这文件相当地长,并且实际上不那么适合用在安装盘里。特别是,NOTE: debconf-get-selections 会在类型和只之间放 2 个空格。您得在把她放在安装盘上以前修改他们。
这会输出一个您在安装时候作出的选择的列表;这文件相当地长,并且实际上不那么适合用在安装盘里。特别是,'''NOTE:''' debconf-get-selections 会在类型和只之间放 '''2''' 个空格。您得在把她放在安装盘上以前修改他们。


如果您想让 d-i 安装额外的软件包,或者一个最小的系统,您需要在preseed里修改 "base-config base-config/package-selection"。This should be set to an aptitude pattern; see the aptitude documentation for more information on these. 例如,标准安装一个SSH服务,用这一行:
如果您想让 d-i 安装额外的软件包,或者一个最小的系统,您需要在preseed里修改 "base-config base-config/package-selection"。This should be set to an aptitude pattern; see the aptitude documentation for more information on these. 例如,标准安装一个SSH服务,用这一行:


base-config base-config/package-selection string ~t^ubuntu-standard$|~t^ubuntu-desktop$|~n^openssh-server$
<pre><nowiki>
base-config base-config/package-selection string ~t<sup>ubuntu-standard$|~t^ubuntu-desktop$|~n</sup>openssh-server$
</nowiki></pre>


To install support for additional languages, a different mechanism is available, namely to preseed the detailed locale question asked by the installer in expert mode. See the first column of /usr/share/i18n/SUPPORTED for the locale names you can use here. 例如, 增加孟加拉语和泰米尔语的支持,用这一行:
To install support for additional languages, a different mechanism is available, namely to preseed the detailed locale question asked by the installer in expert mode. See the first column of `/usr/share/i18n/SUPPORTED` for the locale names you can use here. 例如, 增加孟加拉语和泰米尔语的支持,用这一行:


<pre><nowiki>
d-i localechooser/supported-locales multiselect ba_IN, ta_IN
d-i localechooser/supported-locales multiselect ba_IN, ta_IN
</nowiki></pre>


修改pool目录,增加或删除软件包
=== 修改pool目录,增加或删除软件包 ===


也许制定您自己的安装CD的主要原因是想改变所安装软件包;特别是您想增加一些包到CD里。这有好几个方法来做到,不需要完全地理解。最容易的事情是建立一个最小的仓库放您想要增加的包,再在制作光盘镜像文件之前合并到光盘文件体系里。这儿棘手的地方是:制作让Debian软件包管理系统知道这个仓库的相关文件;写一个更高版本的Release文件;并签上 GPG 。下面是我所做的。
也许制定您自己的安装CD的主要原因是想改变所安装软件包;特别是您想增加一些包到CD里。这有好几个方法来做到,不需要完全地理解。最容易的事情是建立一个最小的仓库放您想要增加的包,再在制作光盘镜像文件之前合并到光盘文件体系里。这儿棘手的地方是:制作让Debian软件包管理系统知道这个仓库的相关文件;写一个更高版本的Release文件;并签上 GPG 。下面是我所做的。


    * . 选定一个文件目录作为您的工作空间;在这个目录里,


*.  选定一个文件目录作为您的工作空间;在这个目录里,
<pre><nowiki>
mkdir -p dists/breezy/extras/binary-i386 pool/extras/ isolinux preseed
mkdir -p dists/breezy/extras/binary-i386 pool/extras/ isolinux preseed
</nowiki></pre>


把您修改过的isolinux.cfg放在目录isolinux/,把您的preseed文件放在目录preseed里。 Put your modified isolinux.cfg in isolinux/, and your preseed file in preseed/.
把您修改过的isolinux.cfg放在目录isolinux/,把您的preseed文件放在目录preseed里。
 
Put your modified isolinux.cfg in isolinux/, and your preseed file in preseed/.
    * . 把您需要的所有额外的包放在目录 pool/extras/ 里。您还需要包括一个新版本的 ubuntu-keyring 包,我将马上解释一下
*. 把您需要的所有额外的包放在目录 pool/extras/ 里。您还需要包括一个新版本的 ubuntu-keyring 包,我将马上解释一下
    * . 创建并编辑文件dists/breezy/extras/binary-i386/Release,写入下面的内容:  
*. 创建并编辑文件dists/breezy/extras/binary-i386/Release,写入下面的内容:  


<pre><nowiki>
Archive: breezy
Archive: breezy
Version: 5.10
Version: 5.10
第102行: 第111行:
Label: Ubuntu
Label: Ubuntu
Architecture: i386
Architecture: i386
</nowiki></pre>


    * . 把您做的修改这样合并到CD里:
*. 把您做的修改这样合并到CD里:
        1.
a. 挂载您下载的官方ISO文件:<code><nowiki>mount /path/to/iso /some/mountpoint/ -o loop</nowiki></code>


            挂载您下载的官方ISO文件:mount /path/to/iso /some/mountpoint/ -o loop
b. 把光盘里的全部文件拷贝到某个目录(您会需要1到2G的空间);我用rsync:<code><nowiki>sudo rsync -azvb --delete --backup-dir=/yeowe/usr/cdbuilder/old/ $MOUNT $BUILD</nowiki></code> ( 这儿的 $MOUNT 是挂载点,$BUILD 是额外的包的目录)


            b. 把光盘里的全部文件拷贝到某个目录(您会需要1到2G的空间);我用rsync:sudo rsync -azvb --delete --backup-dir=/yeowe/usr/cdbuilder/old/ $MOUNT $BUILD ( 这儿的 $MOUNT 是挂载点,$BUILD 是额外的包的目录)
c. '''最重要的地方'''. 我们将用apt-ftparchive工具来产生软件包相关和更高版本的Release文件。我们还要用GPG来签这个Release文件。安装程序会用包ubuntu-keyring 的公匙来检测签名。但是您的签名不一样。所以您得建立一个新版本的 ubuntu-keyring 包。这做起来很容易,但是要确保正确无误。下面是执行的命令:


            c. 最重要的地方. 我们将用apt-ftparchive工具来产生软件包相关和更高版本的Release文件。我们还要用GPG来签这个Release文件。安装程序会用包ubuntu-keyring 的公匙来检测签名。但是您的签名不一样。所以您得建立一个新版本的 ubuntu-keyring 包。这做起来很容易,但是要确保正确无误。下面是执行的命令:
<pre><nowiki>
apt-get source ubuntu-keyring
cd ubuntu-keyring--2005.01.11/keyring
gpg --import < ubuntu-archive-keyring.gpg
gpg --list-keys "Your Name"
gpg --export  FBB75451 437D05B5 YOURKEYID > ubuntu-archive-keyring.gpg
cd ..
dpkg-buildpackage -rfakeroot -m"Your Name <[email protected]> -k"Your Name <[email protected]>"
cp ubuntu-keyring*deb $BUILD/pool/extras/
</nowiki></pre>


            apt-get source ubuntu-keyring
OK -- what we've done here is import the 2 Ubuntu keys into your main keyring, then exported them along with your own key into a replacement keyring. "YOURKEYID" should be replaced with the 8-digit hexadecimal code that gpg tells you when you do the --list-keys command above. And really, the best policy would be to do all that first, and copy a version into your $STAGE file structure so that you have it permanently available.
            cd ubuntu-keyring--2005.01.11/keyring
            gpg --import < ubuntu-archive-keyring.gpg
            gpg --list-keys "Your Name"
            gpg --export  FBB75451 437D05B5 YOURKEYID > ubuntu-archive-keyring.gpg
            cd ..
            dpkg-buildpackage -rfakeroot -m"Your Name <[email protected]> -k"Your Name <[email protected]>"
            cp ubuntu-keyring*deb $BUILD/pool/extras/
 
            OK -- what we've done here is import the 2 Ubuntu keys into your main keyring, then exported them along with your own key into a replacement keyring. "YOURKEYID" should be replaced with the 8-digit hexadecimal code that gpg tells you when you do the --list-keys command above. And really, the best policy would be to do all that first, and copy a version into your $STAGE file structure so that you have it permanently available.  


Note: If you do not have an existing gpg signing key, use the following code:
Note: If you do not have an existing gpg signing key, use the following code:
 
<pre><nowiki> gpg --gen-key
    *
</nowiki></pre>
 
      gpg --gen-key  
       


Accept all defaults, select "No expiry", and enter an appropriate passphrase.
Accept all defaults, select "No expiry", and enter an appropriate passphrase.


In order to use apt-ftparchive, we will need to provide it with some defaults. Create the files "apt-ftparchive-deb.conf, "apt-ftparchive-udeb.conf", and "apt-ftparchive-extras.conf" as follows (substitude $BUILD for the absolute path to your BUILD directory, and /path/to/indices to the location of the indices files, which you can download from http://archive.ubuntu.com/ubuntu/indices/ ):
In order to use apt-ftparchive, we will need to provide it with some defaults.
Create the files "apt-ftparchive-deb.conf, "apt-ftparchive-udeb.conf", and "apt-ftparchive-extras.conf" as follows (substitude $BUILD for the absolute path to your BUILD directory, and /path/to/indices to the location of the indices files, which you can download from http://archive.ubuntu.com/ubuntu/indices/ ):


    *
<pre><nowiki>
apt-ftparchive-deb.conf:
Dir {
ArchiveDir "$BUILD";
};


      apt-ftparchive-deb.conf:
TreeDefault {
      Dir {
Directory "pool/";
        ArchiveDir "$BUILD";
};
      };


      TreeDefault {
BinDirectory "pool/main" {
        Directory "pool/";
Packages "dists/breezy/main/binary-i386/Packages";
      };
BinOverride "/path/to/indices/override.breezy.main";
ExtraOverride "path/to/indices/override.breezy.extra.main";
};


      BinDirectory "pool/main" {
Default {
        Packages "dists/breezy/main/binary-i386/Packages";
Packages {
        BinOverride "/path/to/indices/override.breezy.main";
Extensions ".deb";
        ExtraOverride "path/to/indices/override.breezy.extra.main";
Compress ". gzip";
      };
};
};


      Default {
Contents {
        Packages {
Compress "gzip";
          Extensions ".deb";
};
          Compress ". gzip";
        };
      };


      Contents {
</nowiki></pre>
        Compress "gzip";
      };


       
<pre><nowiki>
apt-ftparchive-udeb.conf:
Dir {
ArchiveDir "$BUILD";
};


      apt-ftparchive-udeb.conf:
TreeDefault {
      Dir {
Directory "pool/";
        ArchiveDir "$BUILD";
};
      };


      TreeDefault {
BinDirectory "pool/main" {
        Directory "pool/";
Packages "dists/breezy/main/debian-installer/binary-i386/Packages";
      };
BinOverride "/path/to/indices/override.breezy.main.debian-installer";
};


      BinDirectory "pool/main" {
Default {
        Packages "dists/breezy/main/debian-installer/binary-i386/Packages";
Packages {
        BinOverride "/path/to/indices/override.breezy.main.debian-installer";
Extensions ".udeb";
      };
Compress ". gzip";
};
};


      Default {
Contents {
        Packages {
Compress "gzip";
          Extensions ".udeb";
};
          Compress ". gzip";
</nowiki></pre>
        };
      };


      Contents {
<pre><nowiki>
        Compress "gzip";
apt-ftparchive-extras.conf:
      };
Dir {
       
ArchiveDir "$BUILD";
};


      apt-ftparchive-extras.conf:
TreeDefault {
      Dir {
Directory "pool/";
        ArchiveDir "$BUILD";
};
      };


      TreeDefault {
BinDirectory "pool/extras" {
        Directory "pool/";
Packages "dists/breezy/extras/binary-i386/Packages";
      };
};


      BinDirectory "pool/extras" {
Default {
        Packages "dists/breezy/extras/binary-i386/Packages";
Packages {
      };
Extensions ".deb";
Compress ". gzip";
};
};


      Default {
Contents {
        Packages {
Compress "gzip";
          Extensions ".deb";
};
          Compress ". gzip";
</nowiki></pre>
        };
      };


      Contents {
        Compress "gzip";
      };
       


    * . 现在就用apt-ftparchive来创建Packages和Release文件:
*. 现在就用apt-ftparchive来创建Packages和Release文件:
          o


            cd $BUILD
<pre><nowiki>
            sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-deb.conf
cd $BUILD
            sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-udeb.conf
sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-deb.conf
            sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-extras.conf
sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-udeb.conf
 
sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-extras.conf
            $APTCONF is a file somewhere that looks about like this:  
</nowiki></pre>
 
$APTCONF is a file somewhere that looks about like this:
APT::FTPArchive::Release::Origin "Ubuntu";  
<pre><nowiki>APT::FTPArchive::Release::Origin "Ubuntu";
APT::FTPArchive::Release::Label "Ubuntu";
APT::FTPArchive::Release::Label "Ubuntu";
APT::FTPArchive::Release::Suite "breezy";
APT::FTPArchive::Release::Suite "breezy";
第233行: 第242行:
APT::FTPArchive::Release::Components "main restricted extras";
APT::FTPArchive::Release::Components "main restricted extras";
APT::FTPArchive::Release::Description "Ubuntu Breezy";
APT::FTPArchive::Release::Description "Ubuntu Breezy";
</nowiki></pre>


  1.
a. 给Release文件签gpg:<pre><nowiki>
 
sudo gpg --default-key "MY GPG KEY ID" --output $BUILD/dists/breezy/Release.gpg -ba $BUILD/dists/breezy/Release
      给Release文件签gpg:
</nowiki></pre>
 
      sudo gpg --default-key "MY GPG KEY ID" --output $BUILD/dists/breezy/Release.gpg -ba $BUILD/dists/breezy/Release
 
*. Regenerate the md5 checksums:


*. Regenerate the md5 checksums:<pre><nowiki>
cd $BUILD
cd $BUILD
find . -type f -print0 | xargs -0 md5sum > md5sum.txt
find . -type f -print0 | xargs -0 md5sum > md5sum.txt
</nowiki></pre>


    * . 现在可以来生成光盘镜像文件:  
*. 现在可以来生成光盘镜像文件:
 
<pre><nowiki>
sudo mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -o $IMAGE -R $BUILD/
sudo mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -o $IMAGE -R $BUILD/
 
</nowiki></pre>
    * ‘$IMAGE’表示您的光盘镜像文件.  
‘$IMAGE’表示您的光盘镜像文件.
 
*. 最后,可以用cdrecord或其它刻录工具来刻录您的CD了:
    * . 最后,可以用cdrecord或其它刻录工具来刻录您的CD了:  
<pre><nowiki>
 
sudo nice -18 cdrecord dev=ATA:1,1,0 speed=12 --blank=fast -v -gracetime=2 -tao $IMAGE
sudo nice -18 cdrecord dev=ATA:1,1,0 speed=12 --blank=fast -v -gracetime=2 -tao $IMAGE
 
</nowiki></pre>
that will burn the image on the second cd drive; if your cd-burner is the first or only cd-drive, change dev argument to ATA:1,0,0. I strongly recommend using rewritable media -- I've burned a LOT of coasters on this project.
that will burn the image on the second cd drive; if your cd-burner is the first or only cd-drive, change dev argument to ATA``:1,0,0. I '''strongly''' recommend using rewritable media -- I've burned a LOT of coasters on this project.


好了,搞定! 如果谁感兴趣,我写了一个小脚本(很简单)来自动完成这个步骤。我想我正好可以放在这儿
好了,搞定! 如果谁感兴趣,我写了一个小脚本(很简单)来自动完成这个步骤。我想我正好可以放在这儿


#!/bin/bash
<pre><nowiki>
# usage
# update-learningexchange.sh kubuntu|ubuntu|xubuntu


# a very primitive script with no structure of controls etc
# no default behaviour, etc etc
# all ofthis should be trivial to implement but my
# bash syntax sucks
# obvious thing to do would be to convert to python
# & add a simple gtk front end too
# but I'm rushed at the moment


# Notes;Bugs:
# REMEMBER: this absolutely will not work if you haven't built a new version of ubuntu-keyring
# package & included that in $STAGE/pool/extras/!  You do that thusly:
# apt-get source ubuntu-keyring
# cd ubuntu-keyring-version-info/keyring
# gpg --import < ubuntu-server-keyring.gpg
# gpg --output=ubuntu-server-keyring.gpg --export "ubuntu" "Your Name"
# dpkg-buildpackage -rfakeroot -m"My Name <[email protected]>"
# cp ../ubuntu-keyring*deb $BUILD/pool/extras/




# VARIABLES
# this script relies on the existence of several files and directories:


# Original = $ORIG: location of the "clean", unmodified CD .iso
# CD mount point = $MOUNT: mount point of clean CD
# Staging area = $STAGE: where you keep all your files
#  this area should include main dirs isolinux/, pool/, and dists/ at a minimum
#  as written the script assumes you have a directory pool/extras with your
#  extra debs, and that dists/breezy/extras/binary-i386/Release exists (copy it over
#  from dists/breezy/main/binary-i386, and replace "main" with "extras")
#  There is no doubt a better way to do this but it involves work...
# Building Area = $BUILD: location where your changes are merged into the "clean" directory \
#  structure.
# Image location = $IMAGE: name of the new .iso file you want to build
# apt.conf file = $APTCONF: location of the file used to feed instructions to apt-ftparchive


ORIG="/var/www/jigdo/$1-breezy-install-i386.iso"
ORIG="/var/www/jigdo/$1-breezy-install-i386.iso"
第306行: 第281行:




# sync with latest image
sudo umount $MOUNT
sudo umount $MOUNT
sudo mount $ORIG $MOUNT -o loop
sudo mount $ORIG $MOUNT -o loop
# sudo rsync -azvb --delete --exclude="language-pack*" --backup-dir=/yeowe/usr/cdbuilder/old/ $MOUNT $BUILD
sudo rsync -azvb --delete  $MOUNT $BUILD
sudo rsync -azvb --delete  $MOUNT $BUILD
# now get rid of the old ubuntu-keyring package
sudo rm -r $BUILD/pool/u/ubuntu-keyring/
sudo rm -r $BUILD/pool/u/ubuntu-keyring/
# note I've excluded a few files, shouldn't matter much for you I reckon
sudo rsync -avzb --exclude='*~' --exclude='INSTRUCTIONS.txt' --backup-dir=/yeowe/usr/cdbuilder/old/ --exclude='example-preseed.txt' $STAGE $BUILD
sudo rsync -avzb --exclude='*~' --exclude='INSTRUCTIONS.txt' --backup-dir=/yeowe/usr/cdbuilder/old/ --exclude='example-preseed.txt' $STAGE $BUILD


# generate Packages, Release, Release.gpg
# first thing to realize is, that we only need to generate the Packages files,
# the top-level Release file, and top-level Release.gpg. 
# everything else should be in your $STAGE file structure or usable unchanged
# in the original form


# remove Release file otherwise you'll have trouble writing to it. 
sudo rm $BUILD/dists/breezy/Release*
sudo rm $BUILD/dists/breezy/Release*
# ubuntu-keyring must be included in main/, so main NEEDS to be rebuilt!
for component in main extras; do
for component in main extras; do
    sudo apt-ftparchive packages "$BUILD/pool/$component/" > "$BUILD/dists/breezy/$component/binary-i386/Packages"
sudo apt-ftparchive packages "$BUILD/pool/$component/" > "$BUILD/dists/breezy/$component/binary-i386/Packages"
    gzip -c "$BUILD/dists/breezy/$component/binary-i386/Packages" | \
gzip -c "$BUILD/dists/breezy/$component/binary-i386/Packages" | \
        sudo tee "$BUILD/dists/breezy/$component/binary-i386/Packages.gz" > /dev/null
sudo tee "$BUILD/dists/breezy/$component/binary-i386/Packages.gz" > /dev/null
done
done
sudo apt-ftparchive -c $APTCONF release $BUILD/dists/breezy > $BUILD/dists/breezy/Release
sudo apt-ftparchive -c $APTCONF release $BUILD/dists/breezy > $BUILD/dists/breezy/Release
# gpg options: -ba = armored, detached-sig
sudo gpg --output $BUILD/dists/breezy/Release.gpg -ba $BUILD/dists/breezy/Release
sudo gpg --output $BUILD/dists/breezy/Release.gpg -ba $BUILD/dists/breezy/Release


# build the actual image.  Note the options to mkisofs, which make the image bootable
sudo chown -R root:root $BUILD/isolinux  $BUILD/preseed  
sudo chown -R root:root $BUILD/isolinux  $BUILD/preseed  
sudo mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -o $IMAGE -R $BUILD/
sudo mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -o $IMAGE -R $BUILD/


# burn the image to 2nd cd drive on most setups
sudo nice -18 cdrecord dev=ATA:1,1,0 speed=12 --blank=fast -v -gracetime=2 -tao $IMAGE
sudo nice -18 cdrecord dev=ATA:1,1,0 speed=12 --blank=fast -v -gracetime=2 -tao $IMAGE
</nowiki></pre>
[[category:CategoryDocumentation]] [[category:CategoryCleanup]]
[[category:UbuntuHelp]]

2007年5月22日 (二) 13:46的版本

定制Ubuntu安装CD


原文出处:https://wiki.ubuntu.com/InstallCDCustomizationHowTo

原文作者:未知

授权许可:创作共用协议

翻译人员:ctqucl

校对人员:无

适用版本:

文章状态:


定制Ubuntu CD的过程并不复杂,但是她有一些繁琐和过分的讲究。我对这过程的所知并不完美,因此,希望有人可以作适当修改。

安装CD有三个主要部分:

  • 启动引导器:(如ISOLINUX用于amd64/i386,yaboot用于powerpc)开机时内核映象的选择与配置;
  • Debian安装程序(d-i):其实就是一个特殊的微Ubuntu系统;
  • Debian软件库:放在"pool"和"dists"目录,它将占据光盘的大部分空间。

建立这个新的CD就包涵了这三部分的修改。

用"Presseed"文件修改安装行为

当CD启动时,Linux内核就被装载且开始安装任务。安装程序的行为可以用一个"preseed"文件来修改,这些文件给Debian安装程序(d-i)回答如何配置软件包或其它相关的问题。如果您仔细看你的安装CD,您会找到这些选项(例如server,expert,oem)都有对应的preseed文件。

所以,假设您想在一群的相同配置电脑上安装breezy,并且您已经知道安装时必问问题的答案(您所在的国家和时区,您你的键盘布局,您的网络设置,您需要如何分区等等)。您可以通过"preseed"在一简单的配置文件里回答这些问题.

改变isolinux.cfg确定您的preseed

首先,您必须告诉"d-i"找到您的preseed文件的正确位置。在标准的光盘上有个/preseed目录;您可以把您的这些文件放这里。您要修改启动引导器的配置文件/isolinux/isolinux.cfg中的相关内核参数,来告诉"d-i"找到这个文件。我的文件里有下列行:

DEFAULT /install/vmlinuz
APPEND   preseed/file=/cdrom/preseed/learnexchange.seed kbd-chooser/method=us debian-installer/locale=en_CA vga=normal initrd=/install/initrd.gz ramdisk_size=16384 root=/dev/rd/0 DEBCONF_PRIORITY=critical debconf/priority=critical rw --

"DEFAULT"是指我在boot提示符下直接按回车键装载的内核。APPEND 包涵了要传给内核的参数。preseed/file 是这儿最重要的参数;接着的那两个指出我的键盘布局用及本地为加拿大;DEBCONF_PRIORITY 用来确定我不想看到不必要的配置软件包提问。

根据你的情况小心修改这文件.

写preseed文件

这里有很多实例;看看这个在安装盘里的--server.seed:

d-i     base-installer/kernel/linux/extra-packages-2.6  string
d-i     archive-copier/desktop-task     string ubuntu-standard
d-i     archive-copier/ship-task        string
base-config     base-config/package-selection   string ~t^ubuntu-standard$
base-config     base-config/language-pack-patterns      string language-pack-$LL
base-config     base-config/install-language-support    boolean false

(Note that the version of this file on breezy CD images was buggy: it set base-config/package-selection to "~tubuntu-standard" rather than "~t^ubuntu-standard$". Use the new version in preference; the old one will break with Ubuntu 6.04.)

首先注意格式,有 4 个部分:

    • 取得变量的程序名称
    • 答案的变量名
    • 变量类型
    • 变量值

两个要注意的地方:现在,d-i 期望有精确的类型和值;在breezy这个版本不支持用 \ 来处理多行(新的版本支持)。

我建议您从一些现有的 preseed 来修改--这儿有一个可以用的 点击。 如果您没能在这儿找到,那就试着执行这些命令:

debconf-get-selections --installer > somefile.txt
debconf-get-selections >> somefile.txt

这会输出一个您在安装时候作出的选择的列表;这文件相当地长,并且实际上不那么适合用在安装盘里。特别是,NOTE: debconf-get-selections 会在类型和只之间放 2 个空格。您得在把她放在安装盘上以前修改他们。

如果您想让 d-i 安装额外的软件包,或者一个最小的系统,您需要在preseed里修改 "base-config base-config/package-selection"。This should be set to an aptitude pattern; see the aptitude documentation for more information on these. 例如,标准安装一个SSH服务,用这一行:

base-config base-config/package-selection string ~t<sup>ubuntu-standard$|~t^ubuntu-desktop$|~n</sup>openssh-server$

To install support for additional languages, a different mechanism is available, namely to preseed the detailed locale question asked by the installer in expert mode. See the first column of `/usr/share/i18n/SUPPORTED` for the locale names you can use here. 例如, 增加孟加拉语和泰米尔语的支持,用这一行:

d-i localechooser/supported-locales multiselect ba_IN, ta_IN

修改pool目录,增加或删除软件包

也许制定您自己的安装CD的主要原因是想改变所安装软件包;特别是您想增加一些包到CD里。这有好几个方法来做到,不需要完全地理解。最容易的事情是建立一个最小的仓库放您想要增加的包,再在制作光盘镜像文件之前合并到光盘文件体系里。这儿棘手的地方是:制作让Debian软件包管理系统知道这个仓库的相关文件;写一个更高版本的Release文件;并签上 GPG 。下面是我所做的。


  • . 选定一个文件目录作为您的工作空间;在这个目录里,
mkdir -p dists/breezy/extras/binary-i386 pool/extras/ isolinux preseed

把您修改过的isolinux.cfg放在目录isolinux/,把您的preseed文件放在目录preseed里。 Put your modified isolinux.cfg in isolinux/, and your preseed file in preseed/.

  • . 把您需要的所有额外的包放在目录 pool/extras/ 里。您还需要包括一个新版本的 ubuntu-keyring 包,我将马上解释一下
  • . 创建并编辑文件dists/breezy/extras/binary-i386/Release,写入下面的内容:
Archive: breezy
Version: 5.10
Component: extras
Origin: Ubuntu
Label: Ubuntu
Architecture: i386
  • . 把您做的修改这样合并到CD里:

a. 挂载您下载的官方ISO文件:mount /path/to/iso /some/mountpoint/ -o loop

b. 把光盘里的全部文件拷贝到某个目录(您会需要1到2G的空间);我用rsync:sudo rsync -azvb --delete --backup-dir=/yeowe/usr/cdbuilder/old/ $MOUNT $BUILD ( 这儿的 $MOUNT 是挂载点,$BUILD 是额外的包的目录)

c. 最重要的地方. 我们将用apt-ftparchive工具来产生软件包相关和更高版本的Release文件。我们还要用GPG来签这个Release文件。安装程序会用包ubuntu-keyring 的公匙来检测签名。但是您的签名不一样。所以您得建立一个新版本的 ubuntu-keyring 包。这做起来很容易,但是要确保正确无误。下面是执行的命令:

apt-get source ubuntu-keyring
cd ubuntu-keyring--2005.01.11/keyring
gpg --import < ubuntu-archive-keyring.gpg
gpg --list-keys "Your Name"
gpg --export  FBB75451 437D05B5 YOURKEYID > ubuntu-archive-keyring.gpg
cd ..
dpkg-buildpackage -rfakeroot -m"Your Name <[email protected]> -k"Your Name <[email protected]>"
cp ubuntu-keyring*deb $BUILD/pool/extras/

OK -- what we've done here is import the 2 Ubuntu keys into your main keyring, then exported them along with your own key into a replacement keyring. "YOURKEYID" should be replaced with the 8-digit hexadecimal code that gpg tells you when you do the --list-keys command above. And really, the best policy would be to do all that first, and copy a version into your $STAGE file structure so that you have it permanently available.

Note: If you do not have an existing gpg signing key, use the following code:

 gpg --gen-key

Accept all defaults, select "No expiry", and enter an appropriate passphrase.

In order to use apt-ftparchive, we will need to provide it with some defaults. Create the files "apt-ftparchive-deb.conf, "apt-ftparchive-udeb.conf", and "apt-ftparchive-extras.conf" as follows (substitude $BUILD for the absolute path to your BUILD directory, and /path/to/indices to the location of the indices files, which you can download from http://archive.ubuntu.com/ubuntu/indices/ ):

apt-ftparchive-deb.conf:
Dir {
ArchiveDir "$BUILD";
};

TreeDefault {
Directory "pool/";
};

BinDirectory "pool/main" {
Packages "dists/breezy/main/binary-i386/Packages";
BinOverride "/path/to/indices/override.breezy.main";
ExtraOverride "path/to/indices/override.breezy.extra.main";
};

Default {
Packages {
Extensions ".deb";
Compress ". gzip";
};
};

Contents {
Compress "gzip";
};

apt-ftparchive-udeb.conf:
Dir {
ArchiveDir "$BUILD";
};

TreeDefault {
Directory "pool/";
};

BinDirectory "pool/main" {
Packages "dists/breezy/main/debian-installer/binary-i386/Packages";
BinOverride "/path/to/indices/override.breezy.main.debian-installer";
};

Default {
Packages {
Extensions ".udeb";
Compress ". gzip";
};
};

Contents {
Compress "gzip";
};
apt-ftparchive-extras.conf:
Dir {
ArchiveDir "$BUILD";
};

TreeDefault {
Directory "pool/";
};

BinDirectory "pool/extras" {
Packages "dists/breezy/extras/binary-i386/Packages";
};

Default {
Packages {
Extensions ".deb";
Compress ". gzip";
};
};

Contents {
Compress "gzip";
};


  • . 现在就用apt-ftparchive来创建Packages和Release文件:
cd $BUILD
sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-deb.conf
sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-udeb.conf
sudo apt-ftparchive -c $APTCONF generate /path/to/apt-ftparchive-extras.conf

$APTCONF is a file somewhere that looks about like this:

APT::FTPArchive::Release::Origin "Ubuntu";
APT::FTPArchive::Release::Label "Ubuntu";
APT::FTPArchive::Release::Suite "breezy";
APT::FTPArchive::Release::Version "5.10";
APT::FTPArchive::Release::Codename "breezy";
APT::FTPArchive::Release::Architectures "i386";
APT::FTPArchive::Release::Components "main restricted extras";
APT::FTPArchive::Release::Description "Ubuntu Breezy";

a. 给Release文件签gpg:

sudo gpg --default-key "MY GPG KEY ID" --output $BUILD/dists/breezy/Release.gpg -ba $BUILD/dists/breezy/Release
  • . Regenerate the md5 checksums:

cd $BUILD find . -type f -print0 | xargs -0 md5sum > md5sum.txt

  • . 现在可以来生成光盘镜像文件:
sudo mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -o $IMAGE -R $BUILD/

‘$IMAGE’表示您的光盘镜像文件.

  • . 最后,可以用cdrecord或其它刻录工具来刻录您的CD了:
sudo nice -18 cdrecord dev=ATA:1,1,0 speed=12 --blank=fast -v -gracetime=2 -tao $IMAGE

that will burn the image on the second cd drive; if your cd-burner is the first or only cd-drive, change dev argument to ATA``:1,0,0. I strongly recommend using rewritable media -- I've burned a LOT of coasters on this project.

好了,搞定! 如果谁感兴趣,我写了一个小脚本(很简单)来自动完成这个步骤。我想我正好可以放在这儿







ORIG="/var/www/jigdo/$1-breezy-install-i386.iso"
STAGE="/home/matt/LearningExchangeCD/$1/"
MOUNT=/mnt/iso/
BUILD="/yeowe/usr/cdbuilder/$1"
IMAGE="/yeowe/usr/cdbuilder/$1-learningexchange.iso"
APTCONF=/home/matt/LearningExchangeCD/apt.conf 


sudo umount $MOUNT
sudo mount $ORIG $MOUNT -o loop
sudo rsync -azvb --delete  $MOUNT $BUILD
sudo rm -r $BUILD/pool/u/ubuntu-keyring/
sudo rsync -avzb --exclude='*~' --exclude='INSTRUCTIONS.txt' --backup-dir=/yeowe/usr/cdbuilder/old/ --exclude='example-preseed.txt' $STAGE $BUILD


sudo rm $BUILD/dists/breezy/Release*
for component in main extras; do
sudo apt-ftparchive packages "$BUILD/pool/$component/" > "$BUILD/dists/breezy/$component/binary-i386/Packages"
gzip -c "$BUILD/dists/breezy/$component/binary-i386/Packages" | \
sudo tee "$BUILD/dists/breezy/$component/binary-i386/Packages.gz" > /dev/null
done
sudo apt-ftparchive -c $APTCONF release $BUILD/dists/breezy > $BUILD/dists/breezy/Release
sudo gpg --output $BUILD/dists/breezy/Release.gpg -ba $BUILD/dists/breezy/Release

sudo chown -R root:root $BUILD/isolinux  $BUILD/preseed 
sudo mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-moved -o $IMAGE -R $BUILD/

sudo nice -18 cdrecord dev=ATA:1,1,0 speed=12 --blank=fast -v -gracetime=2 -tao $IMAGE