| 1 |
#! /bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
. /usr/share/debconf/confmodule |
| 5 |
db_capb backup |
| 6 |
|
| 7 |
. /usr/lib/base-installer/library.sh |
| 8 |
|
| 9 |
ETCDIR=/target/etc |
| 10 |
KEYRING=/usr/share/keyrings/archive.gpg |
| 11 |
|
| 12 |
# Architecture and OS detection |
| 13 |
ARCH=`udpkg --print-architecture` |
| 14 |
OS=`udpkg --print-os` |
| 15 |
|
| 16 |
# Set initial value to includes and excludes |
| 17 |
db_get base-installer/includes |
| 18 |
INCLUDES="$(printf '%s' "$RET" | sed 's/ /,/g')" || true |
| 19 |
|
| 20 |
db_get base-installer/excludes |
| 21 |
EXCLUDES="$(printf '%s' "$RET" | sed 's/ /,/g')" || true |
| 22 |
|
| 23 |
# Check if a specific script should be used |
| 24 |
if db_get base-installer/debootstrap_script && [ "$RET" ]; then |
| 25 |
if expr "$RET" : / >/dev/null ; then |
| 26 |
DEBOOTSTRAP_SCRIPT="$RET" |
| 27 |
else |
| 28 |
DEBOOTSTRAP_SCRIPT=/usr/share/debootstrap/scripts/"$RET" |
| 29 |
fi |
| 30 |
if [ ! -e "$DEBOOTSTRAP_SCRIPT" ]; then |
| 31 |
error "debootstrap script '$DEBOOTSTRAP_SCRIPT' doesn't exist" |
| 32 |
fi |
| 33 |
fi |
| 34 |
|
| 35 |
# Check if a specific variant should be used |
| 36 |
if db_get base-installer/debootstrap_variant && [ "$RET" ]; then |
| 37 |
DEBOOTSTRAP_VARIANT="--variant=$RET" |
| 38 |
fi |
| 39 |
|
| 40 |
# TODO: on netboot images only |
| 41 |
#if is_ports_architecture $ARCH ; then |
| 42 |
# DEBOOTSTRAP_EXTRA_SUITES="--extra-suites=unreleased" |
| 43 |
#fi |
| 44 |
|
| 45 |
# Avoid debconf sending email during the base install process |
| 46 |
DEBCONF_ADMIN_EMAIL="" |
| 47 |
export DEBCONF_ADMIN_EMAIL |
| 48 |
|
| 49 |
SUBARCH="$(archdetect)" |
| 50 |
SUBARCH="${SUBARCH#*/}" |
| 51 |
|
| 52 |
# Avoid locale related errors during package installations |
| 53 |
export IT_LANG_OVERRIDE=C |
| 54 |
|
| 55 |
|
| 56 |
# See kernel/README for the architecture-specific functions expected here |
| 57 |
if [ -f /usr/lib/base-installer/kernel.sh ]; then |
| 58 |
. /usr/lib/base-installer/kernel.sh |
| 59 |
else |
| 60 |
arch_get_kernel_flavour () { |
| 61 |
warning "Unknown architecture '$ARCH'." |
| 62 |
return 0 |
| 63 |
} |
| 64 |
arch_check_usable_kernel () { |
| 65 |
warning "Unknown architecture '$ARCH'." |
| 66 |
return 0 |
| 67 |
} |
| 68 |
arch_get_kernel () { |
| 69 |
warning "Unknown architecture '$ARCH'." |
| 70 |
} |
| 71 |
fi |
| 72 |
|
| 73 |
FLAVOUR="$(arch_get_kernel_flavour || true)" |
| 74 |
|
| 75 |
install_base_system () { |
| 76 |
# library.sh sets variables depending on various checks, |
| 77 |
# including base's installability. In this case |
| 78 |
# (e.g. netinst), PROTOCOL will be set to file, MIRROR empty, |
| 79 |
# and DIRECTORY to /cdrom; let's look at mirror/protocol to |
| 80 |
# see whether some https is wanted in the installed system, |
| 81 |
# and add packages which can be guessed by debootstrap: |
| 82 |
db_get mirror/protocol |
| 83 |
mirror_protocol="$RET" || true |
| 84 |
if [ "$mirror_protocol" = https ]; then |
| 85 |
INCLUDES="$INCLUDES,ca-certificates" |
| 86 |
fi |
| 87 |
|
| 88 |
if [ -s /cdrom/.disk/base_include ]; then |
| 89 |
INCLUDES="$INCLUDES,`grep -v '^#' /cdrom/.disk/base_include | tr '\n' , | sed 's/^,//g;s/,$//'`" |
| 90 |
fi |
| 91 |
|
| 92 |
if [ -s /cdrom/.disk/base_exclude ]; then |
| 93 |
EXCLUDES="$EXCLUDES,`grep -v '^#' /cdrom/.disk/base_exclude | tr '\n' , | sed 's/^,//g;s/,$//'`" |
| 94 |
fi |
| 95 |
|
| 96 |
db_progress INFO base-installer/progress/preparing |
| 97 |
|
| 98 |
if [ "${INCLUDES}" ]; then |
| 99 |
include="--include=${INCLUDES}" |
| 100 |
fi |
| 101 |
if [ "${EXCLUDES}" ]; then |
| 102 |
exclude="--exclude=${EXCLUDES}" |
| 103 |
fi |
| 104 |
sigcheck="--no-check-gpg" |
| 105 |
if [ "$PROTOCOL" = http ] || [ "$PROTOCOL" = ftp ]; then |
| 106 |
if type gpgv >/dev/null; then |
| 107 |
if ! db_get debian-installer/allow_unauthenticated || [ "$RET" != true ]; then |
| 108 |
sigcheck="--keyring=${KEYRING}" |
| 109 |
fi |
| 110 |
else |
| 111 |
warning "gpgv not found, not authenticating archive" |
| 112 |
fi |
| 113 |
elif [ "$PROTOCOL" = https ]; then |
| 114 |
if db_get debian-installer/allow_unauthenticated_ssl && [ "$RET" = true ]; then |
| 115 |
sigcheck="$sigcheck --no-check-certificate" |
| 116 |
fi |
| 117 |
fi |
| 118 |
|
| 119 |
test -d $ETCDIR || mkdir -p $ETCDIR |
| 120 |
|
| 121 |
local copied_fstab= |
| 122 |
if [ -f /target/etc/fstab ] ; then |
| 123 |
# programs in debootstrap may scrawl on the fstab and |
| 124 |
# a configured fstab can cause problems, so make a backup |
| 125 |
# to be restored later and create a dummy file instead |
| 126 |
copied_fstab=1 |
| 127 |
cp /target/etc/fstab /target/etc/fstab.orig |
| 128 |
echo "# UNCONFIGURED FSTAB FOR BASE SYSTEM" >/target/etc/fstab |
| 129 |
fi |
| 130 |
|
| 131 |
if [ "$PROTOCOL" = "http" ]; then |
| 132 |
db_get mirror/http/proxy |
| 133 |
http_proxy="$RET" || true |
| 134 |
if [ "$http_proxy" ]; then |
| 135 |
export http_proxy |
| 136 |
fi |
| 137 |
elif [ "$PROTOCOL" = "https" ]; then |
| 138 |
db_get mirror/https/proxy |
| 139 |
https_proxy="$RET" || true |
| 140 |
if [ "$https_proxy" ]; then |
| 141 |
export https_proxy |
| 142 |
fi |
| 143 |
fi |
| 144 |
|
| 145 |
# clean up after any past debootstrap run |
| 146 |
rm -f /target/var/lib/apt/* 2>/dev/null || true |
| 147 |
|
| 148 |
local debootstrap_failed= |
| 149 |
if search-path cdebootstrap; then |
| 150 |
cdebootstrap || debootstrap_failed=$? |
| 151 |
else |
| 152 |
log-output -t debootstrap run-debootstrap \ |
| 153 |
--components="${COMPONENTS}" \ |
| 154 |
--debian-installer \ |
| 155 |
--resolve-deps \ |
| 156 |
${include} ${exclude} \ |
| 157 |
${sigcheck} \ |
| 158 |
${DEBOOTSTRAP_VARIANT} \ |
| 159 |
${DEBOOTSTRAP_EXTRA_SUITES} \ |
| 160 |
${DISTRIBUTION} /target \ |
| 161 |
"$PROTOCOL://$MIRROR$DIRECTORY" \ |
| 162 |
${DEBOOTSTRAP_SCRIPT} \ |
| 163 |
|| debootstrap_failed=$? |
| 164 |
fi |
| 165 |
|
| 166 |
if [ "$copied_fstab" ]; then |
| 167 |
mv /target/etc/fstab.orig /target/etc/fstab |
| 168 |
fi |
| 169 |
|
| 170 |
if [ "$debootstrap_failed" ]; then |
| 171 |
exit_error base-installer/debootstrap-failed |
| 172 |
fi |
| 173 |
|
| 174 |
# If we need SSL certificates, copy them in now. |
| 175 |
if [ "$PROTOCOL" = "https" -o "$mirror_protocol" = "https" ] && [ -d /etc/ssl/certs ]; then |
| 176 |
if find /etc/ssl/certs/ -name \*.crt | grep -q .; then |
| 177 |
mkdir -p /target/usr/local/share/ca-certificates |
| 178 |
cp -a /etc/ssl/certs/*.crt /target/usr/local/share/ca-certificates/ |
| 179 |
chroot /target update-ca-certificates || true |
| 180 |
fi |
| 181 |
fi |
| 182 |
|
| 183 |
# Progress bar is now stepped to 100 |
| 184 |
} |
| 185 |
|
| 186 |
waypoint 1 check_target |
| 187 |
waypoint 1 get_mirror_info |
| 188 |
waypoint 100 install_base_system |
| 189 |
waypoint 1 pre_install_hooks |
| 190 |
waypoint 1 setup_dev |
| 191 |
waypoint 1 configure_apt_preferences |
| 192 |
waypoint 1 configure_apt |
| 193 |
waypoint 3 apt_update |
| 194 |
waypoint 5 post_install_hooks |
| 195 |
waypoint 1 pick_kernel |
| 196 |
waypoint 20 install_kernel |
| 197 |
waypoint 10 install_extra |
| 198 |
waypoint 0 final_apt_preferences |
| 199 |
waypoint 0 cleanup |
| 200 |
|
| 201 |
run_waypoints base-installer/progress/installing-base |
| 202 |
exit 0 |