Difference between revisions of "Customizing Ubuntu Desktop CD"

From Gramps
Jump to: navigation, search
(Linux Genealogy CD)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Developers/General]]
+
#REDIRECT [[Linux Genealogy CD]]
 
 
This page describes how to customize the Ubuntu Dekstop CD. This is typically done to showcase certain packages that don't come with the default Ubuntu CD. This information is based on Ubuntu 8.04 and may or may not be applicable to future releases.
 
 
 
==Brief overview of the process==
 
An extremely general picture is: unpack stuff from CD, add our packages, pack it all back. Now a little more detail on each part.
 
* The whole filesystem of the Ubuntu that will run in the Live session is packed into a single file on the CD. This file is <code>/casper/filesystem.squashfs</code> and one needs the <code>squashfs</code> kernel module to work with such filesystems.
 
* One needs to prepare packages (.deb files) that are to be added to the system. These packages may have dependencies that also need to be downloaded beforehand.
 
* The final CD image may turn up to be more than 700MB after we add our stuff. So some sacrificing of other useless contents might be needed after we add our packages.
 
* There are tricks to pack everything back. They all will be explained below in their respective order.
 
 
 
==Unpacking==
 
This part is by far the easiest. Once you have downloaded the original iso file with the Ubuntu desktop CD, mount it: <pre>mount ubuntu-8.04-desktop-i386.iso mnt -o loop</pre> assuming that you have an empty directory <code>mnt</code> and the iso file in your working directory. Then copy everything into another directory using <code>rsync</code>: <pre>rsync --exclude=/casper/filesystem.squashfs -a mnt/ iso</pre> This will create the directory called <code>iso</code> with the contents of the CD, '''except''' for the largest file <code>/casper/filesystem.squashfs</code> that holds the whole target filesystem.
 
 
 
Next we unpack the target filesystem from that huge file. First we will mount it using another empty directory <code> mnt_sq</code>: <pre>mount mnt/casper/filesystem.squashfs mnt_sq -o loop -t squashfs</pre> And then we <code>rsync</code> from it to a new directory: <pre>rsync -a mnt_sq/ squash</pre> This should create the directory <code>squash</code> with the contents of the target filesystem. Now that we are done with the mounted images, we may unmount them: <pre>umount mnt_sq
 
umount mnt</pre> At this point you should have the directory <code>iso</code> with all the contents on the CD needed for booting the Ubuntu system, and the directory <code>squash</code> with the system itself.
 
 
 
==Adding our contents==
 
===Adding packages===
 
For the sake of simplicity, let's assume that you have collected all the packages you want to add in a separate directory <code>new/debs</code> relative to your working directory. That is, there's <code>new</code> dir with the subdir <code>debs</code> where all the deb packages are collected. Let's copy all these packages onto the target filesystem (any place will do for now, but I chose <code>/root</code>): <pre>cp new/debs/* squash/root/</pre> Then we will prepare <code>chroot</code> environment like so: <pre>mount -t proc proc squash/proc
 
mount -t sysfs sysfs squash/sys</pre> and then we will "change root" (<code>chroot</code>) to that target filesystem and install packages. <pre>chroot squash dpkg -i /root/gramps_3.0.1-1_all.deb</pre> Changing root means we will see '''only''' the target filesystem as if we were truly running it it and it were our root filesystem. So the above command changes root to <code>squash</code> and then runs <code>dpkg -i /root/gramps_3.0.1-1_all.deb</code> command to install GRAMPS. You will need to repeat that line for every package you want to install. After you are done, remove the debs from the <code>/root</code> of the target: <pre>rm squash/root/*.deb</pre>
 
 
 
===Other customizations===
 
If you'd like to modify the desktop look, set up custom launchers for the user and the like, you would need to copy all this stuff into <code>/etc/skel</code> of the target. This is because no user accounts exist yet, and there is no way to modify the home directories. But the <code>/etc/skel</code> gets copied into the home directory of every new user when it gets created. So copying into <code>/etc/skel</code> will do the trick: <pre>for fl in `ls -A new/home`; do
 
    cp -R new/home/$fl squash/etc/skel
 
done</pre> The thing is, some of that contents may be files and some are directories like <code>.gramps</code> which will need to copy recursively.
 
 
 
Similarly, you can copy anything you need onto the target system: geneweb databaes, custom welcome pages, movies, scripts, etc.
 
 
 
==Packing it all back==
 
===Removing extra contents===
 
We most likely will need to remove something, or our final CD image will not fit onto the CD blank. Your mileage may vary, depending on what customization you have done. I keep the commands removing stuff in a script, then I execute it: <pre>cp new/scripts/purge squash/root/
 
chroot squash /root/purge
 
rm squash/root/purge<pre> But you may just as well do <code>rm squash/blah/blah</code>. I also remove lots of stuff from <code>/var</code> and <code>/tmp</code>: <pre>rm squash/var/log/dpkg.log
 
rm squash/var/log/scrollkeeper.log
 
rm squash/var/cache/debconf/templates.dat-old
 
rm -rf squash/tmp/*</pre>
 
 
 
===Preparing to close===
 
We need to regenerate the manifest for the squash filesystem: <pre>chroot squash dpkg-query -W --showformat='${Package} ${Version}\n' \
 
    > iso/casper/filesystem.manifest</pre>
 
 
 
If we want our added stuff to be able to make it to the installation (not just the Live session), we need to add our packages to the <code>filesystem.manifest-desktop</code> file. The trick is, that file already has some contents, so we should add ours and then sort the whole list. Assume our packages are all listed in <code>new/debs/list.txt</code> file: <pre>cat iso/casper/filesystem.manifest-desktop new/debs/list.txt | sort > junk
 
mv junk iso/casper/filesystem.manifest-desktop</pre>
 
 
 
Finally, close the chroot so it is again nothing more than the directory full of contents: <pre>umount squash/sys squash/proc</pre>
 
 
 
===Close===
 
First, we need to pack all that stuff back into the single file, that will later on end up on our CD. This will take a while: <pre>mksquashfs squash iso/casper/filesystem.squashfs</pre>
 
 
 
Then we need to generate md5 sums for every file on the CD so that the disk can be checked for damages. Note that we want to skip the md5 file itself, our temporary file, and the stuff in isolinux which gets recreated at the burning stage: <pre>cd iso
 
find . -type f -print0  | xargs -0 md5sum > junk.txt
 
cat junk.txt | grep -v md5 | grep -v junk | grep -v isolinux > md5sum.txt
 
rm junk.txt
 
cd ..</pre>
 
 
 
Now we are ready to create the CD image: <pre>mkisofs -r -V "Linux Genealogy CD 4.0" \
 
    -cache-inodes -quiet \
 
    -J -l -b isolinux/isolinux.bin \
 
    -c isolinux/boot.cat -no-emul-boot \
 
    -boot-load-size 4 -boot-info-table \
 
    -o lgenealogy4.0-dekstop.iso iso</pre>
 
 
 
Finally, we may want to create an md5 file for the whole CD image. That way it will be easy to check wether the iso was downloaded completely or not: <pre>md5sum lgenealogy4.0-dekstop.iso > lgenealogy4.0-dekstop.iso.md5sum</pre> That's it, folks!
 

Latest revision as of 02:55, 8 October 2011

Redirect to: