Skip to content

Instantly share code, notes, and snippets.

@wildintellect
Created May 1, 2012 23:31
Show Gist options
  • Save wildintellect/2572358 to your computer and use it in GitHub Desktop.
Save wildintellect/2572358 to your computer and use it in GitHub Desktop.
OSGeo Live chroot build
#LiveCD on the commandline
#https://help.ubuntu.com/community/LiveCDCustomization
DIR=`dirname ${0}`
VERSION=`cat "$DIR"/../VERSION.txt`
PACKAGE_NAME="osgeo-live"
ISO_NAME="${PACKAGE_NAME}-${VERSION}"
sudo apt-get install squashfs-tools genisoimage
#TODO add wget to grab a fresh image, optional
#Stuff to be done the 1st time, should already be in place for additional builds
mkdir ~/livecdtmp
cd ~/livecdtmp
#mv ubuntu-9.04-desktop-i386.iso ~/livecdtmp
wget http://mirror.anl.gov/pub/ubuntu-iso/CDs-Xubuntu/10.04/release/xubuntu-10.04-desktop-i386.iso
#mv xubuntu-10.04-desktop-i386.iso ~/livecdtmps
mkdir mnt
#Start with a fresh copy
sudo mount -o loop xubuntu-10.04-desktop-i386.iso mnt
mkdir extract-cd
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
sudo unsquashfs mnt/casper/filesystem.squashfs
#Does the above need to be done every time or can it be done once, and then just make a fresh copy of the chroot for each builds
sudo mv squashfs-root edit
sudo cp /etc/resolv.conf edit/etc/
sudo cp /etc/hosts edit/etc/
sudo mount --bind /dev/ edit/dev
sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
export HOME=/roots
export LC_ALL=C
dbus-uuidgen > /var/lib/dbus/machines-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
#Execute the build
./main.sh ...
#After the build
#Check for users above 999
awk -F: '$3 > 999' /etc/passwd
#Cleanup
apt-get clean
rm -rf /tmp/* ~/.bash_history
rm /etc/hosts
rm /etc/resolv.conf
rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
umount /proc || umount -lf /proc
umount /sys
umount /dev/pts
exit
sudo umount edit/dev
#remaster the dvd
chmod +w extract-cd/casper/filesystem.manifest
sudo chroot livealpha dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest
sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/casper/d' extract-cd/casper/filesystem.manifest-desktop
sudo rm extract-cd/casper/filesystem.squashfs
sudo mksquashfs livealpha extract-cd/casper/filesystem.squashfs
#Update the filesystem.size file, which is needed by the installer:
# TODO: get it to run as sudo no sudo su
printf $(sudo du -sx --block-size=1 livealpha | cut -f1) > extract-cd/casper/filesystem.size
#Set an image name in extract-cd/README.diskdefines
#KVM VNC doesn't pass ctrl, can't use vim or nano
#Can probably use sed magic
sudo nano extract-cd/README.diskdefines
#Remove old md5sum.txt and calculate new md5 sums
cd extract-cd
sudo rm md5sum.txt
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt
#Create the ISO image
sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../osgeo-live-${version}-mini.iso .
----
#Actual example
sudo mv squashfs-root live4.5alpha1
sudo cp /etc/resolv.conf live4.5alpha1/etc/
clear
sudo cp /etc/hosts live4.5alpha1/etc/
sudo mount --bind /dev/ live4.5alpha1/dev
sudo chroot live4.5alpha1/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment