3
# This code is covered by the GNU General Public License (GPLv2 or higher)
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
12
27
#exit 1 # won't work; initramfs-tools ignores hook script exit code
14
29
if [ "$DEBIAN_FRONTEND" = "noninteractive" ] ; then
15
30
echo "Unable to abort; system will probably be broken!" >&2
17
32
echo "Press Ctrl-C to abort build, or Enter to continue" >&2
22
# Should we override the root device or merely provide a default root
26
"Buffalo Linkstation Pro/Live")
29
"Buffalo/Revogear Kurobox Pro")
38
"HP Media Vault mv2120")
56
"Marvell OpenRD Base Board")
59
"Marvell OpenRD Client Board")
62
"Marvell SheevaPlug Reference Board")
65
"Marvell eSATA SheevaPlug Reference Board")
44
FK_DIR="/usr/share/flash-kernel"
46
. "${FK_CHECKOUT:-$FK_DIR}/functions"
87
48
. /usr/share/initramfs-tools/hook-functions
89
# Only run this hook on some machines
90
machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//')
91
if [ -z "$(root_type "$machine")" ]; then
95
50
# Record the root filesystem device for use during boot
96
51
rootdev=$(egrep '^[^# ]+[ ]+/[ ]' /etc/fstab | awk '{print $1}') || true
98
53
# Map LVM devices in the form of /dev/vg/lv to /dev/mapper/..., otherwise
99
54
# initramfs won't initialize them.
100
path=$(readlink -f $rootdev)
101
if echo "$path" | grep -q "^/dev/mapper/"; then
55
if [ -n "$rootdev" ]; then
56
path=$(readlink -f $rootdev)
57
if echo "$path" | grep -q "^/dev/mapper/"; then
105
62
# Translate LABEL and UUID entries into a proper device name.
125
82
echo "/etc/fstab parse error; cannot recognize root $rootdev" >&2
84
echo "guessing that the root device is $rootdev" >&2
130
89
if [ ! -e "$rootdev" ]; then
132
echo "Warning: /etc/fstab parse error; guessing that the root device is $rootdev" >&2
90
echo "Warning: root device $rootdev does not exist" >&2
135
case "$(root_type "$machine")" in
94
machine="$(get_cpuinfo_hardware)"
96
# Should we override the root device or merely provide a default root
98
blsr="$(get_machine_field "$machine" "Bootloader-sets-root")"
100
if [ "$blsr" = "no" ]; then
136
101
# The boot loader doesn't pass root= on the command line, so
137
102
# provide a default.
139
install -d $DESTDIR/conf/conf.d
140
echo "ROOT=\"$rootdev\"" > $DESTDIR/conf/conf.d/default_root
103
install -d $DESTDIR/conf/conf.d
104
echo "ROOT=\"$rootdev\"" > $DESTDIR/conf/conf.d/default_root
142
106
# The boot loader passes a bogus root= (e.g. root=/dev/ram), so
143
107
# override the command line parameter.
145
install -d $DESTDIR/conf
146
echo "ROOT=\"$rootdev\"" >> $DESTDIR/conf/param.conf
148
# This shouldn't happen - only if a device from the case statement
149
# above wasn't added here.
151
echo "Device $machine not supported. Please file a bug." >&2
108
install -d $DESTDIR/conf
109
echo "ROOT=\"$rootdev\"" >> $DESTDIR/conf/param.conf
112
# vim:noexpandtab shiftwidth=8