File: flash-kernel-installer.postinst

package info (click to toggle)
flash-kernel 3.3%2Bdeb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 500 kB
  • sloc: sh: 577; makefile: 6
file content (109 lines) | stat: -rwxr-xr-x 2,697 bytes parent folder | download
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
#!/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
}

machine="$(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.
sed -i "s/^FSCKFIX=no$/FSCKFIX=yes/" /target/etc/default/rcS || true

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