~codyshepherd/livecd-rootfs/xenial-proposed-snaps-manifest

« back to all changes in this revision

Viewing changes to debian/livecd.sh

  • Committer: LaMont Jones
  • Date: 2005-01-07 06:42:03 UTC
  • Revision ID: Arch-1:lamont.jones@canonical.com--2004-work%livecd-rootfs--mainline--0--base-0
initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -xe
 
2
 
 
3
# Depends: debootstrap, rsync, cloop-utils, python
 
4
 
 
5
cleanup() {
 
6
    for mnt in $MOUNTS; do
 
7
        umount $mnt || true
 
8
    done
 
9
 
 
10
    [ -n "$DEV" ] && losetup -d $DEV
 
11
    grep ${ROOT} /proc/mounts && return 1 || return 0
 
12
}
 
13
 
 
14
if [ $(id -u) != 0 ];then
 
15
  echo "must be run as root"
 
16
  exit 2
 
17
fi
 
18
 
 
19
umask 022
 
20
export TTY=unknown
 
21
case $(hostname --fqdn) in
 
22
  *.mmjgroup.com)       MIRROR=http://ia/ubuntu;;
 
23
  *.warthogs.hbd.com)   MIRROR=http://jackass.warthogs.hbd.com;;
 
24
  *.ubuntu.com)         MIRROR=http://jackass.warthogs.hbd.com;;
 
25
  *)                    MIRROR=http://archive.ubuntu.com/ubuntu;;
 
26
esac
 
27
 
 
28
ROOT=$(pwd)/chroot-livecd/
 
29
IMG=livecd.fsimg
 
30
MOUNTS="${ROOT}dev/pts ${ROOT}dev/shm ${ROOT}.dev ${ROOT}dev $(pwd)/$IMG ${ROOT}proc"
 
31
 
 
32
rm -rf ${ROOT}
 
33
 
 
34
mkdir -p ${ROOT}var/cache/debconf
 
35
cat << @@EOF > ${ROOT}var/cache/debconf/config.dat
 
36
Name: debconf/frontend
 
37
Template: debconf/frontend
 
38
Value: Noninteractive
 
39
Owners: debconf
 
40
Flags: seen
 
41
@@EOF
 
42
 
 
43
# need to defer udev until the apt-get, since debootstrap doesn't believe
 
44
# in diversions
 
45
debootstrap --exclude=udev,ubuntu-base hoary $ROOT $MIRROR
 
46
 
 
47
# Just make a few things go away, which lets us skip a few other things.
 
48
# sadly, udev's postinst does some actual work, so we can't just make it
 
49
# go away completely.
 
50
DIVERTS="usr/sbin/mkinitrd usr/sbin/invoke-rc.d etc/init.d/dbus-1 sbin/udevd"
 
51
for file in $DIVERTS; do
 
52
    mkdir -p ${ROOT}${file%/*}
 
53
    cp /bin/true ${ROOT}$file
 
54
    (echo /$file; echo /${file}.livecd; echo :) >> ${ROOT}var/lib/dpkg/diversions
 
55
done
 
56
 
 
57
# /bin/true won't cut it for mkinitrd, need to have -o support.
 
58
cat << @@EOF > ${ROOT}/usr/sbin/mkinitrd
 
59
#!/usr/bin/python
 
60
import sys
 
61
 
 
62
for i in range(len(sys.argv)):
 
63
    if sys.argv[i]=='-o':
 
64
        open(sys.argv[i+1],"w")
 
65
@@EOF
 
66
chmod 755 ${ROOT}usr/sbin/mkinitrd
 
67
 
 
68
trap "cleanup" 0 1 2 3 15
 
69
 
 
70
# Make a good /etc/kernel-img.conf for the kernel packages
 
71
cat << @@EOF >> ${ROOT}etc/kernel-img.conf
 
72
do_symlinks = yes
 
73
relative_links = yes
 
74
do_bootloader = no
 
75
do_bootfloppy = no
 
76
do_initrd = yes
 
77
link_in_boot = no
 
78
@@EOF
 
79
 
 
80
mkdir -p ${ROOT}proc
 
81
mount -tproc none ${ROOT}proc
 
82
 
 
83
# In addition to the ones we got from apt, trust whatever the local system
 
84
# believes in, but put things back afterwards.
 
85
cp ${ROOT}etc/apt/trusted.gpg ${ROOT}etc/apt/trusted.gpg.$$
 
86
cat /etc/apt/trusted.gpg >> ${ROOT}etc/apt/trusted.gpg
 
87
 
 
88
# Create a good sources.list, and finish the install
 
89
echo deb $MIRROR hoary main restricted > ${ROOT}etc/apt/sources.list
 
90
chroot $ROOT apt-get update
 
91
chroot $ROOT apt-get -y install ubuntu-base ubuntu-desktop linux-386 </dev/null
 
92
 
 
93
# remove our diversions
 
94
for file in $DIVERTS; do
 
95
    ls -ld ${ROOT}$file ${ROOT}$file.livecd || true
 
96
    rm -f ${ROOT}$file
 
97
    chroot $ROOT dpkg-divert --remove --rename /$file
 
98
done
 
99
 
 
100
# And make this look more pristene
 
101
cleanup
 
102
cat << @@EOF > ${ROOT}etc/apt/sources.list
 
103
echo deb http://archive.ubuntu.com/ubuntu hoary main restricted
 
104
echo deb-src http://archive.ubuntu.com/ubuntu hoary main restricted
 
105
@@EOF
 
106
mv ${ROOT}etc/apt/trusted.gpg.$$ ${ROOT}etc/apt/trusted.gpg
 
107
 
 
108
# get rid of the .debs - we don't need them.
 
109
chroot ${ROOT} apt-get clean
 
110
rm ${ROOT}var/lib/apt/lists/*_*
 
111
 
 
112
# Make the filesystem, with some room for meta data and such
 
113
USZ="400*1024"          # 400MB for the user
 
114
UINUM=""                # blank (default), or number of inodes desired.
 
115
SZ=$(python -c "print int($(du -sk $ROOT|sed 's/[^0-9].*$//')*1.1+$USZ)")
 
116
dd if=/dev/zero of=$IMG seek=$SZ bs=1024 count=1
 
117
if [-n "$UINUM" ]; then
 
118
    INUM="-N "$(python -c "print $(find ${ROOT} | wc -l)+$UINUM")
 
119
fi
 
120
mke2fs $INUM -Osparse_super -F $IMG
 
121
DEV=$(losetup -f);
 
122
losetup $DEV $IMG
 
123
mkdir -p livecd.mnt
 
124
mount $DEV livecd.mnt
 
125
rsync -a ${ROOT}/ livecd.mnt
 
126
 
 
127
rm -rf ${ROOT} &
 
128
 
 
129
create_compressed_fs $IMG 65536 > livecd.cloop