1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#!/bin/sh
# This code is covered by the GNU General Public License (GPLv2 or higher)
set -e
FK_DIR="/usr/share/flash-kernel"
. "${FK_CHECKOUT:-$FK_DIR}/functions"
. /usr/share/debconf/confmodule
log() {
logger -t flash-kernel-installer "$@"
}
error() {
log "error: $@"
db_progress STOP
exit 1
}
findfs () {
mount | grep "on /target${1%/} " | tail -n1 | cut -d' ' -f1
}
tac () {
sed '1!G;h;$!d'
}
get_machine
if machine_uses_flash "$machine"; then
db_progress START 0 3 flash-kernel-installer/progress
else
db_progress START 0 3 flash-kernel-installer/progress_disk
fi
db_progress INFO flash-kernel-installer/prepare
# Stop fsck from prompting the user for input since most users don't
# have a serial console.
if [ -e /target/etc/default/rcS ]; then
sed -i -e "s/^FSCKFIX=no$/FSCKFIX=yes/" /target/etc/default/rcS || true
fi
if [ -e /target/etc/default/fsck ]; then
sed -i -e "s/^#FSCKFIX=no$/FSCKFIX=yes/" -e "s/^FSCKFIX=no$/FSCKFIX=yes/" /target/etc/default/fsck || true
fi
def_params="@DEFAULT_CMDLINE@"
# reverse them so we prefix them in the right order
rev_def_params="$(echo $def_params | tr ' ' '\n' | tac)"
user_params=$(user-params) || true
kopt_params="$user_params"
for d_param in $rev_def_params; do
# Don't add redundant default params
if echo $kopt_params | tr ' ' '\n' | grep -q "^${d_param}$"; then
continue
else
kopt_params="$d_param${kopt_params:+ $kopt_params}"
fi
done
echo flash-kernel flash-kernel/linux_cmdline string $kopt_params | \
chroot /target debconf-set-selections
if ! apt-install flash-kernel; then
error "apt-install flash-kernel failed"
fi
# Temporarily move flash-kernel out of the way so update-initramfs
# won't call flash-kernel; otherwise we might call it twice.
mv /target/usr/sbin/flash-kernel /target/tmp/flash-kernel.$$
trap "mv /target/tmp/flash-kernel.$$ /target/usr/sbin/flash-kernel" EXIT HUP INT QUIT TERM
db_progress STEP 1
for package in $(get_machine_field "$machine" "Optional-Packages"); do
if ! apt-install "$package"; then
log "apt-install $package failed"
fi
done
for package in $(get_machine_field "$machine" "Required-Packages"); do
if ! apt-install "$package"; then
error "apt-install $package failed"
fi
done
case "$machine" in
"Linksys NSLU2")
# installing nslu2-utils will call update-initramfs -u
:
;;
*)
in-target update-initramfs -u || true
;;
esac
if [ "$machine" = "HP Media Vault mv2120" ]; then
# The firmware loads /boot/uImage from the first partition
# but uImage will be in / if a separate boot partition is
# used. In this case, create a /boot/boot -> /boot symlink.
# Note that a partman check will make sure that /boot (if
# it exists) or / (if there's no separate /boot) are on the
# first partition.
rootfs=$(findfs /)
bootfs=$(findfs /boot)
if [ "$rootfs" != "$bootfs" ]; then
if [ ! -e /target/boot/boot ]; then
ln -s . /target/boot/boot
fi
fi
fi
db_progress STEP 1
if machine_uses_flash "$machine"; then
db_progress INFO flash-kernel-installer/flashing
else
db_progress INFO flash-kernel-installer/generating_image
fi
trap - EXIT HUP INT QUIT TERM
mv /target/tmp/flash-kernel.$$ /target/usr/sbin/flash-kernel
# We need the udev /dev which has the MTD devices
mount -o bind /dev /target/dev
if ! in-target flash-kernel; then
umount /target/dev || true
error "flash-kernel failed"
fi
umount /target/dev || true
db_progress STEP 1
db_progress STOP
# vim:noexpandtab shiftwidth=8
|