Wednesday, December 20, 2006

HowToCreateYourOwnGNULinuxDistribution

As part of creating gNewSense, we created our Builder which allows for the creation of a new GNU/Linux distribution based on Ubuntu Dapper. From a simple config file you can choose the name of your distribution, release, tagline and what packages you'd like to be installed/removed by default. Graphics will be automatically generated. These scripts are obviously biased towards producing gNewSense, but should provide a good base to work off.

You'll need at least 35GB of free disk space, and preferably a very fast internet connection (you'll be pulling 27GB of data). You'll also need about 28GB of space on your mirror (which can be the same system). If you're smart with hardlinks you should be able to avoid some of the duplication. This should be run on a Ubuntu Dapper system without any updates (security or otherwise). Source repositories will need to be enabled. It is possible to downgrade to this state - see Removing Updated Pacakges.

If you have any queries, please drop into our IRC channel. This is still very much beta software, I haven't done a rebuild from scratch in a long time and the code has changed a good bit since.

Step 1: GPG key

More recent verions of apt require GPG signed release files in a repository to ensure the integrity of the distribution, so our first step is to create a GPG key.

 gpg --gen-key

will let you do this. Make sure the key has a blank password. Take a note of the fingerprint of the key as you'll need it later for the config file.

Finally, you'll need to add the public key to root's keyring.

Step 2: Packages

You'll need a number of packages for the Builder to run properly.

 apt-get install reprepro imagemagick debmirror build-essential apache2 subversion cdebootstrap 
apt-get install squashfs-tools netpbm syslinux bittornado
apt-get build-dep linux-image-$(uname -r) ubiquity update-manager ubuntu-artwork base-files ubuntu-meta
apt-get build-dep launchpad-integration grub system-tools-backends example-content gnome-panel
apt-get build-dep gnome-app-install
svn co http://svn.gnewsense.svnhopper.net/gnewsense/builder/trunk builder
sudo ./fixup-kernel-wedge

There's undoubtably packages missing from this, please let me know.

Step 3: Debmirror (optional)

To avoid having to redownload files, I suggest creating a mirror of Ubuntu main and universe. This will take an additional 27GB.

 debmirror --nocleanup --verbose --progress --method=http --host=ie.archive.ubuntu.com --arch=i386 \
--source --dist=dapper,dapper-security,dapper-updates,dapper-backports --section=main,main/debian-installer,universe --ignore-release-gpg \
--root=ubuntu /the/target/directory

You'll also need to setup apache so you can get to the mirror via HTTP over localhost. This step is optional, but it is strongly reccommended to have a local Ubuntu mirror (for some value of local).

Step 4: Configuration

cd into the builder directory you created earlier and open the config file in a text editor. The settings you need to worry about are MIRROR, RELEASE, DISTRONAME, DOMAIN, BASEDIR, and REPOAPT.

MIRROR is either the mirror you setup in step 3, or an Ubuntu mirror. It should contain the security packages. MIRRORDIST is the distribution in the mirror, usually 'dapper'.

DISTRONAME is what you want to call your distribution, similaraly RELEASE is the name of your release. Your release should be all lowercase as it will appear in paths. LOGOLETTER is the letter that will be your logo, while TAGLINE is used in the bootsplash and login screnn. SIGNINGKEY is your GPG fingerprint from step 1, it should not contain any spaces.

DOMAIN is used to create the default sources.list when installing. We assume an Ubuntu-like setup where you have archive.DOMAIN and security.DOMAIN and subdomains for all the country codes.

BASEDIR is the directory under which the repository, livecd and temporary files will be put. REPOAPT is where the build scripts will pull packages from, so you should setup apache to serve the REPODST directory ($BASEDIR/(lowercase distribution name)).

META_*_{ADD,REMOVE} control what packages you'd like added and removed from the ubuntu-meta package when your meta packages are being created.

*_VERSION are the numbers appended to created packages versions. You will need to increment these every time you rebuild a package. You will probably want to set these all to 1 when starting.

RSYNC_DEST is where the generated repo and livecds should be rsynced to by a push-repo or push-cd.

Step 5: Generate the repository

 ./gen-repo && ./do-update

This will take a while. The repository will possibly be in an inconsistant state while this is running, which is why you only push your changes to a mirror in Step 7. Every time there's new versions upstream (e.g. security updates) re-run do-update (and debmirror if needed).

Step 6: Generate the LiveCD

 sudo ./gen-livecd

The created image will be placed in $LIVECDDIR/$DISTRONAME_L-livecd-$LIVECD_VERSION.iso

 ./gen-cdsource
./stage-cd

Will prepare a source tarball and push the iso to $REPODST/cdimage

Step 7: Push your repository to a mirror and publicise

You can now publish your repository (the dists and pool) directories as well as your LiveCD to your mirror and publicise your new distribution to the world.

 ./push-repo
./push-cd

No comments:

Post a Comment