ready for tagging
[util-vserver.git] / distrib / hoary / debootstrap.script
1 default_mirror http://old-releases.ubuntu.com/ubuntu
2 mirror_style release
3 download_style apt
4
5 work_out_debs () {
6
7     required="base-files base-passwd bash bsdutils coreutils libacl1 libattr1 debconf debconf-i18n liblocale-gettext-perl libtext-iconv-perl libtext-wrapi18n-perl libtext-charwidth-perl debianutils diff dpkg dselect libblkid1 e2fsprogs e2fslibs libcomerr2 libss2 libuuid1 findutils grep gzip hostname libcap1 libdb1-compat libdb3 libncurses5 libnewt0.51 libpam-modules libpam-runtime libpam0g libpopt0 login makedev mawk mount ncurses-base ncurses-bin passwd perl-base procps python-minimal python2.4-minimal sed slang1a-utf8 lsb-base initscripts sysvinit sysv-rc tar util-linux zlib1g whiptail libgcc1 gcc-3.3-base libstdc++5"
8
9     base="adduser alsa-base alsa-utils apt apt-utils aptitude at base-config bind9-host bsdmainutils bzip2 console-common console-data console-tools cpio cramfsprogs cron dash dhcp3-client dhcp3-common discover1 discover1-data dmsetup dnsutils dosfstools ed eject ethtool evms evms-ncurses fdutils file ftp gettext-base gnupg grepmap groff-base hdparm hotplug ifrename ifupdown info initrd-tools iproute iptables iputils-arping iputils-ping iputils-tracepath jfsutils klogd less libasound2 libbz2-1.0 libconsole libdb4.2 libdevmapper1.00 libdiscover1 libdns16 libevms-2.5 libfribidi0 libgc1 libgcrypt11 libgdbm3 libgnutls11 libgpg-error0 libgpmg1 libidn11 libisc7 libiw27 libldap2 liblockfile1 liblwres1 liblzo1 libmagic1 libncursesw5 libopencdk8 libparted1.6-12 libpcap0.8 libreiserfs0.3-0 libsasl2 libsasl2-modules libsigc++-1.2-5c102 libssl0.9.7 libtasn1-2 libusb-0.1-4 libwrap0 locales logrotate lsb-release lshw lsof lvm-common lvm10 lvm2 mailx man-db manpages mdadm mii-diag mime-support module-init-tools mtr-tiny mutt nano net-tools netbase netcat netkit-inetd ntp ntpdate openssh-client parted pciutils popularity-contest postfix postfix-tls ppp pppconfig pppoeconf psmisc python python2.4 reiser4progs reiserfsprogs reportbug rsync strace sudo sysklogd tcpd tcpdump telnet time ubuntu-base ubuntu-keyring udev usbutils vim vim-common w3m wget wireless-tools xfsprogs"
10
11     without_package () {
12         echo "$2" | tr ' ' '\n' | grep -v "^$1$" | tr '\n' ' '
13     }
14     subst_package () {
15         echo "$3" | tr ' ' '\n' | sed "s/^$1$/$2/" | tr '\n' ' '
16     }
17
18     LIBC6=libc6
19
20     case $ARCH in
21         "i386")
22             required="$required libc6 libc6-i686"
23             base="$base dmidecode libelfg0 ltrace memtest86+ libreadline4"
24             ;;
25         "powerpc")
26             required="$required libc6 libreadline4"
27             base="$base hfsplus hfsutils libelfg0 libhfsp0 ltrace mac-fdisk pmac-fdisk powerpc-utils"
28             ;;
29         "amd64")
30             required="$required libc6"
31             base="$base dmidecode libelfg0 ltrace memtest86+ libreadline4"
32             ;;
33         "ia64")
34             required="$required libc6.1 libunwind7"
35             base="$base dmidecode libreadline4"
36             LIBC6="libc6.1"
37             ;;
38         "sparc")
39             required="$required libc6"
40             base="$base lib64gcc1 libc6-sparc64 libreadline4"
41             ;;
42         *)
43             # who knows?
44             ;;
45     esac
46 }
47
48 install_debs () {
49     first_stage_install
50     second_stage_install
51 }
52
53 first_stage_install () {
54     extract $required
55
56     mkdir -p "$TARGET/var/lib/dpkg"
57     : >"$TARGET/var/lib/dpkg/status"
58     echo >"$TARGET/var/lib/dpkg/available"
59
60     setup_etc
61     if [ ! -e "$TARGET/etc/fstab" ]; then
62         echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
63         chown 0.0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
64     fi
65
66     setup_devices
67
68     x_feign_install () {
69         local pkg="$1"
70         local deb="$(debfor $pkg)"
71         local ver="$(
72             ar -p "$TARGET/$deb" control.tar.gz | zcat |
73                 tar -O -xf - control ./control 2>/dev/null |
74                 sed -ne 's/^Version: *//Ip' | head -n 1
75         )"
76
77         mkdir -p "$TARGET/var/lib/dpkg/info"
78
79         echo \
80 "Package: $pkg
81 Version: $ver
82 Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
83
84         touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
85     }
86
87     x_feign_install dpkg
88 }
89
90 second_stage_install () {
91     x_core_install () {
92         smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
93     }
94     p () {
95         baseprog="$(($baseprog + ${1:-1}))"
96     }
97
98     DEBIAN_FRONTEND=noninteractive
99     DEBCONF_NONINTERACTIVE_SEEN=true
100     export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
101
102     baseprog=0
103     bases=7
104
105     setup_proc
106     in_target /sbin/ldconfig
107
108     p; progress $baseprog $bases INSTCORE "Installing core packages" #1
109     info INSTCORE "Installing core packages..."
110
111     p; progress $baseprog $bases INSTCORE "Installing core packages" #2
112     ln -sf mawk $TARGET/usr/bin/awk
113     x_core_install base-files base-passwd
114     p; progress $baseprog $bases INSTCORE "Installing core packages" #3
115     x_core_install dpkg
116
117     if [ ! -e "$TARGET/etc/localtime" ]; then
118         ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
119     fi
120
121     p; progress $baseprog $bases INSTCORE "Installing core packages" #4
122     x_core_install $LIBC6
123
124     p; progress $baseprog $bases INSTCORE "Installing core packages" #5
125     x_core_install perl-base
126     p; progress $baseprog $bases INSTCORE "Installing core packages" #6
127     rm $TARGET/usr/bin/awk
128     x_core_install mawk
129     p; progress $baseprog $bases INSTCORE "Installing core packages" #7
130     x_core_install debconf
131
132     baseprog=0
133     bases="$(set -- $required; echo $#)"
134
135     info UNPACKREQ "Unpacking required packages..."
136
137     smallyes '' | (repeat 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages.  This will be attempted up to five times." "" dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 | dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING) 7>&1
138
139     baseprog=0
140
141     info CONFREQ "Configuring required packages..."
142
143     mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
144     echo \
145 "#!/bin/sh
146 echo
147 echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
148     chmod 755 "$TARGET/sbin/start-stop-daemon"
149
150     setup_dselect_method apt
151     #on_exit "(in_target_nofail umount /dev/pts) || true"
152
153     smallyes '' | (in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 | dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING) 7>&1
154
155     baseprog=0
156     bases="$(set -- $base; echo $#)"
157
158     info UNPACKBASE "Unpacking the base system..."
159
160     smallyes '' | (repeat 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages.  This will be re-attempted up to five times." "" dpkg --status-fd 8 --force-auto-select --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 | dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING) 7>&1
161
162     baseprog=0
163
164     info CONFBASE "Configuring the base system..."
165
166     mv "$TARGET/usr/sbin/sendmail" "$TARGET/usr/sbin/sendmail.REAL"
167     ln -s /bin/true "$TARGET/usr/sbin/sendmail"
168
169     smallyes '' | (repeat 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages.  This will be attempted 5 times." "" dpkg --status-fd 8 --force-confold --skip-same-version  --configure -a 8>&1 1>&7 | dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING) 7>&1
170
171     rm -f "$TARGET/usr/sbin/sendmail"
172     mv "$TARGET/usr/sbin/sendmail.REAL" "$TARGET/usr/sbin/sendmail"
173
174     mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
175
176     progress $bases $bases CONFBASE "Configuring base system"
177     info BASESUCCESS "Base system installed successfully."
178 }
179