XXX: Use a custom debootstrap script.
[tails.git] / data / debootstrap / tails-wheezy
blobbf3404f9b869b998a73c82834399ea932f8e8edd
1 mirror_style release
2 download_style apt
3 finddebs_style from-indices
4 variants - buildd fakechroot minbase scratchbox
5 keyring /usr/share/keyrings/debian-archive-keyring.gpg
7 if doing_variant fakechroot; then
8         test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started"
9 fi
11 case $ARCH in
12         alpha|ia64) LIBC="libc6.1" ;;
13         kfreebsd-*) LIBC="libc0.1" ;;
14         hurd-*)     LIBC="libc0.3" ;;
15         *)          LIBC="libc6" ;;
16 esac
18 work_out_debs () {
19         required="$(get_debs Priority: required)"
21         if doing_variant - || doing_variant fakechroot; then
22                 #required="$required $(get_debs Priority: important)"
23                 #  ^^ should be getting debconf here somehow maybe
24                 base="$(get_debs Priority: important)"
25         elif doing_variant buildd || doing_variant scratchbox; then
26                 base="apt build-essential"
27         elif doing_variant minbase; then
28                 base="apt"
29         fi
31         if doing_variant fakechroot; then
32                 # ldd.fake needs binutils
33                 required="$required binutils"
34         fi
36         case $MIRRORS in
37             https://*)
38                 base="$base apt-transport-https ca-certificates"
39                 ;;
40         esac
43 first_stage_install () {
44         extract $required
46         mkdir -p "$TARGET/var/lib/dpkg"
47         : >"$TARGET/var/lib/dpkg/status"
48         : >"$TARGET/var/lib/dpkg/available"
50         setup_etc
51         if [ ! -e "$TARGET/etc/fstab" ]; then
52                 echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
53                 chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
54         fi
56         x_feign_install () {
57                 local pkg="$1"
58                 local deb="$(debfor $pkg)"
59                 local ver="$(extract_deb_field "$TARGET/$deb" Version)"
61                 mkdir -p "$TARGET/var/lib/dpkg/info"
63                 echo \
64 "Package: $pkg
65 Version: $ver
66 Maintainer: unknown
67 Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
69                 touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
70         }
72         x_feign_install dpkg
75 second_stage_install () {
76         setup_devices
78         x_core_install () {
79                 smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
80         }
82         p () {
83                 baseprog="$(($baseprog + ${1:-1}))"
84         }
86         if doing_variant fakechroot; then
87                 setup_proc_fakechroot
88         elif doing_variant scratchbox; then
89                 true
90         else
91                 setup_proc
92                 in_target /sbin/ldconfig
93         fi
95         DEBIAN_FRONTEND=noninteractive
96         DEBCONF_NONINTERACTIVE_SEEN=true
97         export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
99         baseprog=0
100         bases=7
102         p; progress $baseprog $bases INSTCORE "Installing core packages" #1
103         info INSTCORE "Installing core packages..."
105         p; progress $baseprog $bases INSTCORE "Installing core packages" #2
106         ln -sf mawk "$TARGET/usr/bin/awk"
107         x_core_install base-passwd
108         x_core_install base-files
109         p; progress $baseprog $bases INSTCORE "Installing core packages" #3
110         x_core_install dpkg
112         if [ ! -e "$TARGET/etc/localtime" ]; then
113                 ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
114         fi
116         if doing_variant fakechroot; then
117                 install_fakechroot_tools
118         fi
120         p; progress $baseprog $bases INSTCORE "Installing core packages" #4
121         x_core_install $LIBC
123         p; progress $baseprog $bases INSTCORE "Installing core packages" #5
124         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
130         p; progress $baseprog $bases INSTCORE "Installing core packages" #7
131         if doing_variant -; then
132                 x_core_install debconf
133         fi
135         baseprog=0
136         bases=$(set -- $required; echo $#)
138         info UNPACKREQ "Unpacking required packages..."
140         exec 7>&1
142         smallyes '' |
143                 (repeatn 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages.  This will be attempted up to five times." "" \
144                 dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 || echo EXITCODE $?) |
145                 dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING
147         info CONFREQ "Configuring required packages..."
149         echo \
150 "#!/bin/sh
151 exit 101" > "$TARGET/usr/sbin/policy-rc.d"
152         chmod 755 "$TARGET/usr/sbin/policy-rc.d"
154         mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
155         echo \
156 "#!/bin/sh
157 echo
158 echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
159         chmod 755 "$TARGET/sbin/start-stop-daemon"
161         setup_dselect_method apt
163         smallyes '' |
164                 (in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" \
165                 dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 || echo EXITCODE $?) |
166                 dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING
168         baseprog=0
169         bases="$(set -- $base; echo $#)"
171         info UNPACKBASE "Unpacking the base system..."
173         setup_available $required $base
174         done_predeps=
175         while predep=$(get_next_predep); do
176                 # We have to resolve dependencies of pre-dependencies manually because
177                 # dpkg --predep-package doesn't handle this.
178                 predep=$(without "$(without "$(resolve_deps $predep)" "$required")" "$done_predeps")
179                 # XXX: progress is tricky due to how dpkg_progress works
180                 # -- cjwatson 2009-07-29
181                 p; smallyes '' |
182                 in_target dpkg --force-overwrite --force-confold --skip-same-version --install $(debfor $predep)
183                 base=$(without "$base" "$predep")
184                 done_predeps="$done_predeps $predep"
185         done
187         smallyes '' |
188                 (repeatn 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages.  This will be re-attempted up to five times." "" \
189                 dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 || echo EXITCODE $?) |
190                 dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING
192         info CONFBASE "Configuring the base system..."
194         smallyes '' |
195                 (repeatn 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages.  This will be re-attempted up to five times." "" \
196                 dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 || echo EXITCODE $?) |
197                 dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING
199         mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
200         rm -f "$TARGET/usr/sbin/policy-rc.d"
202         progress $bases $bases CONFBASE "Configuring base system"
203         info BASESUCCESS "Base system installed successfully."