mirror of
https://git.launchpad.net/livecd-rootfs
synced 2025-06-09 09:02:11 +00:00
add support for kubuntu livecds
This commit is contained in:
parent
8b12cea1a7
commit
8e6007b171
242
livecd.sh
242
livecd.sh
@ -1,8 +1,8 @@
|
|||||||
#!/bin/sh -eu
|
#!/bin/bash -eu
|
||||||
|
|
||||||
#################################################################
|
######################################################################
|
||||||
#### (c) Copyright 2004 Canonical Ltd. All rights reserved. ####
|
#### (c) Copyright 2004,2005 Canonical Ltd. All rights reserved. ####
|
||||||
#################################################################
|
######################################################################
|
||||||
|
|
||||||
# Depends: debootstrap, rsync, cloop-utils, python
|
# Depends: debootstrap, rsync, cloop-utils, python
|
||||||
|
|
||||||
@ -30,80 +30,105 @@ case $(hostname --fqdn) in
|
|||||||
*) MIRROR=http://archive.ubuntu.com/ubuntu;;
|
*) MIRROR=http://archive.ubuntu.com/ubuntu;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# How much space do we leave on the filesystem for the user?
|
while getopts :m: name; do case $name in
|
||||||
USZ="400*1024" # 400MB for the user
|
m) MIRROR="$OPTARG";;
|
||||||
# And how many inodes? Default currently gives them > 100000
|
\?) echo bad usage >&2; exit 2;;
|
||||||
UINUM="" # blank (default), or number of inodes desired.
|
\:) echo missing argument >&2; exit 2;;
|
||||||
STE=hoary
|
esac; done;
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
ROOT=$(pwd)/chroot-livecd/ # trailing / is CRITICAL
|
(( $# == 0 )) && set -- ubuntu || true
|
||||||
IMG=livecd.fsimg
|
[ "X$1" = "Xall" ] && set -- ubuntu kubuntu || true
|
||||||
MOUNTS="${ROOT}dev/pts ${ROOT}dev/shm ${ROOT}.dev ${ROOT}dev ${ROOT}proc"
|
|
||||||
DEV=""
|
|
||||||
|
|
||||||
rm -rf ${ROOT}
|
for arg in "$@"; do case "$arg" in
|
||||||
|
ubuntu|kubuntu) ;;
|
||||||
|
*) echo bad name >&2; exit 2;;
|
||||||
|
esac; done
|
||||||
|
|
||||||
mkdir -p ${ROOT}var/cache/debconf
|
for FS in "$@"; do
|
||||||
cat << @@EOF > ${ROOT}var/cache/debconf/config.dat
|
# How much space do we leave on the filesystem for the user?
|
||||||
Name: debconf/frontend
|
USZ="400*1024" # 400MB for the user
|
||||||
Template: debconf/frontend
|
# And how many inodes? Default currently gives them > 100000
|
||||||
Value: Noninteractive
|
UINUM="" # blank (default), or number of inodes desired.
|
||||||
Owners: debconf
|
STE=hoary
|
||||||
Flags: seen
|
|
||||||
@@EOF
|
|
||||||
|
|
||||||
# need to defer udev until the apt-get, since debootstrap doesn't believe
|
ROOT=$(pwd)/chroot-livecd/ # trailing / is CRITICAL
|
||||||
# in diversions
|
IMG=livecd.fsimg
|
||||||
debootstrap --exclude=udev,ubuntu-base $STE $ROOT $MIRROR
|
MOUNTS="${ROOT}dev/pts ${ROOT}dev/shm ${ROOT}.dev ${ROOT}dev ${ROOT}proc"
|
||||||
|
DEV=""
|
||||||
|
|
||||||
# Just make a few things go away, which lets us skip a few other things.
|
rm -rf ${ROOT}
|
||||||
# sadly, udev's postinst does some actual work, so we can't just make it
|
|
||||||
# go away completely.
|
mkdir -p ${ROOT}var/cache/debconf
|
||||||
DIVERTS="usr/sbin/mkinitrd usr/sbin/invoke-rc.d sbin/udevd"
|
cat << @@EOF > ${ROOT}var/cache/debconf/config.dat
|
||||||
for file in $DIVERTS; do
|
Name: debconf/frontend
|
||||||
|
Template: debconf/frontend
|
||||||
|
Value: Noninteractive
|
||||||
|
Owners: debconf
|
||||||
|
Flags: seen
|
||||||
|
@@EOF
|
||||||
|
|
||||||
|
case "$FS" in
|
||||||
|
ubuntu)
|
||||||
|
LIST="ubuntu-base ubuntu-desktop ubuntu-live"
|
||||||
|
;;
|
||||||
|
kubuntu)
|
||||||
|
LIST="ubuntu-base kubuntu-desktop ubuntu-live"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
LIST="$LIST xresprobe laptop-detect"
|
||||||
|
|
||||||
|
# need to defer udev until the apt-get, since debootstrap doesn't believe
|
||||||
|
# in diversions
|
||||||
|
debootstrap --exclude=udev,ubuntu-base $STE $ROOT $MIRROR
|
||||||
|
|
||||||
|
# Just make a few things go away, which lets us skip a few other things.
|
||||||
|
# sadly, udev's postinst does some actual work, so we can't just make it
|
||||||
|
# go away completely.
|
||||||
|
DIVERTS="usr/sbin/mkinitrd usr/sbin/invoke-rc.d sbin/udevd"
|
||||||
|
for file in $DIVERTS; do
|
||||||
mkdir -p ${ROOT}${file%/*}
|
mkdir -p ${ROOT}${file%/*}
|
||||||
sudo chroot $ROOT dpkg-divert --add --local --divert /${file}.livecd --rename /${file}
|
sudo chroot $ROOT dpkg-divert --add --local --divert /${file}.livecd --rename /${file}
|
||||||
cp /bin/true ${ROOT}$file
|
cp /bin/true ${ROOT}$file
|
||||||
done
|
done
|
||||||
|
|
||||||
# /bin/true won't cut it for mkinitrd, need to have -o support.
|
# /bin/true won't cut it for mkinitrd, need to have -o support.
|
||||||
cat << @@EOF > ${ROOT}/usr/sbin/mkinitrd
|
cat << @@EOF > ${ROOT}/usr/sbin/mkinitrd
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import sys
|
import sys
|
||||||
for i in range(len(sys.argv)):
|
for i in range(len(sys.argv)):
|
||||||
if sys.argv[i]=='-o':
|
if sys.argv[i]=='-o':
|
||||||
open(sys.argv[i+1],"w")
|
open(sys.argv[i+1],"w")
|
||||||
@@EOF
|
@@EOF
|
||||||
chmod 755 ${ROOT}usr/sbin/mkinitrd
|
chmod 755 ${ROOT}usr/sbin/mkinitrd
|
||||||
|
|
||||||
trap "cleanup" 0 1 2 3 15
|
trap "cleanup" 0 1 2 3 15
|
||||||
|
|
||||||
# Make a good /etc/kernel-img.conf for the kernel packages
|
# Make a good /etc/kernel-img.conf for the kernel packages
|
||||||
cat << @@EOF >> ${ROOT}etc/kernel-img.conf
|
cat << @@EOF >> ${ROOT}etc/kernel-img.conf
|
||||||
do_symlinks = yes
|
do_symlinks = yes
|
||||||
relative_links = yes
|
relative_links = yes
|
||||||
do_bootloader = no
|
do_bootloader = no
|
||||||
do_bootfloppy = no
|
do_bootfloppy = no
|
||||||
do_initrd = yes
|
do_initrd = yes
|
||||||
link_in_boot = no
|
link_in_boot = no
|
||||||
@@EOF
|
@@EOF
|
||||||
|
|
||||||
cat << @@EOF > ${ROOT}etc/locale.gen
|
cat << @@EOF > ${ROOT}etc/locale.gen
|
||||||
en_US.UTF-8 UTF-8
|
en_US.UTF-8 UTF-8
|
||||||
en_GB.UTF-8 UTF-8
|
en_GB.UTF-8 UTF-8
|
||||||
en_ZA.UTF-8 UTF-8
|
en_ZA.UTF-8 UTF-8
|
||||||
@@EOF
|
@@EOF
|
||||||
|
|
||||||
mkdir -p ${ROOT}proc
|
mkdir -p ${ROOT}proc
|
||||||
mount -tproc none ${ROOT}proc
|
mount -tproc none ${ROOT}proc
|
||||||
|
|
||||||
# In addition to the ones we got from apt, trust whatever the local system
|
# In addition to the ones we got from apt, trust whatever the local system
|
||||||
# believes in, but put things back afterwards.
|
# believes in, but put things back afterwards.
|
||||||
cp ${ROOT}etc/apt/trusted.gpg ${ROOT}etc/apt/trusted.gpg.$$
|
cp ${ROOT}etc/apt/trusted.gpg ${ROOT}etc/apt/trusted.gpg.$$
|
||||||
cat /etc/apt/trusted.gpg >> ${ROOT}etc/apt/trusted.gpg
|
cat /etc/apt/trusted.gpg >> ${ROOT}etc/apt/trusted.gpg
|
||||||
|
|
||||||
LIST="ubuntu-base ubuntu-desktop ubuntu-live xresprobe laptop-detect"
|
case $(dpkg --print-architecture) in
|
||||||
case $(dpkg --print-architecture) in
|
|
||||||
amd64) LIST="$LIST linux-amd64-generic";;
|
amd64) LIST="$LIST linux-amd64-generic";;
|
||||||
i386) LIST="$LIST linux-386";;
|
i386) LIST="$LIST linux-386";;
|
||||||
ia64) LIST="$LIST linux-itanium-smp linux-mckinley-smp";;
|
ia64) LIST="$LIST linux-itanium-smp linux-mckinley-smp";;
|
||||||
@ -113,64 +138,65 @@ case $(dpkg --print-architecture) in
|
|||||||
hppa) LIST="$LIST linux-hppa32-smp linux-hppa64-smp";;
|
hppa) LIST="$LIST linux-hppa32-smp linux-hppa64-smp";;
|
||||||
sparc*) LIST="$LIST linux-sparc64";;
|
sparc*) LIST="$LIST linux-sparc64";;
|
||||||
*) echo "Unknown architecture: no kernel."; exit 1;;
|
*) echo "Unknown architecture: no kernel."; exit 1;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Create a good sources.list, and finish the install
|
# Create a good sources.list, and finish the install
|
||||||
echo deb $MIRROR $STE main restricted > ${ROOT}etc/apt/sources.list
|
echo deb $MIRROR $STE main restricted > ${ROOT}etc/apt/sources.list
|
||||||
chroot $ROOT apt-get update
|
chroot $ROOT apt-get update
|
||||||
chroot $ROOT apt-get -y install $LIST </dev/null
|
chroot $ROOT apt-get -y install $LIST </dev/null
|
||||||
chroot $ROOT /etc/cron.daily/slocate
|
chroot $ROOT /etc/cron.daily/slocate
|
||||||
chroot $ROOT /etc/cron.daily/man-db
|
chroot $ROOT /etc/cron.daily/man-db
|
||||||
chroot $ROOT /usr/sbin/locale-gen
|
chroot $ROOT /usr/sbin/locale-gen
|
||||||
|
|
||||||
# remove our diversions
|
# remove our diversions
|
||||||
for file in $DIVERTS; do
|
for file in $DIVERTS; do
|
||||||
ls -ld ${ROOT}${file} ${ROOT}${file}.livecd || true
|
ls -ld ${ROOT}${file} ${ROOT}${file}.livecd || true
|
||||||
rm -f ${ROOT}${file}
|
rm -f ${ROOT}${file}
|
||||||
chroot $ROOT dpkg-divert --remove --rename /${file}
|
chroot $ROOT dpkg-divert --remove --rename /${file}
|
||||||
done
|
done
|
||||||
|
|
||||||
# And make this look more pristene
|
# And make this look more pristene
|
||||||
cleanup
|
cleanup
|
||||||
cat << @@EOF > ${ROOT}etc/apt/sources.list
|
cat << @@EOF > ${ROOT}etc/apt/sources.list
|
||||||
deb http://archive.ubuntu.com/ubuntu $STE main restricted
|
deb http://archive.ubuntu.com/ubuntu $STE main restricted
|
||||||
deb-src http://archive.ubuntu.com/ubuntu $STE main restricted
|
deb-src http://archive.ubuntu.com/ubuntu $STE main restricted
|
||||||
|
|
||||||
## Uncomment the following two lines to add software from the 'universe'
|
## Uncomment the following two lines to add software from the 'universe'
|
||||||
## repository.
|
## repository.
|
||||||
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
|
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
|
||||||
## team, and may not be under a free licence. Please satisfy yourself as to
|
## team, and may not be under a free licence. Please satisfy yourself as to
|
||||||
## your rights to use the software. Also, please note that software in
|
## your rights to use the software. Also, please note that software in
|
||||||
## universe WILL NOT receive any review or updates from the Ubuntu security
|
## universe WILL NOT receive any review or updates from the Ubuntu security
|
||||||
## team.
|
## team.
|
||||||
# deb http://archive.ubuntu.com/ubuntu $STE universe
|
# deb http://archive.ubuntu.com/ubuntu $STE universe
|
||||||
# deb-src http://archive.ubuntu.com/ubuntu $STE universe
|
# deb-src http://archive.ubuntu.com/ubuntu $STE universe
|
||||||
|
|
||||||
deb http://security.ubuntu.com/ubuntu ${STE}-security main restricted
|
deb http://security.ubuntu.com/ubuntu ${STE}-security main restricted
|
||||||
deb-src http://security.ubuntu.com/ubuntu ${STE}-security main restricted
|
deb-src http://security.ubuntu.com/ubuntu ${STE}-security main restricted
|
||||||
@@EOF
|
@@EOF
|
||||||
mv ${ROOT}etc/apt/trusted.gpg.$$ ${ROOT}etc/apt/trusted.gpg
|
mv ${ROOT}etc/apt/trusted.gpg.$$ ${ROOT}etc/apt/trusted.gpg
|
||||||
|
|
||||||
# get rid of the .debs - we don't need them.
|
# get rid of the .debs - we don't need them.
|
||||||
chroot ${ROOT} apt-get clean
|
chroot ${ROOT} apt-get clean
|
||||||
rm -f ${ROOT}var/lib/apt/lists/*_*
|
rm -f ${ROOT}var/lib/apt/lists/*_*
|
||||||
rm -f ${ROOT}var/spool/postfix/maildrop/*
|
rm -f ${ROOT}var/spool/postfix/maildrop/*
|
||||||
chroot $ROOT apt-get update || true # give them fresh lists, but don't fail
|
chroot $ROOT apt-get update || true # give them fresh lists, but don't fail
|
||||||
rm ${ROOT}etc/resolv.conf
|
rm ${ROOT}etc/resolv.conf
|
||||||
|
chroot ${ROOT} dpkg-query -W --showformat='${Package} ${Version}\n' > livecd.manifest
|
||||||
|
|
||||||
mkdir -p livecd.mnt
|
mkdir -p livecd.mnt
|
||||||
MOUNTS="$MOUNTS $(pwd)/livecd.mnt"
|
MOUNTS="$MOUNTS $(pwd)/livecd.mnt"
|
||||||
DEV=$(losetup -f);
|
DEV=$(losetup -f);
|
||||||
|
|
||||||
# Make the filesystem, with some room for meta data and such
|
# Make the filesystem, with some room for meta data and such
|
||||||
SZ=$(python -c "print int(($(du -sk $ROOT|sed 's/[^0-9].*$//')*1.1+$USZ)/1024)")
|
SZ=$(python -c "print int(($(du -sk $ROOT|sed 's/[^0-9].*$//')*1.1+$USZ)/1024)")
|
||||||
(( SZ > 2047 )) && SZ=2047
|
(( SZ > 2047 )) && SZ=2047
|
||||||
SZ=2047 # XXX fix size for now
|
SZ=2047 # XXX fix size for now
|
||||||
|
|
||||||
for fsbs in 1024:65536; do
|
for fsbs in 1024:65536; do
|
||||||
FSBLOCK=${fsbs%:*}
|
FSBLOCK=${fsbs%:*}
|
||||||
COMP=${fsbs#*:}
|
COMP=${fsbs#*:}
|
||||||
IMGNAME=${IMG}-${FSBLOCK}
|
IMGNAME=${IMG}-${FS}-${FSBLOCK}
|
||||||
if [ ! -f ${IMGNAME} ]; then
|
if [ ! -f ${IMGNAME} ]; then
|
||||||
if [ -f old-${IMGNAME} ]; then
|
if [ -f old-${IMGNAME} ]; then
|
||||||
cp old-${IMGNAME} new-${IMGNAME}
|
cp old-${IMGNAME} new-${IMGNAME}
|
||||||
@ -193,7 +219,7 @@ for fsbs in 1024:65536; do
|
|||||||
mv new-${IMGNAME} ${IMGNAME}
|
mv new-${IMGNAME} ${IMGNAME}
|
||||||
cp ${IMGNAME} old-${IMGNAME}
|
cp ${IMGNAME} old-${IMGNAME}
|
||||||
fi
|
fi
|
||||||
create_compressed_fs $IMGNAME $COMP > livecd.cloop-${fsbs}
|
create_compressed_fs $IMGNAME $COMP > livecd.cloop-${FS}-${fsbs}
|
||||||
done
|
done
|
||||||
|
|
||||||
chroot ${ROOT} dpkg-query -W --showformat='${Package} ${Version}\n' > livecd.manifest
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user