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,
27
#exit 1 # won't work; initramfs-tools ignores hook script exit code
29
if [ "$DEBIAN_FRONTEND" = "noninteractive" ] ; then
30
echo "Unable to abort; system will probably be broken!" >&2
32
echo "Press Ctrl-C to abort build, or Enter to continue" >&2
44
FK_DIR="/usr/share/flash-kernel"
46
. "${FK_CHECKOUT:-$FK_DIR}/functions"
48
. /usr/share/initramfs-tools/hook-functions
50
machine="$(get_cpuinfo_hardware)"
52
# Should we override the root device or merely provide a default root
54
blsr="$(get_machine_field "$machine" "Bootloader-sets-root")"
56
if [ "$blsr" = "yes" ] || [ -n "$FLASH_KERNEL_SKIP" ]; then
60
# Do not run inside an LXC container
61
if systemd-detect-virt --quiet --container; then
65
# Record the root filesystem device for use during boot
66
rootdev=$(egrep '^[^# ]+[ ]+/[ ]' /etc/fstab | awk '{print $1}') || true
68
# Map LVM devices in the form of /dev/vg/lv to /dev/mapper/..., otherwise
69
# initramfs won't initialize them.
70
if [ -n "$rootdev" ]; then
71
path=$(readlink -f $rootdev)
72
if echo "$path" | grep -q "^/dev/mapper/"; then
77
# Translate LABEL and UUID entries into a proper device name.
78
if echo "$rootdev" | grep -q "="; then
79
a=$(echo "$rootdev" | cut -d "=" -f 1)
80
b=$(echo "$rootdev" | cut -d "=" -f 2- | sed -e 's/^"\(.*\)"$/\1/')
83
c=$(echo "$b" | sed 's#/#\\x2f#g')
84
if [ -e /dev/disk/by-label/$c ]; then
85
rootdev="/dev/disk/by-label/$c"
87
echo "Label $b not found in /dev/disk/by-label" >&2
91
rootdev=/dev/disk/by-uuid/$b
92
if [ ! -e $rootdev ]; then
93
echo "UUID $b doesn't exist in /dev/disk/by-uuid" >&2
97
echo "/etc/fstab parse error; cannot recognize root $rootdev" >&2
99
echo "guessing that the root device is $rootdev" >&2
104
if [ ! -e "$rootdev" ]; then
105
echo "Warning: root device $rootdev does not exist" >&2
109
# The boot loader doesn't pass root= on the command line, so
111
install -d $DESTDIR/conf/conf.d
112
echo "ROOT=\"$rootdev\"" > $DESTDIR/conf/conf.d/default_root
114
# vim:noexpandtab shiftwidth=8