| 1 | # emdebian build chroot support script. |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2007-2008 Neil Williams <codehelp@debian.org> |
|---|
| 4 | # |
|---|
| 5 | # This package is free software; you can redistribute it and/or modify |
|---|
| 6 | # it under the terms of the GNU General Public License as published by |
|---|
| 7 | # the Free Software Foundation; either version 3 of the License, or |
|---|
| 8 | # (at your option) any later version. |
|---|
| 9 | # |
|---|
| 10 | # This program is distributed in the hope that it will be useful, |
|---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | # GNU General Public License for more details. |
|---|
| 14 | # |
|---|
| 15 | # You should have received a copy of the GNU General Public License |
|---|
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | # |
|---|
| 18 | |
|---|
| 19 | mirror_style release |
|---|
| 20 | download_style apt |
|---|
| 21 | |
|---|
| 22 | work_out_debs () { |
|---|
| 23 | |
|---|
| 24 | required="base-files base-passwd bash bsdutils coreutils libacl1 |
|---|
| 25 | libattr1 debconf debconf-i18n liblocale-gettext-perl libtext-wrapi18n-perl |
|---|
| 26 | libtext-charwidth-perl debianutils diff dpkg dselect libblkid1 e2fsprogs |
|---|
| 27 | e2fslibs libcomerr2 libss2 libuuid1 findutils grep gzip hostname libcap1 |
|---|
| 28 | libc6 libdb1-compat libncurses5 libnewt0.52 libpam-modules |
|---|
| 29 | libpam-runtime libpam0g libperl5.10 libpopt0 login makedev mawk |
|---|
| 30 | mount ncurses-base ncurses-bin passwd perl-base procps sed |
|---|
| 31 | initscripts sysvinit sysv-rc tar util-linux whiptail libgcc1 libstdc++6" |
|---|
| 32 | |
|---|
| 33 | base="adduser apt apt-cross apt-utils autoconf automake |
|---|
| 34 | build-essential cpio cpp cron dash debhelper debian-archive-keyring |
|---|
| 35 | devscripts dhcp3-client dialog dpatch dpkg-cross dpkg-dev emdebian-tools |
|---|
| 36 | fakeroot fdutils gawk gcc gcc-4.2-base gettext-base gnupg gpgv ifupdown |
|---|
| 37 | iputils-ping klogd libbz2-1.0 libc6-dev libclass-accessor-perl nano |
|---|
| 38 | libconfig-auto-perl libconfig-inifiles-perl libfile-homedir-perl |
|---|
| 39 | libgdbm3 libldap-2.4-2 liblzo1 libpcap0.8 libpcre3 |
|---|
| 40 | libsasl2-2 libselinux1 libsepol1 libslang2 libssl0.9.8 libtasn1-3 |
|---|
| 41 | libtext-iconv-perl libtextwrap1 libusb-0.1-4 libwrap0 lsb-base |
|---|
| 42 | mktemp net-tools netbase openbsd-inetd perl perl-modules readline-common |
|---|
| 43 | sysklogd sysvinit-utils tcpd tzdata update-inetd wget zlib1g " |
|---|
| 44 | |
|---|
| 45 | without_package () { |
|---|
| 46 | echo "$2" | tr ' ' '\n' | grep -v "^$1$" | tr '\n' ' ' |
|---|
| 47 | } |
|---|
| 48 | subst_package () { |
|---|
| 49 | echo "$3" | tr ' ' '\n' | sed "s/^$1$/$2/" | tr '\n' ' ' |
|---|
| 50 | } |
|---|
| 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 | conditional_cp /etc/resolv.conf "$TARGET" |
|---|
| 66 | conditional_cp /etc/hostname "$TARGET" |
|---|
| 67 | conditional_cp /etc/hosts "$TARGET" |
|---|
| 68 | |
|---|
| 69 | setup_devices |
|---|
| 70 | |
|---|
| 71 | x_feign_install () { |
|---|
| 72 | local pkg="$1" |
|---|
| 73 | local deb="$(debfor $pkg)" |
|---|
| 74 | local ver="$( |
|---|
| 75 | ar -p "$TARGET/$deb" control.tar.gz | zcat | |
|---|
| 76 | tar -O -xf - control ./control 2>/dev/null | |
|---|
| 77 | sed -ne 's/^Version: *//Ip' | head -n 1 |
|---|
| 78 | )" |
|---|
| 79 | |
|---|
| 80 | mkdir -p "$TARGET/var/lib/dpkg/info" |
|---|
| 81 | |
|---|
| 82 | echo \ |
|---|
| 83 | "Package: $pkg |
|---|
| 84 | Version: $ver |
|---|
| 85 | Status: install ok installed" >> "$TARGET/var/lib/dpkg/status" |
|---|
| 86 | |
|---|
| 87 | touch "$TARGET/var/lib/dpkg/info/${pkg}.list" |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | x_feign_install dpkg |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | second_stage_install () { |
|---|
| 94 | x_core_install () { |
|---|
| 95 | smallyes '' | in_target dpkg --force-depends --install $(debfor "$@") |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | p () { |
|---|
| 99 | baseprog="$(($baseprog + ${1:-1}))" |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | setup_proc |
|---|
| 103 | in_target /sbin/ldconfig |
|---|
| 104 | |
|---|
| 105 | DEBIAN_FRONTEND=noninteractive |
|---|
| 106 | DEBCONF_NONINTERACTIVE_SEEN=true |
|---|
| 107 | export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN |
|---|
| 108 | |
|---|
| 109 | baseprog=0 |
|---|
| 110 | bases=40 |
|---|
| 111 | |
|---|
| 112 | p; progress $baseprog $bases INSTBASE "Installing base system" #1 |
|---|
| 113 | info INSTCORE "Installing core packages..." |
|---|
| 114 | echo 'APT::Install-Recommends "false";' >> $TARGET/etc/apt/apt.conf |
|---|
| 115 | |
|---|
| 116 | p; progress $baseprog $bases INSTBASE "Installing base system" #2 |
|---|
| 117 | ln -sf mawk $TARGET/usr/bin/awk |
|---|
| 118 | x_core_install base-files base-passwd |
|---|
| 119 | p; progress $baseprog $bases INSTBASE "Installing base system" #3 |
|---|
| 120 | x_core_install dpkg |
|---|
| 121 | |
|---|
| 122 | if [ ! -e "$TARGET/etc/localtime" ]; then |
|---|
| 123 | ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime" |
|---|
| 124 | fi |
|---|
| 125 | |
|---|
| 126 | p; progress $baseprog $bases INSTBASE "Installing base system" #4 |
|---|
| 127 | x_core_install libc6 |
|---|
| 128 | |
|---|
| 129 | p; progress $baseprog $bases INSTBASE "Installing base system" #5 |
|---|
| 130 | x_core_install perl-base |
|---|
| 131 | p; progress $baseprog $bases INSTBASE "Installing base system" #6 |
|---|
| 132 | rm $TARGET/usr/bin/awk |
|---|
| 133 | x_core_install mawk |
|---|
| 134 | p; progress $baseprog $bases INSTBASE "Installing base system" #7 |
|---|
| 135 | x_core_install debconf |
|---|
| 136 | |
|---|
| 137 | info UNPACKREQ "Unpacking required packages..." |
|---|
| 138 | |
|---|
| 139 | p; progress $baseprog $bases INSTBASE "Installing base system" #8 |
|---|
| 140 | smallyes '' | repeat 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages. This will be attempted up to five times." "" dpkg --force-depends --unpack $(debfor $required) |
|---|
| 141 | p 10; progress $baseprog $bases INSTBASE "Installing base system" #18 |
|---|
| 142 | |
|---|
| 143 | info CONFREQ "Configuring required packages..." |
|---|
| 144 | |
|---|
| 145 | mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL" |
|---|
| 146 | echo \ |
|---|
| 147 | "#!/bin/sh |
|---|
| 148 | echo |
|---|
| 149 | echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon" |
|---|
| 150 | chmod 755 "$TARGET/sbin/start-stop-daemon" |
|---|
| 151 | |
|---|
| 152 | setup_dselect_method apt |
|---|
| 153 | |
|---|
| 154 | p; progress $baseprog $bases INSTBASE "Installing base system" #19 |
|---|
| 155 | smallyes '' | in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" dpkg --configure --pending --force-configure-any --force-depends |
|---|
| 156 | p 10; progress $baseprog $bases INSTBASE "Installing base system" #29 |
|---|
| 157 | |
|---|
| 158 | info INSTBASE "Installing base packages..." |
|---|
| 159 | |
|---|
| 160 | p; progress $baseprog $bases INSTBASE "Installing base system" #30 |
|---|
| 161 | 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 --force-auto-select --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) |
|---|
| 162 | |
|---|
| 163 | rm -f "$TARGET/usr/sbin/sendmail" |
|---|
| 164 | ln -sf /bin/true "$TARGET/usr/sbin/sendmail" |
|---|
| 165 | |
|---|
| 166 | smallyes '' | repeat 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages. This will be attempted 5 times." "" dpkg --force-confold --skip-same-version --configure -a |
|---|
| 167 | |
|---|
| 168 | rm -f "$TARGET/usr/sbin/sendmail" |
|---|
| 169 | ln -sf exim4 "$TARGET/usr/sbin/sendmail" |
|---|
| 170 | |
|---|
| 171 | p 9; progress $baseprog $bases INSTBASE "Installing base system" #39 |
|---|
| 172 | |
|---|
| 173 | mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon" |
|---|
| 174 | |
|---|
| 175 | progress $bases $bases INSTBASE "Installing base system" #40 |
|---|
| 176 | info BASESUCCESS "Base system installed successfully." |
|---|
| 177 | } |
|---|