Debian Codegraph @

initramfs-tools/hooks/flash_kernel_set_root

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
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.
7 #
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.
12 #
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,
16 # USA.
17
18 PREREQ=""
19
20 prereqsscip-shell shell flash-kernel 3.110 prereqs().() {
21 echoscip-shell system . . echo. "$PREREQ"
22 }
23
24 pause_errorscip-shell shell flash-kernel 3.110 pause_error().() {
25 local _ignored
26
27 #exit 1 # won't work; initramfs-tools ignores hook script exit code
28 echoscip-shell system . . echo. "" >&2
29
30 # Script is called from update-initramfs which in turn can be
31 # called manually by the admin from the CLI or via various
32 # postinst and trigger hooks or from the installer.
33 #
34 # If debconf appears to be running then it is important that
35 # we do not block on stdin since this would hang the
36 # installer.
37 if [scip-shell system . . `[`. "$DEBIAN_HAS_FRONTEND" ] || [scip-shell system . . `[`. "$DEBIAN_FRONTEND" ]; then
38 echoscip-shell system . . echo. "Unable to abort; system will probably be broken!" >&2
39 else
40 echoscip-shell system . . echo. "Press Ctrl-C to abort build, or Enter to continue" >&2
41 read _ignored
42 fi
43 }
44
45 case $1 in
46 prereqs)
47 prereqsscip-shell shell flash-kernel 3.110 prereqs().
48 exit 0
49 ;;
50 esac
51
52 FK_DIR="/usr/share/flash-kernelscip-shell filesystem . . `/usr/share/flash-kernel`."
53
54 . "${FK_CHECKOUT:-$FK_DIR}/functions"
55
56 . /usr/share/initramfs-tools/hook-functionsscip-shell source . . `/usr/share/initramfs-tools/hook-functions`.
57
58 # Record the root filesystem device for use during boot
59 rootdev=$(egrepscip-shell system . . egrep. '^[^# ]+[ ]+/[ ]' /etc/fstabscip-shell filesystem . . `/etc/fstab`. | awkscip-shell system . . awk. '{print $1}') || truescip-shell system . . true.
60
61 # Map LVM devices in the form of /dev/vg/lv to /dev/mapper/..., otherwise
62 # initramfs won't initialize them.
63 if [scip-shell system . . `[`. -n "$rootdev" ]; then
64 path=$(readlinkscip-shell system . . readlink. -f $rootdev)
65 if echoscip-shell system . . echo. "$path" | grepscip-shell system . . grep. -q "^/dev/mapper/"; then
66 rootdev=$path
67 fi
68 fi
69
70 # Translate LABEL, UUID, and PARTUUID entries into a proper device name.
71 if echoscip-shell system . . echo. "$rootdev" | grepscip-shell system . . grep. -q "="; then
72 a=$(echoscip-shell system . . echo. "$rootdev" | cutscip-shell system . . cut. -d "=" -f 1)
73 b=$(echoscip-shell system . . echo. "$rootdev" | cutscip-shell system . . cut. -d "=" -f 2- | sedscip-shell system . . sed. -e 's/^"\(.*\)"$/\1/')
74 case "$a" in
75 LABEL)
76 c=$(echoscip-shell system . . echo. "$b" | sedscip-shell system . . sed. 's#/#\\x2f#g')
77 if [scip-shell system . . `[`. -e /dev/disk/by-label/$c ]; then
78 rootdev="/dev/disk/by-label/$c"
79 else
80 echoscip-shell system . . echo. "Label $b not found in /dev/disk/by-label" >&2
81 fi
82 ;;
83 UUID)
84 rootdev=/dev/disk/by-uuid/$b
85 if [scip-shell system . . `[`. ! -e $rootdev ]; then
86 echoscip-shell system . . echo. "UUID $b doesn't exist in /dev/disk/by-uuid" >&2
87 fi
88 ;;
89 PARTUUID)
90 rootdev=/dev/disk/by-partuuid/$b
91 if [scip-shell system . . `[`. ! -e $rootdev ]; then
92 echoscip-shell system . . echo. "PARTUUID $b doesn't exist in /dev/disk/by-partuuid" >&2
93 fi
94 ;;
95 PARTLABEL)
96 rootdev=/dev/disk/by-partlabel/$b
97 if [scip-shell system . . `[`. ! -e $rootdev ]; then
98 echoscip-shell system . . echo. "PARTLABEL $b doesn't exist in /dev/disk/by-partlabel" >&2
99 fi
100 ;;
101 *)
102 echoscip-shell system . . echo. "/etc/fstab parse error; cannot recognize root $rootdev" >&2
103 rootdev=/dev/sda2scip-shell filesystem . . `/dev/sda2`.
104 echoscip-shell system . . echo. "guessing that the root device is $rootdev" >&2
105 ;;
106 esac
107 fi
108
109 # Most mount options don't matter for the initial boot, but some are
110 # vital, make sure we preserve them
111 rootfstype=$(egrepscip-shell system . . egrep. '^[^# ]+[ ]+/[ ]' /etc/fstabscip-shell filesystem . . `/etc/fstab`. | awkscip-shell system . . awk. '{print $3}') || truescip-shell system . . true.
112 rootmntopts=$(egrepscip-shell system . . egrep. '^[^# ]+[ ]+/[ ]' /etc/fstabscip-shell filesystem . . `/etc/fstab`. | awkscip-shell system . . awk. '{print $4}') || truescip-shell system . . true.
113
114 case "$rootfstype" in
115 "btrfs")
116 rootflags="$rootflags$(exprscip-shell system . . expr. ",${rootmntopts}," : '.*,\(subvol=[^,]*,\)')"
117 rootflags="$rootflags$(exprscip-shell system . . expr. ",${rootmntopts}," : '.*,\(degraded,\)')"
118 rootflags="${rootflags%,}" # Remove possible trailing ,
119 ;;
120 esac
121
122 get_machine
123
124 # Should we override the root device or merely provide a default root
125 # device?
126 blsir="$(get_machine_field "$machine" "Bootloader-Sets-Incorrect-Root")"
127 if [scip-shell system . . `[`. -z "$blsir" ] ; then
128 blsir="$(get_machine_field "$machine" "Bootloader-Sets-Root")"
129 if [scip-shell system . . `[`. -n "$blsir" ] ; then
130 echoscip-shell system . . echo. "WARNING: flash-kernel configuration contains deprecated" >&2
131 echoscip-shell system . . echo. "WARNING: \"Bootloader-Sets-Root\" option please update to" >&2
132 echoscip-shell system . . echo. "WARNING: use \"Bootloader-Sets-Incorrect-Root\" instead." >&2
133 fi
134 fi
135
136 if [scip-shell system . . `[`. ! -e "$rootdev" ]; then
137 echoscip-shell system . . echo. "Warning: root device $rootdev does not exist" >&2
138 if [scip-shell system . . `[`. "$blsir" = "yes" ]; then
139 pause_errorscip-shell shell flash-kernel 3.110 pause_error().
140 fi
141 fi
142
143 if [scip-shell system . . `[`. "$blsir" = "yes" ]; then
144 # The boot loader passes a bogus root= (e.g. root=/dev/ram), so
145 # override the command line parameter.
146 installscip-shell system . . install. -d $DESTDIR/conf
147 echoscip-shell system . . echo. "ROOT=\"$rootdev\"" >> $DESTDIR/conf/param.conf
148 if [scip-shell system . . `[`. -n "${rootflags}" ]; then
149 echoscip-shell system . . echo. "ROOTFLAGS=\"-o ${rootflags}\"" >> $DESTDIR/conf/param.conf
150 fi
151 else
152 # The boot loader may or may not pass root= on the command line, so
153 # provide a default.
154 installscip-shell system . . install. -d $DESTDIR/conf/conf.d
155 echoscip-shell system . . echo. "ROOT=\"$rootdev\"" > $DESTDIR/conf/conf.d/default_root
156 if [scip-shell system . . `[`. -n "${rootflags}" ]; then
157 echoscip-shell system . . echo. "ROOTFLAGS=\"-o ${rootflags}\"" >> $DESTDIR/conf/conf.d/default_root
158 fi
159 fi
160
161 # vim:noexpandtab shiftwidth=8