| 1 |
#! /bin/sh
|
| 2 |
set -e
|
| 3 |
|
| 4 |
. /usr/share/debconf/confmodule
|
| 5 |
db_capb backup
|
| 6 |
|
| 7 |
LOGFILE=/var/log/messages
|
| 8 |
ETCDIR=/target/etc
|
| 9 |
ARCH=`udpkg --print-architecture`
|
| 10 |
PROTOCOL=
|
| 11 |
MIRROR=
|
| 12 |
DIRECTORY=
|
| 13 |
COMPONENTS=
|
| 14 |
DISTRIBUTION=
|
| 15 |
INCLUDES=
|
| 16 |
EXCLUDES=
|
| 17 |
KERNEL=
|
| 18 |
KERNEL_LIST=/tmp/available_kernels.txt
|
| 19 |
KERNEL_MAJOR="$(uname -r | cut -d . -f 1,2)"
|
| 20 |
|
| 21 |
db_get debian-installer/kernel/subarchitecture
|
| 22 |
SUBARCH="$RET"
|
| 23 |
|
| 24 |
log() {
|
| 25 |
logger -t base-installer "$@"
|
| 26 |
}
|
| 27 |
error() {
|
| 28 |
log "error: $*"
|
| 29 |
}
|
| 30 |
warning() {
|
| 31 |
log "warning: $*"
|
| 32 |
}
|
| 33 |
info() {
|
| 34 |
log "info: $*"
|
| 35 |
}
|
| 36 |
|
| 37 |
exit_error() {
|
| 38 |
error "exiting on error $1"
|
| 39 |
db_progress stop
|
| 40 |
db_input critical $1 || [ $? -eq 30 ]
|
| 41 |
db_go
|
| 42 |
exit 1
|
| 43 |
}
|
| 44 |
|
| 45 |
check_target () {
|
| 46 |
# Make sure something is mounted on the target.
|
| 47 |
# Partconf causes the latter format.
|
| 48 |
if ! grep -q '/target ' /proc/mounts && \
|
| 49 |
! grep -q '/target/ ' /proc/mounts; then
|
| 50 |
exit_error base-installer/no_target_mounted
|
| 51 |
fi
|
| 52 |
|
| 53 |
# debootstrap has issues with awk already existing, and is not
|
| 54 |
# idempotent in general. Detect and abort.
|
| 55 |
if [ -e /target/usr/bin/awk -o -L /target/usr/bin/awk ] || \
|
| 56 |
[ -e /target/bin/sh -o -L /target/bin/sh ]; then
|
| 57 |
db_reset base-installer/use_unclean_target
|
| 58 |
db_input medium base-installer/use_unclean_target || true
|
| 59 |
db_go || exit 10
|
| 60 |
db_get base-installer/use_unclean_target
|
| 61 |
if [ "$RET" = false ]; then
|
| 62 |
exit_error base-installer/unclean_target_cancel
|
| 63 |
fi
|
| 64 |
fi
|
| 65 |
}
|
| 66 |
|
| 67 |
get_mirror_info () {
|
| 68 |
if [ -f /cdrom/.disk/base_installable ]; then
|
| 69 |
PROTOCOL=file
|
| 70 |
MIRROR=""
|
| 71 |
DIRECTORY="/cdrom/"
|
| 72 |
if [ -s /cdrom/.disk/base_components ]; then
|
| 73 |
COMPONENTS=`grep -v '^#' /cdrom/.disk/base_components | tr '\n' , | sed 's/,$//'`
|
| 74 |
else
|
| 75 |
COMPONENTS="*"
|
| 76 |
fi
|
| 77 |
if [ -s /cdrom/.disk/base_include ]; then
|
| 78 |
INCLUDES=`grep -v '^#' /cdrom/.disk/base_include | tr '\n' , | sed 's/,$//'`
|
| 79 |
fi
|
| 80 |
|
| 81 |
if [ -s /cdrom/.disk/base_exclude ]; then
|
| 82 |
EXCLUDES=`grep -v '^#' /cdrom/.disk/base_exclude | tr '\n' , | sed 's/,$//'`
|
| 83 |
fi
|
| 84 |
else
|
| 85 |
mirror_error=""
|
| 86 |
|
| 87 |
db_get mirror/protocol || mirror_error=1
|
| 88 |
PROTOCOL="$RET"
|
| 89 |
|
| 90 |
db_get mirror/$PROTOCOL/hostname || mirror_error=1
|
| 91 |
MIRROR="$RET"
|
| 92 |
|
| 93 |
db_get mirror/$PROTOCOL/directory || mirror_error=1
|
| 94 |
DIRECTORY="$RET"
|
| 95 |
|
| 96 |
COMPONENTS="main"
|
| 97 |
|
| 98 |
if [ "$mirror_error" = 1 ] || [ -z "$PROTOCOL" ] || [ -z "$MIRROR" ]; then
|
| 99 |
exit_error base-installer/cannot_install
|
| 100 |
fi
|
| 101 |
fi
|
| 102 |
|
| 103 |
if db_get mirror/suite && [ "$RET" ] ; then
|
| 104 |
SUITE=$RET
|
| 105 |
fi
|
| 106 |
|
| 107 |
# Find the distribution codename
|
| 108 |
APTLISTDIR=/target/var/lib/apt/lists
|
| 109 |
mkdir -p $APTLISTDIR
|
| 110 |
if [ file = "$PROTOCOL" ]; then
|
| 111 |
cp /cdrom/dists/$SUITE/Release $APTLISTDIR/tmp || nogetrel="/cdrom/dists/$SUITE/Release"
|
| 112 |
else
|
| 113 |
if [ "$PROTOCOL" = "http" ]; then
|
| 114 |
db_get mirror/http/proxy
|
| 115 |
http_proxy="$RET" || true
|
| 116 |
if [ "$http_proxy" ]; then
|
| 117 |
export http_proxy
|
| 118 |
fi
|
| 119 |
fi
|
| 120 |
|
| 121 |
wget "$PROTOCOL://$MIRROR$DIRECTORY/dists/$SUITE/Release" -O $APTLISTDIR/tmp || nogetrel="$PROTOCOL://$MIRROR$DIRECTORY/dists/$SUITE/Release"
|
| 122 |
fi
|
| 123 |
|
| 124 |
if [ "$nogetrel" != "" ]; then
|
| 125 |
db_subst base-installer/debootstrap/error/nogetrel SUBST0 "$nogetrel"
|
| 126 |
exit_error base-installer/debootstrap/error/nogetrel
|
| 127 |
fi
|
| 128 |
|
| 129 |
DISTRIBUTION=`grep ^Codename: $APTLISTDIR/tmp | cut -d' ' -f 2`
|
| 130 |
DEBOOTSTRAPLIST="$APTLISTDIR/debootstrap.invalid_dists_${DISTRIBUTION}"
|
| 131 |
mv $APTLISTDIR/tmp ${DEBOOTSTRAPLIST}_Release
|
| 132 |
}
|
| 133 |
|
| 134 |
install_base_system () {
|
| 135 |
if [ "${INCLUDES}" ]; then
|
| 136 |
include="--include=${INCLUDES}"
|
| 137 |
fi
|
| 138 |
if [ "${EXCLUDES}" ]; then
|
| 139 |
exclude="--exclude=${EXCLUDES}"
|
| 140 |
fi
|
| 141 |
|
| 142 |
test -d $ETCDIR || mkdir -p $ETCDIR
|
| 143 |
|
| 144 |
if [ -f /target/etc/fstab ] ; then
|
| 145 |
# programs in debootstrap may scrawl on the fstab,
|
| 146 |
# so make a backup to be restored later
|
| 147 |
copied_fstab=true
|
| 148 |
cp /target/etc/fstab /target/etc/fstab.orig
|
| 149 |
echo "# UNCONFIGURED FSTAB FOR BASE SYSTEM" >> /target/etc/fstab
|
| 150 |
fi
|
| 151 |
|
| 152 |
if [ "$PROTOCOL" = "http" ]; then
|
| 153 |
db_get mirror/http/proxy
|
| 154 |
http_proxy="$RET" || true
|
| 155 |
if [ "$http_proxy" ]; then
|
| 156 |
export http_proxy
|
| 157 |
fi
|
| 158 |
fi
|
| 159 |
|
| 160 |
# run the scripts found in hook directory before debootstrap
|
| 161 |
partsdir="/usr/lib/base-installer.d"
|
| 162 |
db_progress INFO base-installer/progress/preparing
|
| 163 |
|
| 164 |
tmpfile=/tmp/base-installer-hook.log
|
| 165 |
[ -d "$partsdir"] && info "Execution hook before debootstrap"
|
| 166 |
for script in `ls "$partsdir"/*`; do
|
| 167 |
base=$(basename $script | sed 's/[0-9]*//')
|
| 168 |
if ! db_progress INFO base-installer/progress/$base; then
|
| 169 |
db_subst base-installer/progress/fallback SCRIPT "$base"
|
| 170 |
db_progress INFO base-installer/progress/fallback
|
| 171 |
fi
|
| 172 |
|
| 173 |
if [ -x "$script" ] ; then
|
| 174 |
info "Running $script"
|
| 175 |
if ! "$script" 2>&1 $tmpfile ; then
|
| 176 |
log "warning: $script returned error code $?"
|
| 177 |
fi
|
| 178 |
else
|
| 179 |
error "Unable to execute $script"
|
| 180 |
fi
|
| 181 |
if [ -s "$tmpfile" ] ; then
|
| 182 |
logger -t base-installer < "$tmpfile"
|
| 183 |
rm -f "$tmpfile"
|
| 184 |
fi
|
| 185 |
done
|
| 186 |
|
| 187 |
if [ -e /usr/bin/cdebootstrap ]; then
|
| 188 |
/usr/bin/cdebootstrap || debootstrap_failed=$?
|
| 189 |
else
|
| 190 |
/usr/sbin/run-debootstrap \
|
| 191 |
--components="${COMPONENTS}" \
|
| 192 |
--debian-installer \
|
| 193 |
${include} ${exclude} \
|
| 194 |
${DISTRIBUTION} /target \
|
| 195 |
"$PROTOCOL://$MIRROR$DIRECTORY" \
|
| 196 |
2>> $LOGFILE || debootstrap_failed=$?
|
| 197 |
fi
|
| 198 |
|
| 199 |
if [ true = "$copied_fstab" ] ; then
|
| 200 |
mv /target/etc/fstab.orig /target/etc/fstab
|
| 201 |
fi
|
| 202 |
|
| 203 |
if [ "$debootstrap_failed" ] ; then
|
| 204 |
exit_error base-installer/debootstrap-failed
|
| 205 |
fi
|
| 206 |
|
| 207 |
# Progress bar is now stepped to 100.
|
| 208 |
}
|
| 209 |
|
| 210 |
configure_apt () {
|
| 211 |
# let apt inside the chroot see the cdrom
|
| 212 |
if [ "$PROTOCOL" = file ] ; then
|
| 213 |
if [ -n "$DIRECTORY" ]; then
|
| 214 |
umount /target$DIRECTORY 2>/dev/null || true
|
| 215 |
if [ ! -e /target/$DIRECTORY ]; then
|
| 216 |
mkdir -p /target/$DIRECTORY
|
| 217 |
fi
|
| 218 |
fi
|
| 219 |
if [ "$(KERNEL_MAJOR)" = 2.2 ]; then
|
| 220 |
CDDEV=`grep -i /cdrom /proc/mounts | cut -d' ' -f 1 | grep loop || true`
|
| 221 |
if [ "" != "$CDDEV" ] && \
|
| 222 |
db_get iso-scan/filename && [ "$RET" ] ; then
|
| 223 |
mount -r -o loop /hd-media/$RET /target/$DIRECTORY
|
| 224 |
elif db_get cdrom-detect/cdrom_device && [ -n "$RET" ]; then
|
| 225 |
umount $RET
|
| 226 |
mount -r -t iso9660 $RET /target/$DIRECTORY
|
| 227 |
else
|
| 228 |
warning "kernel 2.2.x failed to bind mount /target$DIRECTORY"
|
| 229 |
fi
|
| 230 |
elif ! mount -o bind $DIRECTORY /target$DIRECTORY; then
|
| 231 |
warning "failed to bind mount /target$DIRECTORY"
|
| 232 |
fi
|
| 233 |
# The bind mount is left mounted after this postinst exits,
|
| 234 |
# for future apt-install calls to use.
|
| 235 |
fi
|
| 236 |
|
| 237 |
# Move files to where apt expects them to avoid another download or copy.
|
| 238 |
APTLISTDIR=/target/var/lib/apt/lists
|
| 239 |
APTDIR=`echo $DIRECTORY | tr "/" "_"`
|
| 240 |
DEBOOTSTRAPLIST="$APTLISTDIR/debootstrap.invalid_dists_${DISTRIBUTION}"
|
| 241 |
APTLIST="$APTLISTDIR/${MIRROR}${APTDIR}_dists_${DISTRIBUTION}"
|
| 242 |
mv ${DEBOOTSTRAPLIST}_Release ${APTLIST}_Release
|
| 243 |
mv ${DEBOOTSTRAPLIST}_main_binary-${ARCH}_Packages ${APTLIST}_main_binary-${ARCH}_Packages
|
| 244 |
|
| 245 |
# sources.list uses space to separate the components, not comma
|
| 246 |
COMPONENTS=`echo $COMPONENTS | tr , " "`
|
| 247 |
APTSOURCE="$PROTOCOL://$MIRROR$DIRECTORY"
|
| 248 |
|
| 249 |
[ ! -d /target/etc/apt ] && mkdir -p /target/etc/apt
|
| 250 |
echo "deb $APTSOURCE $DISTRIBUTION $COMPONENTS" > /target/etc/apt/sources.list
|
| 251 |
}
|
| 252 |
|
| 253 |
create_devices () {
|
| 254 |
# RAID
|
| 255 |
if grep -q ^md /proc/mdstat ; then
|
| 256 |
apt-install mdadm
|
| 257 |
fi
|
| 258 |
# LVM: create VG and LV devices
|
| 259 |
if pvdisplay | grep -iq "physical volume ---" && grep -q " device-mapper$" /proc/misc; then
|
| 260 |
apt-install lvm2
|
| 261 |
mount -t proc proc /target/proc
|
| 262 |
mkdir -p /target/dev/mapper
|
| 263 |
if [ ! -e /target/dev/mapper/control ] ; then
|
| 264 |
major=$(grep "[0-9] misc$" /proc/devices | sed 's/[ ]\+misc//')
|
| 265 |
minor=$(grep "[0-9] device-mapper$" /proc/misc | sed 's/[ ]\+device-mapper//')
|
| 266 |
mknod /target/dev/mapper/control c $major $minor
|
| 267 |
fi
|
| 268 |
chroot /target vgscan --mknodes || true
|
| 269 |
umount /target/proc
|
| 270 |
fi
|
| 271 |
}
|
| 272 |
|
| 273 |
kernel_update_list () {
|
| 274 |
# Using 'uniq' to avoid listing the same kernel more then once.
|
| 275 |
chroot /target apt-cache search kernel-image | grep ^kernel-image | \
|
| 276 |
cut -d" " -f1 | uniq > $KERNEL_LIST
|
| 277 |
}
|
| 278 |
|
| 279 |
kernel_present () {
|
| 280 |
grep -q "^$1\$" $KERNEL_LIST
|
| 281 |
}
|
| 282 |
|
| 283 |
# See kernel/README for the architecture-specific functions expected here.
|
| 284 |
if [ -f /usr/lib/base-installer/kernel.sh ]; then
|
| 285 |
. /usr/lib/base-installer/kernel.sh
|
| 286 |
else
|
| 287 |
arch_get_kernel_flavour () {
|
| 288 |
warning "Unknown architecture '$ARCH'."
|
| 289 |
return 0
|
| 290 |
}
|
| 291 |
arch_check_usable_kernel () {
|
| 292 |
warning "Unknown architecture '$ARCH'."
|
| 293 |
return 0
|
| 294 |
}
|
| 295 |
arch_get_kernel () {
|
| 296 |
warning "Unknown architecture '$ARCH'."
|
| 297 |
}
|
| 298 |
fi
|
| 299 |
|
| 300 |
# Test whether a kernel is usable at all. For the purposes of this test, we
|
| 301 |
# assume that SMP is usable on UP and vice versa (is this safe?).
|
| 302 |
# Some architectures just have a hierarchy of optimized kernels, whereas
|
| 303 |
# some have subarchitectures that are incompatible at the kernel level. This
|
| 304 |
# function should cope with both cases.
|
| 305 |
check_usable_kernel () {
|
| 306 |
best_flavour="$(arch_get_kernel_flavour)" || return 1
|
| 307 |
arch_check_usable_kernel "$1" "$best_flavour" || return 1
|
| 308 |
return 0
|
| 309 |
}
|
| 310 |
|
| 311 |
# Returns a kernel that seems appropriate for the machine.
|
| 312 |
get_arch_kernel () {
|
| 313 |
flavour="$(arch_get_kernel_flavour)" || return
|
| 314 |
arch_get_kernel "$flavour"
|
| 315 |
}
|
| 316 |
|
| 317 |
pick_kernel () {
|
| 318 |
# Fetch the current default
|
| 319 |
if db_get debian-installer/kernel/image-$KERNEL_MAJOR && [ "$RET" ]; then
|
| 320 |
KERNEL="$RET"
|
| 321 |
elif db_get debian-installer/kernel/image && [ "$RET" ]; then
|
| 322 |
KERNEL="$RET"
|
| 323 |
fi
|
| 324 |
|
| 325 |
# Using 'sort -r' to get the newest kernel version at the start of the
|
| 326 |
# list (ie 2.4.20 above 2.2.20). This is in conflict with getting the
|
| 327 |
# most generic architecture first (386 above 686).
|
| 328 |
kernel_update_list
|
| 329 |
kernels=`sort -r $KERNEL_LIST| tr '\n' ',' | sed -e 's/,$//'`
|
| 330 |
|
| 331 |
info "Found kernels '$kernels'"
|
| 332 |
|
| 333 |
if [ "$kernels" ] ; then
|
| 334 |
db_subst base-installer/kernel/which-kernel KERNELS "$kernels"
|
| 335 |
else
|
| 336 |
db_subst base-installer/kernel/no-kernels-found KERNEL "$KERNEL"
|
| 337 |
exit_error base-installer/kernel/no-kernels-found
|
| 338 |
fi
|
| 339 |
|
| 340 |
# Try to make current rootskel setting the default, make sure it is
|
| 341 |
# available first.
|
| 342 |
if kernel_present "$KERNEL" ; then
|
| 343 |
# Current selection is available, nothing to do
|
| 344 |
:
|
| 345 |
else
|
| 346 |
# If possible, find one with at least the same major number
|
| 347 |
# as the currently running kernel.
|
| 348 |
KERNEL=$(echo "$kernels" | sed 's/,/\n/g' | grep -- "-$KERNEL_MAJOR" | head -n 1)
|
| 349 |
if [ -z "$KERNEL" ]; then
|
| 350 |
# Take the first on the list.
|
| 351 |
KERNEL=$(echo "$kernels" | cut -d, -f1)
|
| 352 |
fi
|
| 353 |
fi
|
| 354 |
|
| 355 |
arch_kernel=$(get_arch_kernel)
|
| 356 |
if kernel_present $arch_kernel ; then
|
| 357 |
KERNEL=$arch_kernel
|
| 358 |
elif [ "" != "$arch_kernel" ] ; then
|
| 359 |
kernels=`grep $arch_kernel $KERNEL_LIST | sort -r | tr '\n' ',' | sed -e 's/,$//'`
|
| 360 |
if [ "$kernels" ]; then
|
| 361 |
db_subst base-installer/kernel/which-kernel KERNELS "$kernels"
|
| 362 |
|
| 363 |
# Try to default to running kernel version.
|
| 364 |
KVERS=`uname -r | cut -d'-' -f 1`
|
| 365 |
if [ "$KVERS" != "" ]; then
|
| 366 |
kernellist=`grep $arch_kernel $KERNEL_LIST | sort -r | tr '\n' ' '`
|
| 367 |
for akernel in $kernellist; do
|
| 368 |
if [ "" != "`echo $akernel | grep '^kernel-image-'$KVERS`" ]; then
|
| 369 |
KERNEL=$akernel
|
| 370 |
break
|
| 371 |
fi
|
| 372 |
done
|
| 373 |
fi
|
| 374 |
fi
|
| 375 |
fi
|
| 376 |
|
| 377 |
if [ "$KERNEL" ] ; then
|
| 378 |
db_set base-installer/kernel/which-kernel "$KERNEL"
|
| 379 |
fi
|
| 380 |
|
| 381 |
db_input medium base-installer/kernel/which-kernel || [ $? -eq 30 ]
|
| 382 |
db_go || exit 10
|
| 383 |
|
| 384 |
db_get base-installer/kernel/which-kernel
|
| 385 |
KERNEL=$RET
|
| 386 |
|
| 387 |
info "Using kernel '$KERNEL'"
|
| 388 |
|
| 389 |
# Pass the kernel name on
|
| 390 |
db_set debian-installer/kernel/image "$KERNEL"
|
| 391 |
}
|
| 392 |
|
| 393 |
install_kernel () {
|
| 394 |
if db_get "debian-installer/kernel/linux/initrd-$KERNEL_MAJOR" ; then
|
| 395 |
if [ "$RET" = true ]; then
|
| 396 |
do_initrd=yes
|
| 397 |
else
|
| 398 |
do_initrd=no
|
| 399 |
fi
|
| 400 |
elif db_get debian-installer/kernel/linux/initrd ; then
|
| 401 |
if [ "$RET" = "true" ]; then
|
| 402 |
do_initrd=yes
|
| 403 |
else
|
| 404 |
do_initrd=no
|
| 405 |
fi
|
| 406 |
else
|
| 407 |
warning "Failed to get debconf answer 'debian-installer/kernel/linux/initrd'."
|
| 408 |
do_initrd=yes
|
| 409 |
fi
|
| 410 |
|
| 411 |
if db_get debian-installer/kernel/linux/link_in_boot ; then
|
| 412 |
if [ "$RET" = "true" ]; then
|
| 413 |
link_in_boot=yes
|
| 414 |
else
|
| 415 |
link_in_boot=no
|
| 416 |
fi
|
| 417 |
else
|
| 418 |
warning "Failed to get debconf answer 'debian-installer/kernel/linux/link_in_boot'."
|
| 419 |
link_in_boot=no
|
| 420 |
fi
|
| 421 |
|
| 422 |
info "Setting do_initrd='$do_initrd'."
|
| 423 |
info "Setting link_in_boot='$link_in_boot'."
|
| 424 |
|
| 425 |
if [ -f /target/etc/kernel-img.conf ]; then
|
| 426 |
# Backup old kernel-img.conf
|
| 427 |
mv /target/etc/kernel-img.conf /target/etc/kernel-img.conf.$$
|
| 428 |
fi
|
| 429 |
|
| 430 |
cat > /target/etc/kernel-img.conf <<EOF
|
| 431 |
# Do not create symbolic links in /
|
| 432 |
do_symlinks = yes
|
| 433 |
relative_links = yes
|
| 434 |
do_bootloader = no
|
| 435 |
do_bootfloppy = no
|
| 436 |
do_initrd = $do_initrd
|
| 437 |
link_in_boot = $link_in_boot
|
| 438 |
EOF
|
| 439 |
|
| 440 |
if [ yes = "$do_initrd" ] ; then
|
| 441 |
info "Installing initrd-tools."
|
| 442 |
# Make sure initrd-tools is installed before we change its
|
| 443 |
# configuration
|
| 444 |
if ! apt-install initrd-tools 2>> $LOGFILE ; then
|
| 445 |
exit_error base-installer/kernel/failed-initrd-tools-install
|
| 446 |
fi
|
| 447 |
|
| 448 |
rootpart_devfs=$(mount | grep "on /target " | cut -d' ' -f1)
|
| 449 |
rootpartfs=$(mount | grep "on /target " | cut -d' ' -f5)
|
| 450 |
rootpart=$(mapdevfs $rootpart_devfs)
|
| 451 |
|
| 452 |
# Avoid possible root shell without giving passord while
|
| 453 |
# booting the 2.4 kernel
|
| 454 |
# This is here for back-compatability with woody's
|
| 455 |
# initrd-tools; it's fixed in more recent versions
|
| 456 |
mkinitrdconf=/target/etc/mkinitrd/mkinitrd.conf
|
| 457 |
if [ -f $mkinitrdconf ] ; then
|
| 458 |
sed -e 's/^DELAY=.*/DELAY=0/' -e "s#^ROOT=.*/ROOT='$rootpart $rootpartfs'" < $mkinitrdconf > $mkinitrdconf.new &&
|
| 459 |
mv $mkinitrdconf.new $mkinitrdconf
|
| 460 |
else
|
| 461 |
echo 'DELAY=0' >> $mkinitrdconf
|
| 462 |
echo "ROOT='$rootpart $rootpartfs'" >> $mkinitrdconf
|
| 463 |
fi
|
| 464 |
else
|
| 465 |
info "Not installing initrd-tools."
|
| 466 |
fi
|
| 467 |
|
| 468 |
info "Installing kernel '$KERNEL'."
|
| 469 |
apt-install "$KERNEL" 2>> $LOGFILE || kernel_install_failed=$?
|
| 470 |
|
| 471 |
# /proc/filesystems will accomodate this past the second bootup.
|
| 472 |
if [ "$do_initrd" = yes ]; then
|
| 473 |
sed -e 's/^ROOT=.*/ROOT=probe/' $mkinitrdconf > $mkinitrdconf.new && mv $mkinitrdconf.new $mkinitrdconf
|
| 474 |
fi
|
| 475 |
|
| 476 |
if [ -f /target/etc/kernel-img.conf.$$ ]; then
|
| 477 |
# Revert old kernel-img.conf
|
| 478 |
mv /target/etc/kernel-img.conf.$$ /target/etc/kernel-img.conf
|
| 479 |
fi
|
| 480 |
|
| 481 |
if [ "$kernel_install_failed" ]; then
|
| 482 |
db_subst base-installer/kernel/failed-install KERNEL "$KERNEL"
|
| 483 |
exit_error base-installer/kernel/failed-install
|
| 484 |
fi
|
| 485 |
}
|
| 486 |
|
| 487 |
install_pcmcia_modules () {
|
| 488 |
pcmcia_package=$(echo "$KERNEL" | sed 's/^kernel-image/kernel-pcmcia-modules/')
|
| 489 |
info "Installing pcmcia modules package '$pcmcia_package'."
|
| 490 |
apt-install "$pcmcia_package" 2>> $LOGFILE || true
|
| 491 |
}
|
| 492 |
|
| 493 |
apt_update () {
|
| 494 |
chroot /target apt-get update >> $LOGFILE 2>&1 || apt_update_failed=$?
|
| 495 |
|
| 496 |
if [ "$apt_update_failed" ]; then
|
| 497 |
warning "apt update failed: $apt_update_failed"
|
| 498 |
fi
|
| 499 |
}
|
| 500 |
|
| 501 |
install_extra () {
|
| 502 |
info "Installing extra packages into /target/."
|
| 503 |
|
| 504 |
if [ -f /var/lib/apt-install/queue ] ; then
|
| 505 |
# We need to install these one by one in case one fails.
|
| 506 |
for PKG in `cat /var/lib/apt-install/queue`; do
|
| 507 |
if apt-install $PKG >> $LOGFILE 2>&1 ; then
|
| 508 |
info "Installed $PKG successfully into /target/"
|
| 509 |
else
|
| 510 |
warning "Failed to install $PKG into /target/: $?"
|
| 511 |
fi
|
| 512 |
done
|
| 513 |
fi
|
| 514 |
}
|
| 515 |
|
| 516 |
cleanup () {
|
| 517 |
info "Cleaning up"
|
| 518 |
rm -f $KERNEL_LIST
|
| 519 |
}
|
| 520 |
|
| 521 |
WAYPOINTS=""
|
| 522 |
NUM_STEPS=0
|
| 523 |
waypoint () {
|
| 524 |
WAYPOINTS="$WAYPOINTS $1:$2"
|
| 525 |
NUM_STEPS=$(expr $NUM_STEPS + $1) || true
|
| 526 |
}
|
| 527 |
|
| 528 |
waypoint 1 check_target
|
| 529 |
waypoint 1 get_mirror_info
|
| 530 |
waypoint 100 install_base_system
|
| 531 |
waypoint 1 configure_apt
|
| 532 |
waypoint 3 apt_update
|
| 533 |
waypoint 2 create_devices
|
| 534 |
waypoint 1 pick_kernel
|
| 535 |
waypoint 10 install_kernel
|
| 536 |
case "$ARCH" in
|
| 537 |
i386*)
|
| 538 |
if [ -e /proc/bus/pccard/drivers ]; then
|
| 539 |
waypoint 1 install_pcmcia_modules
|
| 540 |
fi
|
| 541 |
;;
|
| 542 |
esac
|
| 543 |
waypoint 5 install_extra
|
| 544 |
waypoint 0 cleanup
|
| 545 |
|
| 546 |
db_progress START 0 $NUM_STEPS base-installer/progress/installing-debian
|
| 547 |
POS=0
|
| 548 |
for item in $WAYPOINTS; do
|
| 549 |
step=$(echo $item | cut -d: -f 1)
|
| 550 |
waypoint=$(echo $item | cut -d: -f 2)
|
| 551 |
# Not all of the section headers need exist.
|
| 552 |
db_progress INFO "base-installer/section/$waypoint" || true
|
| 553 |
eval $waypoint
|
| 554 |
POS=$(expr $POS + $step) || true
|
| 555 |
db_progress SET $POS
|
| 556 |
done
|
| 557 |
db_progress STOP
|
| 558 |
exit 0
|