File: flash-kernel-installer.postinst

package info (click to toggle)
flash-kernel 2.13
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 352 kB
  • ctags: 19
  • sloc: sh: 531; makefile: 41
file content (149 lines) | stat: -rwxr-xr-x 3,925 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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/sh

# This code is covered by the GNU General Public License (GPLv2 or higher)

set -e

. /usr/share/debconf/confmodule

log() {
	logger -t flash-kernel-installer "$@"
}

error() {
	log "error: $@"
	db_progress STOP
	exit 1
}

findfs () {
	mount | grep "on /target${1%/} " | cut -d' ' -f1
}

# Are we writing to flash or constructing an image on disk?
write_to_flash() {
	case "$machine" in
		"Buffalo Linkstation Pro/Live" | "Buffalo/Revogear Kurobox Pro" | "GLAN Tank" | "HP Media Vault mv2120")
			return 1
		;;
		*)
			return 0
		;;
	esac
}

machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//')

if write_to_flash; 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

# Set up flash-kernel to run on kernel upgrades.
if ! grep -q flash-kernel /target/etc/kernel-img.conf; then
	echo "postinst_hook = flash-kernel" >> \
		/target/etc/kernel-img.conf
fi

# Temporarily move flash-kernel out of the way so update-initramfs
# won't call flash-kernel; otherwise we'd call it twice.
mv /target/usr/sbin/flash-kernel /target/tmp/flash-kernel.$$

db_progress STEP 1

case "$machine" in
	"Buffalo Linkstation Pro/Live" | "Buffalo/Revogear Kurobox Pro")
		in-target update-initramfs -u || true
		if ! apt-install uboot-mkimage; then
			error "apt-install uboot-mkimage failed"
		fi
	;;
	"D-Link DNS-323")
		in-target update-initramfs -u || true
		if ! apt-install uboot-mkimage; then
			error "apt-install uboot-mkimage failed"
		fi
	;;
	"GLAN Tank")
		in-target update-initramfs -u || true
	;;
	"HP Media Vault mv2120")
		if ! apt-install mv2120-utils; then
			# mv2120-utils includes some initramfs-tools scripts
			# that would be nice to have but which are not
			# essential.
			log "apt-install mv2120-utils failed"
		fi
		in-target update-initramfs -u || true
		if ! apt-install uboot-mkimage; then
			error "apt-install uboot-mkimage failed"
		fi
		# 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
	;;
	"Linksys NSLU2")
		if ! apt-install ixp4xx-firmware; then
			# not fatal, firmware can be provided other ways
			# and is not always needed
			log "apt-install ixp4xx-firmware failed"
		fi
		# nslu2-utils will call update-initramfs -u to include the
		# firmware and to run the hook from flash-kernel
		if ! apt-install nslu2-utils; then
			error "apt-install nslu2-utils failed"
		fi
		if ! apt-install apex-nslu2; then
			error "apt-install apex-nslu2 failed"
		fi
	;;
	"Thecus N2100" | "Thecus N4100")
		in-target update-initramfs -u || true
	;;
	"QNAP TS-109/TS-209" | "QNAP TS-409")
		in-target update-initramfs -u || true
		if ! apt-install uboot-mkimage; then
			error "apt-install uboot-mkimage failed"
		fi
	;;
esac

db_progress STEP 1
if write_to_flash; then
	db_progress INFO flash-kernel-installer/flashing
else
	db_progress INFO flash-kernel-installer/generating_image
fi

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