7
by Colin Watson
* Resynchronise with Debian. |
1 |
#! /bin/sh
|
2 |
||
3 |
set -e
|
|
4 |
. /usr/share/debconf/confmodule |
|
5 |
#set -x
|
|
6 |
||
7 |
if [ "$1" ]; then |
|
8 |
ROOT="$1" |
|
9 |
chroot=chroot |
|
10 |
else
|
|
11 |
ROOT= |
|
12 |
chroot= |
|
13 |
fi
|
|
14 |
||
15 |
. /usr/share/grub-installer/functions.sh |
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
16 |
. /usr/share/grub-installer/otheros.sh |
7
by Colin Watson
* Resynchronise with Debian. |
17 |
|
18 |
newline=" |
|
19 |
"
|
|
20 |
||
21 |
db_capb backup |
|
22 |
||
23 |
log() { |
|
24 |
logger -t grub-installer "$@" |
|
25 |
}
|
|
26 |
||
27 |
error() { |
|
28 |
log "error: $@" |
|
29 |
}
|
|
30 |
||
31 |
info() { |
|
32 |
log "info: $@" |
|
33 |
}
|
|
34 |
||
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
35 |
ARCH="$(archdetect)" |
36 |
info "architecture: $ARCH" |
|
37 |
||
7
by Colin Watson
* Resynchronise with Debian. |
38 |
get_serial_console() { |
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
39 |
# Get the last 'console=' entry (if none, the whole string is returned)
|
40 |
local defconsole="$(sed -e 's/.*\(console=[^ ]*\).*/\1/' /proc/cmdline)" |
|
0.2.17
by Christian Perrier, Samuel Thibault, Updated translations
* Team Upload |
41 |
if echo "$defconsole" | grep -qe 'console=\(ttyS\|com\)'; then |
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
42 |
echo "$defconsole" |
7
by Colin Watson
* Resynchronise with Debian. |
43 |
fi
|
44 |
}
|
|
45 |
||
19
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
46 |
grub_serial_console() { |
47 |
#$1=output of get_serial_console
|
|
0.2.17
by Christian Perrier, Samuel Thibault, Updated translations
* Team Upload |
48 |
local serconsole=${1##console=ttyS} |
49 |
serconsole=${serconsole##console=com} |
|
50 |
local unit=${serconsole%%,*} |
|
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
51 |
local options="" |
52 |
if echo $serconsole | grep -q ","; then |
|
53 |
options=${serconsole##*,} |
|
54 |
fi
|
|
55 |
local speed=$(echo "$options" | sed -e 's/^\([0-9]*\).*$/\1/') |
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
56 |
# Take optional 1st (parity) and 2nd (word) characters after speed
|
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
57 |
options=${options##${speed}} |
58 |
local parity=$(echo $options | sed 's/^\(.\?\).*$/\1/') |
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
59 |
local word=$(echo $options | sed 's/^.\?\(.\?\).*$/\1/') |
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
60 |
if [ -z "$speed" ]; then |
61 |
speed="9600" |
|
62 |
fi
|
|
19
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
63 |
case "$parity" in |
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
64 |
n) parity="--parity=no" ;; |
65 |
e) parity="--parity=even" ;; |
|
66 |
o) parity="--parity=odd" ;; |
|
67 |
*) parity="" ;; |
|
19
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
68 |
esac
|
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
69 |
if [ "$word" ]; then |
70 |
word="--word=$word" |
|
71 |
fi
|
|
19
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
72 |
|
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
73 |
echo serial --unit=$unit --speed=$speed $word $parity --stop=1 |
74 |
}
|
|
19
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
75 |
|
7
by Colin Watson
* Resynchronise with Debian. |
76 |
serial="$(get_serial_console)" |
77 |
||
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
78 |
grub_probe () { |
79 |
if [ "$is_grub_common_installed" != true ]; then |
|
80 |
apt-install grub-common |
|
81 |
is_grub_common_installed=true |
|
82 |
fi
|
|
83 |
$chroot $ROOT grub-probe $@ |
|
84 |
}
|
|
85 |
||
7
by Colin Watson
* Resynchronise with Debian. |
86 |
device_map=$ROOT/boot/grub/device.map |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
87 |
|
7
by Colin Watson
* Resynchronise with Debian. |
88 |
# Usage: convert os_device
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
89 |
# Convert an OS device to the corresponding GRUB drive
|
7
by Colin Watson
* Resynchronise with Debian. |
90 |
convert () { |
37
by Luke Yelavich
grub-installer: Properly make use of output from os-prober to configure |
91 |
# Adjust the device map to add a SATA RAID array.
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
92 |
if [ "$grub_version" = grub ] && [ "$frtype" = "sataraid" ] && type dmraid >/dev/null 2>&1; then |
63
by Colin Watson
* Fix some hardcoded uses of /target. |
93 |
temp_map=$ROOT/tmp/sataraid.map |
94 |
echo quit | $chroot $ROOT /usr/sbin/grub --batch --device-map=/tmp/sataraid.map >/dev/null 2>&1 |
|
37
by Luke Yelavich
grub-installer: Properly make use of output from os-prober to configure |
95 |
|
96 |
# Dmraid -r seems to list disks in reverse order to how they
|
|
97 |
# are detected by the kernel.
|
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
98 |
satadisk=$(dmraid -r | grep $(basename "$frdev") | cut -f 1 -d : | tail -1) |
99 |
sed -i "s@$satadisk@$frdev@" $temp_map |
|
37
by Luke Yelavich
grub-installer: Properly make use of output from os-prober to configure |
100 |
|
101 |
# Remove member disks of the SATA RAID array from the device map.
|
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
102 |
for sdisk in $(dmraid -r | grep $(basename "$frdev") | cut -f 1 -d : | grep -v "$satadisk"); do |
37
by Luke Yelavich
grub-installer: Properly make use of output from os-prober to configure |
103 |
cat $temp_map | grep -v "$sdisk" > $temp_map.new |
104 |
mv $temp_map.new $temp_map |
|
105 |
done
|
|
106 |
mv $temp_map $device_map |
|
107 |
fi
|
|
108 |
||
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
109 |
tmp_drive="$(grub_probe -d -t drive "$1")" || exit $? |
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
110 |
if [ "$partition_offset" != 0 ]; then |
111 |
tmp_part="$(echo "$tmp_drive" | sed 's%.*,\([0-9]*\)).*%\1%')" |
|
112 |
if [ "$tmp_part" ] && [ "$tmp_part" != "$tmp_drive" ]; then |
|
75
by Colin Watson
Fix partition offset handling for GRUB Legacy. |
113 |
tmp_drive="$(echo "$tmp_drive" | sed "s%\(.*,\)[0-9]*\().*\)%\1`expr $tmp_part - $partition_offset`\2%")" |
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
114 |
fi
|
115 |
fi
|
|
116 |
echo "$tmp_drive" |
|
7
by Colin Watson
* Resynchronise with Debian. |
117 |
}
|
118 |
||
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
119 |
# Convert a linux non-devfs disk device name into the hurd's syntax
|
7
by Colin Watson
* Resynchronise with Debian. |
120 |
hurd_convert () { |
121 |
dr_type=$(expr "$1" : '.*\([hs]d\)[a-h][0-9]*') |
|
122 |
dr_letter=$(expr "$1" : '.*d\([a-h]\)[0-9]*') |
|
123 |
dr_part=$(expr "$1" : '.*d[a-h]\([0-9]*\)') |
|
124 |
case "$dr_letter" in |
|
125 |
a) dr_num=0 ;; |
|
126 |
b) dr_num=1 ;; |
|
127 |
c) dr_num=2 ;; |
|
128 |
d) dr_num=3 ;; |
|
129 |
e) dr_num=4 ;; |
|
130 |
f) dr_num=5 ;; |
|
131 |
g) dr_num=6 ;; |
|
132 |
h) dr_num=7 ;; |
|
133 |
esac
|
|
134 |
echo "$dr_type${dr_num}s$dr_part" |
|
135 |
}
|
|
136 |
||
0.2.11
by Colin Watson, Updated translations
* Merge changes from Ubuntu by Evan Dandrea and myself: |
137 |
# This should probably be rewritten using udevadm or similar.
|
138 |
device_to_disk () { |
|
139 |
echo "$1" | \ |
|
0.2.15
by Otavio Salvador, Jeremie Koenig, Christian Perrier, Colin Watson, Otavio Salvador, Updated translations
[ Jeremie Koenig ] |
140 |
sed 's:\(/dev/\(cciss\|ida\|rs\)/c[0-9]d[0-9][0-9]*\|/dev/mmcblk[0-9]\|/dev/\(ad\|da\)[0-9]\+\|/dev/[hs]d[0-9]\+\|/dev/[a-z]\+\).*:\1:'
|
0.2.11
by Colin Watson, Updated translations
* Merge changes from Ubuntu by Evan Dandrea and myself: |
141 |
}
|
142 |
||
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
143 |
# Run update-grub in $ROOT
|
7
by Colin Watson
* Resynchronise with Debian. |
144 |
update_grub () { |
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
145 |
local in_target
|
146 |
if [ "$ROOT" = /target ]; then |
|
147 |
in_target='in-target' |
|
148 |
else
|
|
149 |
in_target="log-output -t grub-installer $chroot $ROOT" |
|
150 |
fi
|
|
151 |
if ! $in_target $update_grub; then |
|
0.1.4
by Colin Watson, Colin Watson, Frans Pop, Updated translations
[ Colin Watson ] |
152 |
error "Running '$update_grub' failed." 1>&2 |
7
by Colin Watson
* Resynchronise with Debian. |
153 |
db_input critical grub-installer/update-grub-failed || [ $? -eq 30 ] |
154 |
db_go || true |
|
155 |
db_progress STOP |
|
156 |
exit 1 |
|
157 |
fi
|
|
158 |
}
|
|
159 |
||
23
by Colin Watson
Mark the partition to which GRUB is being installed as bootable, or |
160 |
findfs () { |
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
161 |
if ! grub_probe -t device $1; then |
162 |
mount | grep "on $ROOT${1%/} " | tail -n1 | cut -d' ' -f1 |
|
163 |
fi
|
|
23
by Colin Watson
Mark the partition to which GRUB is being installed as bootable, or |
164 |
}
|
165 |
||
7
by Colin Watson
* Resynchronise with Debian. |
166 |
findfstype () { |
0.2.15
by Otavio Salvador, Jeremie Koenig, Christian Perrier, Colin Watson, Otavio Salvador, Updated translations
[ Jeremie Koenig ] |
167 |
case "$(udpkg --print-os)" in |
168 |
hurd)
|
|
169 |
fsysopts "$ROOT$1" | sed 's:^/hurd/\([^ ]*\)fs .*:\1:' ;; |
|
170 |
*)
|
|
171 |
mount | grep "on $ROOT${1%/} " | tail -n1 | cut -d' ' -f5 ;; |
|
172 |
esac
|
|
7
by Colin Watson
* Resynchronise with Debian. |
173 |
}
|
174 |
||
175 |
is_removable () { |
|
176 |
removabledevice="$(mount | grep "on $ROOT${1%/} " | cut -d' ' -f1)" |
|
15
by Colin Watson
* Return early from is_removable if the argument isn't a mount point |
177 |
if [ -z "$removabledevice" ]; then |
178 |
return
|
|
179 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
180 |
# check if the device we got is a symlink. That might happen in future
|
181 |
# if we implement probe-for-root-fs
|
|
182 |
if [ -L "$removabledevice" ]; then |
|
183 |
removabledevice="$(readlink -f $removabledevice)" |
|
184 |
fi
|
|
185 |
# copy from convert(). We can't use the entire stuff yet. We can clean it later on.
|
|
29
by Soren Hansen
Teach grub-installer about virtio devices (/dev/vd*). |
186 |
removabledevice="$(echo "$removabledevice" | sed -e 's%\([vsh]d[a-z]\)[0-9]*$%\1%' -e 's%\(fd[0-9]*\)$%\1%' -e 's%/part[0-9]*$%/disc%' -e 's%\(c[0-7]d[0-9]*\).*$%\1%' -e 's%^/dev/%%g')" |
7
by Colin Watson
* Resynchronise with Debian. |
187 |
if [ -e "/sys/block/$removabledevice/removable" ]; then |
188 |
if [ "$(cat /sys/block/$removabledevice/removable)" != "0" ]; then |
|
189 |
echo "/dev/$removabledevice" |
|
190 |
return
|
|
191 |
fi
|
|
192 |
fi
|
|
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
193 |
if [ -z "$removabledevice" ]; then |
194 |
return
|
|
195 |
fi
|
|
27
by Evan Dandrea, Colin Watson, Evan Dandrea
[ Colin Watson ] |
196 |
if type udevadm >/dev/null 2>&1; then |
197 |
bus="$(udevadm info -q env -n $removabledevice)" |
|
198 |
else
|
|
199 |
bus="$(udevinfo -q env -n $removabledevice)" |
|
200 |
fi
|
|
201 |
bus="$(echo "$bus" | grep ^ID_BUS= | sed 's/^ID_BUS=//')" |
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
202 |
case $bus in |
203 |
usb|ieee1394) |
|
9
by Tollef Fog Heen
* Fix support for putting / on a removable device |
204 |
echo "/dev/$removabledevice" |
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
205 |
;;
|
206 |
esac
|
|
7
by Colin Watson
* Resynchronise with Debian. |
207 |
}
|
208 |
||
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
209 |
# by-id mapping copied from grub-pc.postinst.
|
210 |
||
211 |
cached_available_ids= |
|
212 |
available_ids()
|
|
213 |
{
|
|
214 |
local id path
|
|
215 |
||
216 |
if [ "$cached_available_ids" ]; then |
|
217 |
echo "$cached_available_ids" |
|
218 |
return
|
|
219 |
fi
|
|
220 |
||
221 |
[ -d /dev/disk/by-id ] || return |
|
222 |
cached_available_ids="$( |
|
223 |
for path in /dev/disk/by-id/*; do |
|
224 |
[ -e "$path" ] || continue |
|
225 |
printf '%s %s\n' "$path" "$(readlink -f "$path")" |
|
226 |
done | sort -k2 -s -u | cut -d' ' -f1 |
|
227 |
)" |
|
228 |
echo "$cached_available_ids" |
|
229 |
}
|
|
230 |
||
231 |
# Returns non-zero and no output if no mapping can be found.
|
|
232 |
device_to_id()
|
|
233 |
{
|
|
234 |
local id
|
|
235 |
for id in $(available_ids); do |
|
236 |
if [ "$(readlink -f "$id")" = "$(readlink -f "$1")" ]; then |
|
237 |
echo "$id" |
|
238 |
return 0 |
|
239 |
fi
|
|
240 |
done
|
|
0.2.5
by Colin Watson, Updated translations
* Merge from Ubuntu: |
241 |
# Fall back to the plain device name if there's no by-id link for it.
|
242 |
if [ -e "$1" ]; then |
|
243 |
echo "$1" |
|
244 |
return 0 |
|
245 |
fi
|
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
246 |
return 1 |
247 |
}
|
|
248 |
||
249 |
devices_to_ids()
|
|
250 |
{
|
|
251 |
local device id ids
|
|
252 |
ids= |
|
253 |
for device; do |
|
254 |
id="$(device_to_id "$device" || true)" |
|
255 |
if [ "$id" ]; then |
|
256 |
ids="${ids:+$ids, }$id" |
|
257 |
fi
|
|
258 |
done
|
|
259 |
echo "$ids" |
|
260 |
}
|
|
261 |
||
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
262 |
rootfs=$(findfs /) |
263 |
bootfs=$(findfs /boot) |
|
7
by Colin Watson
* Resynchronise with Debian. |
264 |
bootfstype=$(findfstype /boot) |
27
by Evan Dandrea, Colin Watson, Evan Dandrea
[ Colin Watson ] |
265 |
if [ -d "$bootfs" ] && [ "$bootfstype" = "none" ]; then |
266 |
bootfs=$rootfs |
|
267 |
bootfstype=$(findfstype /) |
|
268 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
269 |
[ -n "$bootfstype" ] || bootfstype="$(findfstype /)" |
27
by Evan Dandrea, Colin Watson, Evan Dandrea
[ Colin Watson ] |
270 |
[ -n "$bootfs" ] || bootfs="$rootfs" |
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
271 |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
272 |
case $ARCH in |
273 |
powerpc/*)
|
|
274 |
offs=$(findfs /boot/grub) |
|
275 |
[ -n "$offs" ] || error "GRUB requires that the OF partition is mounted in /boot/grub" 1>&2 |
|
276 |
;;
|
|
277 |
esac
|
|
278 |
||
279 |
# This code to set disc_offered was taken from lilo-installer
|
|
280 |
rootfs_nodevfs=$(mapdevfs $rootfs) |
|
281 |
bootfs_nodevfs=$(mapdevfs $bootfs) |
|
0.2.11
by Colin Watson, Updated translations
* Merge changes from Ubuntu by Evan Dandrea and myself: |
282 |
prefix=$(device_to_disk "$bootfs") |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
283 |
|
284 |
case $prefix in |
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
285 |
/dev/md)
|
286 |
disc_offered_devfs="$bootfs" |
|
287 |
;;
|
|
288 |
/dev/mapper)
|
|
289 |
disc_offered_devfs="$bootfs" |
|
290 |
;;
|
|
291 |
/dev/loop)
|
|
292 |
disc_offered_devfs="$bootfs" |
|
293 |
;;
|
|
0.2.15
by Otavio Salvador, Jeremie Koenig, Christian Perrier, Colin Watson, Otavio Salvador, Updated translations
[ Jeremie Koenig ] |
294 |
/dev/[hsv]d[a-z0-9]|/dev/xvd[a-z]|/dev/cciss/c[0-9]d[0-9]*|/dev/ida/c[0-9]d[0-9]*|/dev/rs/c[0-9]d[0-9]*|/dev/mmcblk[0-9]|/dev/ad[0-9]*|/dev/da[0-9]*) |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
295 |
disc_offered_devfs="$prefix" |
296 |
;;
|
|
297 |
*)
|
|
64
by Colin Watson
* Fix typo in fallback case when computing $disc_offered_devfs. |
298 |
disc_offered_devfs=$(echo "$bootfs_nodevfs" | sed "s:\(.*\)/.*:\1/disc:") |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
299 |
;;
|
300 |
esac
|
|
301 |
disc_offered=$(mapdevfs "$disc_offered_devfs") |
|
302 |
||
303 |
# Identify partition table of the disk containing our boot partition
|
|
304 |
bootfslabel=$(partmap $disc_offered || echo unknown) |
|
305 |
||
36
by Colin Watson, Dustin Kirkland
[ Dustin Kirkland ] |
306 |
found=0 |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
307 |
# Check if the boot file system is on Serial ATA RAID
|
308 |
frdev="" |
|
48
by Colin Watson
Check dmraid's exit code as well as parsing its output, the latter for |
309 |
if [ "$found" = "0" ] && type dmraid >/dev/null 2>&1 && \ |
50
by Colin Watson
* cciss and ida logical drive numbers may go up to 15, not just 9. |
310 |
dmraid -s -c >/dev/null 2>&1 && \ |
311 |
db_get disk-detect/activate_dmraid && [ "$RET" = true ]; then |
|
55
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
312 |
for frdisk in $(dmraid -s -c); do |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
313 |
if echo "$disc_offered" | grep -q "/$frdisk[0-9]\+"; then |
314 |
frdev=/dev/mapper/$frdisk |
|
315 |
frbootpart=${disc_offered#$frdev} |
|
0.1.5
by Colin Watson
* Merge from Ubuntu: |
316 |
frgrubroot=$frbootpart |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
317 |
frtype=sataraid |
36
by Colin Watson, Dustin Kirkland
[ Dustin Kirkland ] |
318 |
found=1 |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
319 |
break
|
320 |
fi
|
|
321 |
done
|
|
65
by Colin Watson
* Fix mishandling of loop variable that caused the semi-manual |
322 |
[ "$found" = "1" ] || frdisk= |
36
by Colin Watson, Dustin Kirkland
[ Dustin Kirkland ] |
323 |
fi
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
324 |
# Check if the boot file system is on multipath
|
36
by Colin Watson, Dustin Kirkland
[ Dustin Kirkland ] |
325 |
if [ "$found" = "0" ] && type multipath >/dev/null 2>&1; then |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
326 |
for frdisk in $(multipath -l 2>/dev/null | \ |
327 |
grep '^mpath[0-9]\+ ' | cut -d ' ' -f 1); do |
|
328 |
if echo "$disc_offered" | \ |
|
329 |
grep -q "^/dev/mapper/${frdisk}-part[0-9]\+"; then |
|
330 |
frdev=/dev/mapper/$frdisk |
|
331 |
frbootpart=${disc_offered#$frdev} |
|
0.1.5
by Colin Watson
* Merge from Ubuntu: |
332 |
frgrubroot=${frbootpart#-part} |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
333 |
frtype=multipath |
36
by Colin Watson, Dustin Kirkland
[ Dustin Kirkland ] |
334 |
found=1 |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
335 |
break
|
336 |
fi
|
|
337 |
done
|
|
65
by Colin Watson
* Fix mishandling of loop variable that caused the semi-manual |
338 |
if [ "$found" = "1" ]; then |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
339 |
# Create the device nodes for grub:
|
340 |
apt-install dmsetup |
|
341 |
$chroot $ROOT mount /proc |
|
342 |
$chroot $ROOT dmsetup mknodes |
|
65
by Colin Watson
* Fix mishandling of loop variable that caused the semi-manual |
343 |
else
|
344 |
frdisk= |
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
345 |
fi
|
71
by Colin Watson
Don't check for LVM when we've already worked out that we're installing |
346 |
fi
|
347 |
if [ "$found" = "0" ] && type lvdisplay >/dev/null 2>&1 && \ |
|
0.1.5
by Colin Watson
* Merge from Ubuntu: |
348 |
(lvdisplay "$disc_offered" | grep -q 'LV Name' 2>/dev/null || \ |
349 |
[ -e "$(dirname "$disc_offered")/control" ]); then |
|
350 |
# Don't set frdev/frdisk here, otherwise you'll end up in different
|
|
351 |
# code paths below ...
|
|
352 |
frtype=lvm |
|
36
by Colin Watson, Dustin Kirkland
[ Dustin Kirkland ] |
353 |
fi
|
354 |
# Check if the boot file system is on an mdadm device
|
|
355 |
if [ "$found" = "0" ] && type mdadm >/dev/null 2>&1; then |
|
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
356 |
frdisk_list= |
35
by Colin Watson, Dustin Kirkland
[ Dustin Kirkland ] |
357 |
for frdisk in $(mdadm --detail "$bootfs_nodevfs" 2>/dev/null | \ |
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
358 |
grep " active sync " 2>/dev/null | \ |
359 |
sed "s/^.* active sync\s*//" 2>/dev/null \ |
|
360 |
); do |
|
88
by Colin Watson
Ignore words not beginning with "/dev/" in 'mdadm --detail' output |
361 |
case $frdisk in |
362 |
/dev/*) ;; |
|
363 |
*) continue ;; |
|
364 |
esac
|
|
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
365 |
# Build a list of devices in the mirror
|
89
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
366 |
frdisk_list="$frdisk_list $(mapdevfs "$frdisk" || true)" |
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
367 |
frdev= |
368 |
frtype="mdadm" |
|
36
by Colin Watson, Dustin Kirkland
[ Dustin Kirkland ] |
369 |
found=1 |
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
370 |
done
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
371 |
fi
|
39
by Dustin Kirkland
grub-installer: if the boot filesystem is on a virtio device, we need to |
372 |
# Check if the boot file system is on a virtio device, /dev/vd*
|
373 |
if [ "$found" = "0" ] && echo "$bootfs" | grep -qs "^\/dev\/vd[a-z]"; then |
|
374 |
frdisk= |
|
375 |
found=1 |
|
376 |
fi
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
377 |
|
378 |
info "Identified partition label for $bootfs: $bootfslabel" |
|
379 |
||
380 |
case $ARCH in |
|
381 |
i386/mac|amd64/mac) |
|
382 |
# Note: depends on partman-efi to load the efivars module!
|
|
383 |
if [ -d /sys/firmware/efi ]; then |
|
384 |
# This point can't be reached (yet). See debian/isinstallable.
|
|
385 |
grub_package="grub-efi" |
|
386 |
else
|
|
387 |
# On PC/BIOS, default to GRUB Legacy
|
|
388 |
grub_package="grub" |
|
22
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
389 |
fi
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
390 |
;;
|
81
by Colin Watson
* Install grub-efi on i386/efi and amd64/efi subarchitectures. |
391 |
i386/efi|amd64/efi) |
392 |
grub_package="grub-efi" |
|
393 |
;;
|
|
0.2.4
by Otavio Salvador, Frans Pop, Colin Watson, Updated translations
[ Frans Pop ] |
394 |
i386/*|amd64/*) |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
395 |
# On PC/BIOS, default to GRUB Legacy
|
396 |
grub_package="grub" |
|
397 |
;;
|
|
0.1.7
by Aurelien Jarno, Colin Watson, Felix Zielcke, Luca Favatella, Aurelien Jarno, Updated translations
[ Colin Watson ] |
398 |
kfreebsd-i386/*|kfreebsd-amd64/*) |
399 |
grub_package="grub-pc" |
|
400 |
;;
|
|
0.2.15
by Otavio Salvador, Jeremie Koenig, Christian Perrier, Colin Watson, Otavio Salvador, Updated translations
[ Jeremie Koenig ] |
401 |
hurd-i386/*)
|
402 |
grub_package="grub-pc" |
|
403 |
;;
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
404 |
powerpc/*)
|
55
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
405 |
grub_package="grub-ieee1275" |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
406 |
;;
|
0.2.15
by Otavio Salvador, Jeremie Koenig, Christian Perrier, Colin Watson, Otavio Salvador, Updated translations
[ Jeremie Koenig ] |
407 |
*)
|
408 |
info "Unknown architecture $ARCH, defaulting to grub-legacy" |
|
409 |
grub_package="grub" |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
410 |
esac
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
411 |
|
0.1.5
by Colin Watson
* Merge from Ubuntu: |
412 |
case "$frtype:$bootfstype:$bootfslabel:$grub_package" in |
413 |
lvm:*:*:*)
|
|
414 |
# Booting from LVM requires grub2
|
|
415 |
grub_package="grub-pc" |
|
416 |
;;
|
|
417 |
*:*:*:grub)
|
|
0.2.14
by Otavio Salvador
Drop warning about GRUB 2 being experimental. Closes: #610365. |
418 |
grub_package="grub-pc" |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
419 |
;;
|
0.1.7
by Aurelien Jarno, Colin Watson, Felix Zielcke, Luca Favatella, Aurelien Jarno, Updated translations
[ Colin Watson ] |
420 |
*:ufs:*:*)
|
421 |
# Booting from UFS requires grub2
|
|
422 |
grub_package="grub-pc" |
|
423 |
;;
|
|
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
424 |
*:zfs:*:*)
|
425 |
# Booting from ZFS requires grub2
|
|
426 |
grub_package="grub-pc" |
|
427 |
;;
|
|
0.2.9
by Aurelien Jarno, Aurelien Jarno, Updated translations
[ Aurelien Jarno ] |
428 |
*:ext2fs:*:grub-pc | *:xfs:*:grub-pc) |
429 |
# Booting ext2fs or xfs using grub2 works
|
|
430 |
;;
|
|
81
by Colin Watson
* Install grub-efi on i386/efi and amd64/efi subarchitectures. |
431 |
*:*:*:grub-efi*)
|
432 |
# No reasonable alternative to GRUB here
|
|
433 |
;;
|
|
0.1.5
by Colin Watson
* Merge from Ubuntu: |
434 |
*:*:*:*)
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
435 |
db_subst grub-installer/grub_not_mature_on_this_platform ARCH $ARCH
|
436 |
db_input low grub-installer/grub_not_mature_on_this_platform || [ $? -eq 30 ] |
|
0.2.3
by Felix Zielcke
* Merge from Ubuntu: |
437 |
db_go || exit 10 |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
438 |
db_get grub-installer/grub_not_mature_on_this_platform |
439 |
if [ "$RET" != true ]; then |
|
440 |
exit 10 |
|
441 |
fi
|
|
442 |
;;
|
|
443 |
esac
|
|
444 |
||
445 |
case $grub_package in |
|
446 |
grub)
|
|
447 |
grub_version="grub" |
|
448 |
menu_file="menu.lst" |
|
0.1.4
by Colin Watson, Colin Watson, Frans Pop, Updated translations
[ Colin Watson ] |
449 |
update_grub="update-grub -y" |
0.1.5
by Colin Watson
* Merge from Ubuntu: |
450 |
partition_offset=1 |
451 |
frgrubroot=$(($frgrubroot - 1)) |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
452 |
;;
|
453 |
*)
|
|
454 |
grub_version="grub2" |
|
455 |
menu_file="grub.cfg" |
|
0.1.4
by Colin Watson, Colin Watson, Frans Pop, Updated translations
[ Colin Watson ] |
456 |
update_grub="update-grub" |
0.1.5
by Colin Watson
* Merge from Ubuntu: |
457 |
partition_offset=0 |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
458 |
;;
|
459 |
esac
|
|
7
by Colin Watson
* Resynchronise with Debian. |
460 |
|
461 |
# determine if /boot or / are on a removable disk. We will do it for Linux only
|
|
462 |
# and see how bad it goes.
|
|
463 |
||
464 |
if [ "$(uname -s | tr '[A-Z]' '[a-z]')" = "linux" ]; then |
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
465 |
bootremovable="$(is_removable /boot)" |
466 |
[ -n "$bootremovable" ] || bootremovable="$(is_removable /)" |
|
7
by Colin Watson
* Resynchronise with Debian. |
467 |
fi
|
468 |
||
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
469 |
user_params=$(user-params) || true |
470 |
defopt_params="" |
|
471 |
kopt_params="" |
|
472 |
got_quiet="" |
|
59
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
473 |
got_splash="" |
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
474 |
for u_param in $user_params; do |
475 |
case "$u_param" in |
|
476 |
quiet)
|
|
477 |
got_quiet=1 |
|
478 |
defopt_params=${defopt_params:+$defopt_params }$u_param ;; |
|
59
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
479 |
splash)
|
480 |
got_splash=1 |
|
79
by Colin Watson
Historically, Ubuntu's default behaviour in the absence of command-line |
481 |
;;
|
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
482 |
*)
|
483 |
kopt_params=${kopt_params:+$kopt_params }$u_param ;; |
|
484 |
esac
|
|
485 |
done
|
|
79
by Colin Watson
Historically, Ubuntu's default behaviour in the absence of command-line |
486 |
if [ "$got_splash" ] && \ |
80
by Colin Watson
'nosplash' doesn't work because it isn't passed through by user-params. |
487 |
db_get debian-installer/framebuffer && [ "$RET" = true ] && \ |
488 |
(! db_get debian-installer/splash || [ "$RET" = true ]); then |
|
79
by Colin Watson
Historically, Ubuntu's default behaviour in the absence of command-line |
489 |
defopt_params=${defopt_params:+$defopt_params }splash |
490 |
fi
|
|
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
491 |
if [ "$grub_version" = grub2 ]; then |
492 |
# Add user parameters to the menu file; some options are only added
|
|
493 |
# to the default entry for a kernel instead of all entries.
|
|
494 |
# We have to duplicate grub2's default for
|
|
495 |
# GRUB_CMDLINE_LINUX_DEFAULT here.
|
|
80
by Colin Watson
'nosplash' doesn't work because it isn't passed through by user-params. |
496 |
if [ -z "$got_splash" ] && \ |
497 |
db_get debian-installer/framebuffer && [ "$RET" = true ] && \ |
|
498 |
(! db_get debian-installer/splash || [ "$RET" = true ]); then |
|
59
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
499 |
defopt_params="splash${defopt_params:+ $defopt_params}" |
500 |
fi
|
|
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
501 |
if [ -z "$got_quiet" ]; then |
502 |
defopt_params="quiet${defopt_params:+ $defopt_params}" |
|
503 |
fi
|
|
504 |
# (quoting to deconfuse vim)
|
|
0.1.11
by Felix Zielcke, Colin Watson, Felix Zielcke
[ Colin Watson ] |
505 |
$chroot $ROOT 'debconf-set-selections' <<EOF |
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
506 |
$grub_package grub2/linux_cmdline string $kopt_params
|
507 |
$grub_package grub2/linux_cmdline_default string $defopt_params
|
|
508 |
EOF
|
|
509 |
fi
|
|
60
by Colin Watson
Preseed grub-pc/install_devices based on grub-installer/bootdev (LP: |
510 |
if [ "$grub_package" = grub-pc ]; then |
511 |
# Empty this for now to stop it being asked. We'll fix this up later.
|
|
63
by Colin Watson
* Fix some hardcoded uses of /target. |
512 |
$chroot $ROOT 'debconf-set-selections' <<EOF |
60
by Colin Watson
Preseed grub-pc/install_devices based on grub-installer/bootdev (LP: |
513 |
$grub_package grub-pc/install_devices multiselect
|
73
by Colin Watson
Preseed grub-pc/install_devices_empty while installing grub-pc, since we |
514 |
$grub_package grub-pc/install_devices_empty boolean true
|
60
by Colin Watson
Preseed grub-pc/install_devices based on grub-installer/bootdev (LP: |
515 |
EOF
|
516 |
fi
|
|
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
517 |
|
7
by Colin Watson
* Resynchronise with Debian. |
518 |
db_progress START 0 6 grub-installer/progress/title |
519 |
||
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
520 |
db_subst grub-installer/progress/step_install GRUB "$grub_version" |
7
by Colin Watson
* Resynchronise with Debian. |
521 |
db_progress INFO grub-installer/progress/step_install |
522 |
||
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
523 |
# apt-install passes --no-remove to apt, but grub{,2} conflict each other, so
|
524 |
# we need to purge them first to support users who try grub2 and then switch
|
|
525 |
# to grub legacy, or vice-versa
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
526 |
case "$grub_package" in |
527 |
grub)
|
|
92
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
528 |
log-output -t grub-installer $chroot $ROOT dpkg -P grub-pc-bin grub-pc grub-efi grub-efi-amd64-bin grub-efi-amd64 grub-efi-ia32-bin grub-efi-ia32 grub-gfxpayload-lists |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
529 |
;;
|
530 |
grub-pc)
|
|
92
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
531 |
log-output -t grub-installer $chroot $ROOT dpkg -P grub grub-legacy grub-efi grub-efi-amd64-bin grub-efi-amd64 grub-efi-ia32-bin grub-efi-ia32 |
84
by Colin Watson
Purge grub-efi* when $grub_package is grub or grub-pc, and purge grub, |
532 |
;;
|
533 |
grub-efi)
|
|
92
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
534 |
log-output -t grub-installer $chroot $ROOT dpkg -P grub grub-legacy grub-pc-bin grub-pc grub-gfxpayload-lists |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
535 |
;;
|
536 |
esac
|
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
537 |
|
0.1.10
by Felix Zielcke
* Try installing `grub-legacy' first before `grub' in case GRUB Legacy |
538 |
exit_code=0 |
0.2.4
by Otavio Salvador, Frans Pop, Colin Watson, Updated translations
[ Frans Pop ] |
539 |
inst_package=$grub_package |
0.1.10
by Felix Zielcke
* Try installing `grub-legacy' first before `grub' in case GRUB Legacy |
540 |
case "$grub_package" in |
541 |
grub)
|
|
0.2.4
by Otavio Salvador, Frans Pop, Colin Watson, Updated translations
[ Frans Pop ] |
542 |
if apt-install --no-recommends grub-legacy ; then |
543 |
inst_package=grub-legacy |
|
544 |
else
|
|
0.1.10
by Felix Zielcke
* Try installing `grub-legacy' first before `grub' in case GRUB Legacy |
545 |
apt-install $grub_package || exit_code=$? |
546 |
fi
|
|
547 |
;;
|
|
548 |
*)
|
|
0.2.4
by Otavio Salvador, Frans Pop, Colin Watson, Updated translations
[ Frans Pop ] |
549 |
# Will pull in os-prober based on global setting for Recommends
|
0.1.10
by Felix Zielcke
* Try installing `grub-legacy' first before `grub' in case GRUB Legacy |
550 |
apt-install $grub_package || exit_code=$? |
551 |
;;
|
|
552 |
esac
|
|
553 |
||
554 |
if [ $exit_code -ne 0 ] ; then |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
555 |
db_progress STOP |
0.2.4
by Otavio Salvador, Frans Pop, Colin Watson, Updated translations
[ Frans Pop ] |
556 |
info "Calling 'apt-install $inst_package' failed" |
557 |
db_subst grub-installer/apt-install-failed GRUB "$inst_package" |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
558 |
db_input critical grub-installer/apt-install-failed || true |
7
by Colin Watson
* Resynchronise with Debian. |
559 |
if ! db_go; then |
560 |
exit 10 # back up to menu |
|
561 |
fi
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
562 |
exit 1 |
7
by Colin Watson
* Resynchronise with Debian. |
563 |
fi
|
564 |
||
0.2.4
by Otavio Salvador, Frans Pop, Colin Watson, Updated translations
[ Frans Pop ] |
565 |
grub_debian_version="$($chroot $ROOT dpkg-query -W -f '${Version}' $inst_package)" |
55
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
566 |
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
567 |
if [ "$frtype" = multipath ]; then |
568 |
$chroot $ROOT umount /proc |
|
569 |
fi
|
|
570 |
||
7
by Colin Watson
* Resynchronise with Debian. |
571 |
db_progress STEP 1
|
572 |
db_progress INFO grub-installer/progress/step_os-probe |
|
573 |
os-prober > /tmp/os-probed || true |
|
574 |
||
0.2.15
by Otavio Salvador, Jeremie Koenig, Christian Perrier, Colin Watson, Otavio Salvador, Updated translations
[ Jeremie Koenig ] |
575 |
db_settitle debian-installer/grub-installer/title |
576 |
||
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
577 |
# Work out what probed OSes can be booted from grub
|
7
by Colin Watson
* Resynchronise with Debian. |
578 |
tmpfile=/tmp/menu.lst.extras |
579 |
if [ -s /tmp/os-probed ]; then |
|
580 |
supported_os_list="" |
|
581 |
unsupported_os_list="" |
|
582 |
||
583 |
OLDIFS="$IFS" |
|
584 |
IFS="$newline" |
|
585 |
for os in $(cat /tmp/os-probed); do |
|
586 |
IFS="$OLDIFS" |
|
587 |
title=$(echo "$os" | cut -d: -f2) |
|
588 |
type=$(echo "$os" | cut -d: -f4) |
|
589 |
case "$type" in |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
590 |
chain)
|
591 |
: ;;
|
|
592 |
linux)
|
|
593 |
# Check for linux systems that we don't
|
|
594 |
# know how to boot
|
|
595 |
partition=$(echo "$os" | cut -d: -f1) |
|
596 |
if [ -z "$(linux-boot-prober $partition)" ]; then |
|
7
by Colin Watson
* Resynchronise with Debian. |
597 |
if [ -n "$unsupported_os_list" ]; then |
598 |
unsupported_os_list="$unsupported_os_list, $title" |
|
599 |
else
|
|
600 |
unsupported_os_list="$title" |
|
601 |
fi
|
|
602 |
continue
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
603 |
fi
|
604 |
;;
|
|
605 |
hurd)
|
|
606 |
: ;;
|
|
607 |
*)
|
|
608 |
if [ -n "$unsupported_os_list" ]; then |
|
609 |
unsupported_os_list="$unsupported_os_list, $title" |
|
610 |
else
|
|
611 |
unsupported_os_list="$title" |
|
612 |
fi
|
|
613 |
continue
|
|
7
by Colin Watson
* Resynchronise with Debian. |
614 |
;;
|
615 |
esac
|
|
616 |
||
617 |
if [ -n "$supported_os_list" ]; then |
|
618 |
supported_os_list="$supported_os_list, $title" |
|
619 |
else
|
|
620 |
supported_os_list="$title" |
|
621 |
fi
|
|
622 |
||
623 |
IFS="$newline" |
|
624 |
done
|
|
625 |
IFS="$OLDIFS" |
|
626 |
||
15
by Colin Watson
* Return early from is_removable if the argument isn't a mount point |
627 |
if [ -z "$OVERRIDE_UNSUPPORTED_OS" ] && [ -n "$unsupported_os_list" ]; then |
7
by Colin Watson
* Resynchronise with Debian. |
628 |
# Unsupported OS, jump straight to manual boot device question.
|
629 |
state=2 |
|
630 |
else
|
|
631 |
q=grub-installer/with_other_os |
|
632 |
db_subst $q OS_LIST "$supported_os_list" |
|
633 |
state=1 |
|
634 |
fi
|
|
635 |
else
|
|
636 |
q=grub-installer/only_debian |
|
637 |
state=1 |
|
638 |
fi
|
|
639 |
||
37
by Luke Yelavich
grub-installer: Properly make use of output from os-prober to configure |
640 |
if [ "$frdev" ] && [ "$frtype" != "sataraid" ]; then |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
641 |
if [ -e $ROOT$frdev ] && [ -e $ROOT$frdev$frbootpart ] && \ |
0.1.5
by Colin Watson
* Merge from Ubuntu: |
642 |
[ $frgrubroot -ge $((1 - $partition_offset)) ]; then |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
643 |
db_subst grub-installer/$frtype GRUBROOT $ROOT$frdev$frbootpart |
644 |
q=grub-installer/$frtype |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
645 |
else
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
646 |
db_input critical grub-installer/${frtype}-error |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
647 |
db_go || true |
648 |
exit 1 |
|
649 |
fi
|
|
650 |
fi
|
|
651 |
||
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
652 |
# Try to avoid using (hd0) as a boot device name. Something which can be
|
653 |
# turned into a stable by-id name is better.
|
|
654 |
default_bootdev_os="$($chroot $ROOT grub-mkdevicemap --no-floppy -m - | head -n1 | cut -f2)" |
|
655 |
if [ "$default_bootdev_os" ]; then |
|
81
by Colin Watson
* Install grub-efi on i386/efi and amd64/efi subarchitectures. |
656 |
default_bootdev="$($chroot $ROOT readlink -f "$default_bootdev_os")" |
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
657 |
else
|
0.2.11
by Colin Watson, Updated translations
* Merge changes from Ubuntu by Evan Dandrea and myself: |
658 |
default_bootdev="(hd0)" |
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
659 |
fi
|
0.2.11
by Colin Watson, Updated translations
* Merge changes from Ubuntu by Evan Dandrea and myself: |
660 |
|
661 |
# Set a sensible default boot device, so that we aren't installing GRUB to
|
|
662 |
# installation media which may be removed later. The disk containing /cdrom
|
|
663 |
# is very unlikely to be a sensible default. If we had to fall back to
|
|
664 |
# (hd0), then we can't tell exactly which disk that is, but if /cdrom seems
|
|
665 |
# to be a USB stick then (hd0) may not be safe. If we hit either of those
|
|
666 |
# checks, then try the disk containing /boot instead.
|
|
0.2.13
by Otavio Salvador, Julien Cristau, Updated translations
[ Julien Cristau ] |
667 |
# The same goes for /hd-media, so avoid installing there as well.
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
668 |
cdsrc=$(mount | grep "on /cdrom " | cut -d' ' -f1) |
42
by Colin Watson, Evan Dandrea
[ Evan Dandrea ] |
669 |
cdfs=$(mount | grep "on /cdrom " | cut -d' ' -f5) |
0.2.13
by Otavio Salvador, Julien Cristau, Updated translations
[ Julien Cristau ] |
670 |
hdsrc=$(mount | grep "on /hd-media " | cut -d' ' -f1) |
0.2.11
by Colin Watson, Updated translations
* Merge changes from Ubuntu by Evan Dandrea and myself: |
671 |
hybrid=false |
672 |
if db_get cdrom-detect/hybrid; then |
|
673 |
hybrid="$RET" |
|
674 |
fi
|
|
82
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
675 |
if [ "$grub_package" = grub-efi ]; then |
676 |
# No need for install device selection on EFI.
|
|
677 |
bootdev=efi-dummy |
|
678 |
state=3 |
|
89
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
679 |
elif [ "$(device_to_disk "$cdsrc")" = "$default_bootdev" ] || \ |
680 |
([ -n "$hdsrc" ] && [ "$(device_to_disk "$hdsrc")" = "$default_bootdev" ]) || \ |
|
87
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
681 |
([ "$default_bootdev" = '(hd0)' ] && \ |
682 |
(([ -n "$cdfs" ] && [ "$cdfs" != "iso9660" ]) || \ |
|
89
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
683 |
[ "$hybrid" = true ])) || \ |
684 |
([ "$default_bootdev" != '(hd0)' ] && \ |
|
685 |
! partmap "$default_bootdev" >/dev/null && \ |
|
686 |
! grub_probe -t fs -d "$default_bootdev" >/dev/null); then |
|
42
by Colin Watson, Evan Dandrea
[ Evan Dandrea ] |
687 |
db_fget grub-installer/bootdev seen |
688 |
if [ "$RET" != true ]; then |
|
689 |
bootfs=$(findfs /boot) |
|
690 |
[ "$bootfs" ] || bootfs="$(findfs /)" |
|
0.2.11
by Colin Watson, Updated translations
* Merge changes from Ubuntu by Evan Dandrea and myself: |
691 |
disk=$(device_to_disk "$bootfs") |
42
by Colin Watson, Evan Dandrea
[ Evan Dandrea ] |
692 |
db_set grub-installer/bootdev "$disk" |
693 |
state=2 |
|
694 |
fi
|
|
64
by Colin Watson
* Fix typo in fallback case when computing $disc_offered_devfs. |
695 |
elif [ "$grub_version" = grub2 ] && [ "$frtype" = mdadm ]; then |
68
by Colin Watson
If using GRUB 2 and installing to a RAID device any of whose components |
696 |
# Check whether any of the RAIDed devices is a partition, and if so
|
697 |
# install to the corresponding disk instead, as GRUB 2 doesn't like
|
|
698 |
# installing to a RAID device composed of partitions.
|
|
699 |
# TODO: This duplicates some pretty horrible code from above. This
|
|
700 |
# should at least be turned into a function or something ...
|
|
701 |
disks= |
|
702 |
use_disks= |
|
703 |
for frdisk_one in $frdisk_list; do |
|
704 |
prefix=$(echo "$frdisk_one" | \ |
|
705 |
sed 's:\(/dev/\(cciss\|ida\|rs\)/c[0-9]d[0-9][0-9]*\|/dev/mmcblk[0-9]\|/dev/\(ad\|da\)[0-9]\+\|/dev/[a-z]\+\).*:\1:') |
|
706 |
disks="${disks:+$disks }$prefix" |
|
707 |
case $prefix in |
|
708 |
/dev/[hsv]d[a-z]|/dev/xvd[a-z]|/dev/cciss/c[0-9]d[0-9]*|/dev/ida/c[0-9]d[0-9]*|/dev/rs/c[0-9]d[0-9]*|/dev/mmcblk[0-9]|/dev/ad[0-9]*|/dev/da[0-9]*) |
|
709 |
if [ "$prefix" != "$frdisk_one" ]; then |
|
710 |
use_disks=1 |
|
711 |
fi
|
|
712 |
;;
|
|
713 |
esac
|
|
714 |
done
|
|
715 |
if [ "$use_disks" ]; then |
|
716 |
default_bootdev="$disks" |
|
717 |
else
|
|
718 |
default_bootdev="$bootfs_nodevfs" |
|
719 |
fi
|
|
64
by Colin Watson
* Fix typo in fallback case when computing $disc_offered_devfs. |
720 |
db_set grub-installer/bootdev "$default_bootdev" |
85
by Colin Watson
Install GRUB to the SATA RAID or multipath device when /boot is on such |
721 |
elif [ "$frdev" ]; then |
722 |
default_bootdev="$frdev" |
|
723 |
db_set grub-installer/bootdev "$default_bootdev" |
|
42
by Colin Watson, Evan Dandrea
[ Evan Dandrea ] |
724 |
fi
|
725 |
||
7
by Colin Watson
* Resynchronise with Debian. |
726 |
db_progress STEP 1
|
727 |
db_progress INFO grub-installer/progress/step_bootdev |
|
728 |
||
729 |
while : ; do |
|
730 |
if [ "$state" = 1 ]; then |
|
66
by Colin Watson
* Always use GRUB Legacy when /boot is on a multipath device. |
731 |
if [ "$frdev" ]; then |
732 |
# If /boot is on SATA RAID/multipath, then there's
|
|
733 |
# only one possible answer; we don't support device
|
|
734 |
# selection yet. This is pretty nasty.
|
|
735 |
db_set $q true || true |
|
736 |
db_fset $q seen true || true |
|
737 |
fi
|
|
78
by Colin Watson
* Ask grub-installer/only_debian at high priority again (LP: #47135). |
738 |
db_input high $q || true |
7
by Colin Watson
* Resynchronise with Debian. |
739 |
if ! db_go; then |
740 |
# back up to menu
|
|
741 |
db_progress STOP |
|
742 |
exit 10 |
|
743 |
fi
|
|
744 |
db_get $q
|
|
745 |
if [ "$RET" = true ]; then |
|
746 |
if [ -n "$bootremovable" ]; then |
|
747 |
bootdev="$bootremovable" |
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
748 |
if [ "$grub_version" = grub ] && \ |
749 |
[ ! -e "$device_map" ]; then |
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
750 |
mkdir -p "$(dirname "$device_map")" |
751 |
echo "(hd0) $bootremovable" > "$device_map" |
|
752 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
753 |
else
|
64
by Colin Watson
* Fix typo in fallback case when computing $disc_offered_devfs. |
754 |
bootdev="$default_bootdev" |
7
by Colin Watson
* Resynchronise with Debian. |
755 |
fi
|
756 |
break
|
|
757 |
else
|
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
758 |
# Exit to menu if /boot is on SATA RAID/multipath; we
|
759 |
# don't support device selection in that case
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
760 |
if [ "$frdev" ]; then |
761 |
db_progress STOP |
|
762 |
exit 10 |
|
763 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
764 |
state=2 |
765 |
fi
|
|
82
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
766 |
elif [ "$state" = 2 ]; then |
7
by Colin Watson
* Resynchronise with Debian. |
767 |
db_input critical grub-installer/bootdev || true |
768 |
if ! db_go; then |
|
769 |
if [ "$q" ]; then |
|
770 |
state=1 |
|
771 |
else
|
|
772 |
# back up to menu
|
|
773 |
db_progress STOP |
|
774 |
exit 10 |
|
775 |
fi
|
|
776 |
else
|
|
777 |
db_get grub-installer/bootdev |
|
778 |
bootdev=$RET |
|
779 |
if echo "$bootdev" | grep -qv '('; then |
|
780 |
mappedbootdev=$(mapdevfs "$bootdev") || true |
|
781 |
if [ -n "$mappedbootdev" ]; then |
|
782 |
bootdev="$mappedbootdev" |
|
783 |
fi
|
|
784 |
fi
|
|
785 |
break
|
|
786 |
fi
|
|
82
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
787 |
else
|
788 |
break
|
|
7
by Colin Watson
* Resynchronise with Debian. |
789 |
fi
|
790 |
done
|
|
791 |
||
24
by Colin Watson
Support grub-installer/bootdev_directory preseeding to make use of the |
792 |
if db_get grub-installer/bootdev_directory && [ "$RET" ]; then |
793 |
bootdev= |
|
59
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
794 |
if [ "$grub_version" = grub ] && ! [ -f "$device_map" ]; then |
63
by Colin Watson
* Fix some hardcoded uses of /target. |
795 |
echo quit | $chroot $ROOT /usr/sbin/grub --batch --device-map="${device_map#$ROOT}" >/dev/null 2>&1 |
28
by Evan Dandrea
Generate a device.map when bootdev_directory is set (loop |
796 |
fi
|
24
by Colin Watson
Support grub-installer/bootdev_directory preseeding to make use of the |
797 |
fi
|
798 |
||
7
by Colin Watson
* Resynchronise with Debian. |
799 |
db_progress STEP 1
|
800 |
db_subst grub-installer/progress/step_install_loader BOOTDEV "$bootdev" |
|
801 |
db_progress INFO grub-installer/progress/step_install_loader |
|
802 |
||
803 |
info "Installing grub on '$bootdev'" |
|
804 |
||
805 |
update_mtab |
|
806 |
||
24
by Colin Watson
Support grub-installer/bootdev_directory preseeding to make use of the |
807 |
mkdir -p $ROOT/boot/grub
|
808 |
||
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
809 |
write_grub() { |
810 |
info "Installing GRUB to $frdev; grub root is $disc_offered" |
|
811 |
# TODO: Check for errors during this process!
|
|
812 |
TERM=linux $chroot $ROOT \ |
|
813 |
grub --device-map=/dev/null >/var/log/grub-${frtype}.log 2>&1 </dev/null <<EOF |
|
814 |
device (hd0,$frgrubroot) $disc_offered
|
|
815 |
device (hd0) $frdev
|
|
816 |
root (hd0,$frgrubroot)
|
|
817 |
setup (hd0)
|
|
818 |
quit
|
|
819 |
EOF
|
|
820 |
}
|
|
821 |
||
65
by Colin Watson
* Fix mishandling of loop variable that caused the semi-manual |
822 |
if [ -z "$frdisk" ] || [ "$grub_version" = grub2 ]; then |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
823 |
|
824 |
# Install grub on each space separated disk in the list
|
|
825 |
bootdevs="$bootdev" |
|
826 |
for bootdev in $bootdevs; do |
|
827 |
grub_install_params= |
|
828 |
if ! is_floppy "$bootdev"; then |
|
829 |
if $chroot $ROOT grub-install -h 2>&1 | grep -q no-floppy; then |
|
830 |
info "grub-install supports --no-floppy"
|
|
831 |
grub_install_params="$grub_install_params --no-floppy" |
|
832 |
else
|
|
833 |
info "grub-install does not support --no-floppy"
|
|
834 |
fi
|
|
835 |
if [ -e $ROOT/boot/grub/device.map ] && grep '^(fd' $ROOT/boot/grub/device.map; then |
|
836 |
recheck="--recheck" |
|
837 |
fi
|
|
838 |
else
|
|
839 |
if [ -e $ROOT/boot/grub/device.map ] && ! grep '^(fd' $ROOT/boot/grub/device.map; then |
|
840 |
recheck="--recheck" |
|
841 |
fi
|
|
842 |
fi
|
|
843 |
||
844 |
if [ "$ARCH" = "powerpc/chrp_pegasos" ] ; then |
|
845 |
# nvram is broken here
|
|
846 |
grub_install_params="$grub_install_params --no-nvram" |
|
847 |
fi
|
|
848 |
||
849 |
if [ "$grub_version" = "grub" ] ; then |
|
850 |
grub_install_params="$grub_install_params $recheck" |
|
0.2.2
by Felix Zielcke, Colin Watson
[ Colin Watson ] |
851 |
else
|
852 |
# install even if it requires blocklists
|
|
853 |
grub_install_params="$grub_install_params --force" |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
854 |
fi
|
855 |
||
77
by Colin Watson
Bind-mount /proc and /sys while running grub-install (LP: #527210). |
856 |
umountproc=false |
857 |
umountsys=false |
|
858 |
if [ ! -e $ROOT/proc/cmdline ]; then |
|
859 |
$chroot $ROOT mount /proc |
|
860 |
umountproc=: |
|
861 |
fi
|
|
862 |
if [ ! -d $ROOT/sys/devices ]; then |
|
863 |
$chroot $ROOT mount -t sysfs sysfs /sys |
|
864 |
umountsys=: |
|
865 |
fi
|
|
866 |
||
82
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
867 |
CODE=0 |
868 |
if [ "$grub_package" = grub-efi ]; then |
|
869 |
info "Running $chroot $ROOT grub-install $grub_install_params" |
|
870 |
log-output -t grub-installer $chroot $ROOT grub-install $grub_install_params || CODE=$? |
|
871 |
else
|
|
872 |
info "Running $chroot $ROOT grub-install $grub_install_params \"$bootdev\"" |
|
873 |
log-output -t grub-installer $chroot $ROOT grub-install $grub_install_params "$bootdev" || CODE=$? |
|
874 |
fi
|
|
875 |
if [ "$CODE" = 0 ]; then |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
876 |
info "grub-install ran successfully"
|
877 |
else
|
|
82
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
878 |
if [ "$grub_package" = grub-efi ]; then |
879 |
error "Running 'grub-install $grub_install_params' failed." |
|
880 |
else
|
|
881 |
error "Running 'grub-install $grub_install_params \"$bootdev\"' failed." |
|
882 |
fi
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
883 |
db_subst grub-installer/grub-install-failed BOOTDEV "$bootdev" |
884 |
db_input critical grub-installer/grub-install-failed || [ $? -eq 30 ] |
|
885 |
db_go || true |
|
886 |
db_progress STOP |
|
77
by Colin Watson
Bind-mount /proc and /sys while running grub-install (LP: #527210). |
887 |
if $umountsys; then |
888 |
$chroot $ROOT umount /sys |
|
889 |
fi
|
|
890 |
if $umountproc; then |
|
891 |
$chroot $ROOT umount /proc |
|
892 |
fi
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
893 |
exit 1 |
894 |
fi
|
|
77
by Colin Watson
Bind-mount /proc and /sys while running grub-install (LP: #527210). |
895 |
|
896 |
if $umountsys; then |
|
897 |
$chroot $ROOT umount /sys |
|
898 |
fi
|
|
899 |
if $umountproc; then |
|
900 |
$chroot $ROOT umount /proc |
|
901 |
fi
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
902 |
done
|
903 |
||
904 |
else
|
|
905 |
||
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
906 |
# Semi-manual grub setup for Serial ATA RAID/multipath
|
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
907 |
info "Boot partition is on a Serial ATA RAID disk, multipath, or mdadm device"
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
908 |
case $(archdetect) in |
909 |
i386/*)
|
|
910 |
stagedir=i386-pc ;; |
|
911 |
amd64/*)
|
|
912 |
stagedir=x86_64-pc ;; |
|
913 |
*)
|
|
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
914 |
error "Unsupported architecture for SATA RAID/multipath/mdadm installation"
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
915 |
exit 1 |
916 |
;;
|
|
917 |
esac
|
|
918 |
if [ ! -d $ROOT/usr/lib/grub/$stagedir/ ]; then |
|
919 |
error "Grub stage files not available"
|
|
920 |
exit 1 |
|
921 |
fi
|
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
922 |
mkdir -p $ROOT/boot/grub
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
923 |
cp $ROOT/usr/lib/grub/$stagedir/* $ROOT/boot/grub |
924 |
||
34
by Colin Watson, Colin Watson, Dustin Kirkland
[ Colin Watson ] |
925 |
if [ "$frtype" = "mdadm" ]; then |
926 |
for frdisk in $frdisk_list; do |
|
927 |
frdev=$(echo "$frdisk" | sed "s/[0-9]\+$//") |
|
928 |
disc_offered=$frdev |
|
929 |
frbootpart=${frdisk#$frdev} |
|
930 |
frgrubroot=$(($frbootpart-1)) |
|
931 |
write_grub |
|
932 |
done
|
|
933 |
else
|
|
934 |
write_grub |
|
935 |
fi
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
936 |
|
937 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
938 |
|
23
by Colin Watson
Mark the partition to which GRUB is being installed as bootable, or |
939 |
# Split a device name into a disk device name and a partition number, if
|
940 |
# possible.
|
|
941 |
split_device () { |
|
942 |
disk= |
|
943 |
part= |
|
944 |
case $1 in |
|
29
by Soren Hansen
Teach grub-installer about virtio devices (/dev/vd*). |
945 |
/dev/[vhs]d[a-z]*) |
23
by Colin Watson
Mark the partition to which GRUB is being installed as bootable, or |
946 |
disk="$(echo "$1" | sed 's,\(/dev/[a-z]\+\).*,\1,')" |
947 |
part="$(echo "$1" | sed 's,/dev/[a-z]\+\(.*\),\1,')" |
|
948 |
;;
|
|
949 |
/dev/*/c*d*)
|
|
950 |
disk="$(echo "$1" | sed 's,\(/dev/.*/c[0-9]\+d[0-9]\+\).*,\1,')" |
|
951 |
part="$(echo "$1" | sed 's,/dev/.*/c[0-9]\+d[0-9]\+p\([0-9]\+\),\1,')" |
|
952 |
[ "$part" != "$1" ] || part= |
|
953 |
;;
|
|
51
by Colin Watson
Handle /dev/mmcblk* in split_device (LP: #348411). |
954 |
/dev/mmcblk*)
|
955 |
disk="$(echo "$1" | sed 's,\(/dev/mmcblk[0-9]\+\).*,\1,')" |
|
956 |
part="$(echo "$1" | sed 's,/dev/mmcblk[0-9]\+p\([0-9]\+\),\1,')" |
|
957 |
[ "$part" != "$1" ] || part= |
|
958 |
;;
|
|
23
by Colin Watson
Mark the partition to which GRUB is being installed as bootable, or |
959 |
esac
|
960 |
echo "$disk $part" |
|
961 |
}
|
|
962 |
||
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
963 |
make_device_map () { |
964 |
# If you're preseeding (hd0) et al, stop - preseed OS device names
|
|
965 |
# instead. However, for backward compatibility we ensure that a
|
|
966 |
# device.map exists if you do this.
|
|
967 |
[ "$grub_version" = grub2 ] || return 0 |
|
968 |
[ ! -e "$device_map" ] || return 0 |
|
969 |
local no_floppy
|
|
970 |
case $1 in |
|
971 |
\(fd*|fd*) |
|
972 |
no_floppy= |
|
973 |
;;
|
|
974 |
*)
|
|
975 |
no_floppy=--no-floppy |
|
976 |
;;
|
|
977 |
esac
|
|
978 |
$chroot $ROOT grub-mkdevicemap $no_floppy |
|
979 |
}
|
|
980 |
||
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
981 |
make_active_partition () { |
982 |
bootdisk= |
|
983 |
bootpart= |
|
984 |
case $bootdev in |
|
985 |
/dev/*)
|
|
986 |
bootdev_split="$(split_device "$bootdev")" |
|
987 |
bootdisk="${bootdev_split%% *}" |
|
988 |
bootpart="${bootdev_split#* }" |
|
989 |
;;
|
|
990 |
\([hf]d[0-9]*\)) |
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
991 |
make_device_map "$bootdev" |
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
992 |
bootdev_nopart="$(echo "$bootdev" | sed 's/,[^)]*//')" |
993 |
bootdisk="$(grep -v '^#' $device_map | grep "^ *$bootdev_nopart" \ |
|
994 |
| sed 's/^ *(.*)[[:space:]]*\(.*\)/\1/')" |
|
995 |
bootpart="$(echo "$bootdev" | sed 's/.*,\([^)]*\).*/\1/')" |
|
996 |
[ "$bootpart" != "$bootdev" ] || bootpart= |
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
997 |
if [ "$bootpart" ]; then |
998 |
bootpart="$(($bootpart + $partition_offset))" |
|
999 |
fi
|
|
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
1000 |
;;
|
1001 |
[hf]d[0-9]*) |
|
1002 |
# The GRUB format with no parenthesis.
|
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
1003 |
make_device_map "$bootdev" |
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
1004 |
bootdisk="$(grep -v '^#' $device_map | grep "^ *(${bootdev%%,*})" \ |
1005 |
| sed 's/^ *(.*)[[:space:]]*\(.*\)/\1/')" |
|
1006 |
bootpart="${bootdev#*,}" |
|
1007 |
[ "$bootpart" != "$bootdev" ] || bootpart= |
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
1008 |
if [ "$bootpart" ]; then |
1009 |
bootpart="$(($bootpart + $partition_offset))" |
|
1010 |
fi
|
|
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
1011 |
;;
|
1012 |
esac
|
|
1013 |
||
1014 |
# Make sure that there's *some* active partition; some BIOSes
|
|
1015 |
# reportedly don't like it otherwise. Leave well alone on GPT since
|
|
1016 |
# libparted does this for us.
|
|
1017 |
# TODO: this is gross and wrong; doing it with libparted would probably
|
|
1018 |
# be slightly less unpleasant.
|
|
1019 |
if [ "$bootdisk" ] && ! fdisk -l "$bootdisk" | grep '^/dev/' | grep -q '\*' && \ |
|
76
by Colin Watson
Fix GPT detection to account for changed fdisk output (LP: #538100). |
1020 |
! fdisk -l "$bootdisk" | grep -q 'GPT$'; then |
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
1021 |
if [ -z "$bootpart" ]; then |
1022 |
# bootdev must be set to a disk rather than a
|
|
1023 |
# partition, or we'd already have an active partition
|
|
1024 |
# due to the previous check. Try /boot, if it's on the
|
|
1025 |
# same disk and is primary.
|
|
1026 |
bootfs="$(findfs /boot)" |
|
1027 |
[ "$bootfs" ] || bootfs="$(findfs /)" |
|
1028 |
bootfs="$(mapdevfs "$bootfs")" |
|
1029 |
bootfs_split="$(split_device "$bootfs")" |
|
1030 |
bootfs_disk="${bootfs_split%% *}" |
|
1031 |
bootfs_part="${bootfs_split#* }" |
|
1032 |
if [ "$bootfs_disk" = "$bootdisk" ] && \ |
|
1033 |
([ "$bootfs_part" -ge 1 ] && [ "$bootfs_part" -le 4 ]); then |
|
1034 |
bootpart="$bootfs_part" |
|
23
by Colin Watson
Mark the partition to which GRUB is being installed as bootable, or |
1035 |
fi
|
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
1036 |
fi
|
1037 |
||
1038 |
if [ -z "$bootpart" ]; then |
|
1039 |
# We don't care at this point; just pick the first
|
|
1040 |
# primary partition that exists.
|
|
1041 |
for pnum in 1 2 3 4; do |
|
1042 |
if fdisk -l "$bootdisk" | grep -q "^$bootdisk$pnum "; then |
|
1043 |
bootpart="$pnum" |
|
1044 |
break
|
|
1045 |
fi
|
|
1046 |
done
|
|
1047 |
fi
|
|
1048 |
||
53
by Colin Watson
* If sfdisk fails to set the first primary partition we try as active, try |
1049 |
while [ "$bootpart" ]; do |
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
1050 |
echo -n "I: Setting partition $bootpart of $bootdisk to active..." >&2 |
53
by Colin Watson
* If sfdisk fails to set the first primary partition we try as active, try |
1051 |
if sfdisk -A"$bootpart" "$bootdisk"; then |
1052 |
echo "done." >&2 |
|
1053 |
break
|
|
1054 |
elif [ "$bootpart" -lt 4 ]; then |
|
1055 |
echo "failed; trying next primary partition" >&2 |
|
1056 |
bootpart="$(($bootpart + 1))" |
|
1057 |
else
|
|
1058 |
echo "failed; run out of primary partitions to try. Hope your BIOS doesn't mind there being no active partition!" >&2 |
|
1059 |
break
|
|
1060 |
fi
|
|
1061 |
done
|
|
31
by Evan Dandrea
Added the grub-installer/make_active debconf question. When |
1062 |
fi
|
1063 |
}
|
|
1064 |
||
1065 |
db_get grub-installer/make_active |
|
1066 |
if [ "$RET" = true ]; then |
|
1067 |
make_active_partition |
|
23
by Colin Watson
Mark the partition to which GRUB is being installed as bootable, or |
1068 |
fi
|
1069 |
||
0.2.3
by Felix Zielcke
* Merge from Ubuntu: |
1070 |
if [ "$grub_package" = "grub-pc" ]; then |
1071 |
# Do the same thing on upgrades.
|
|
1072 |
$chroot $ROOT 'debconf-set-selections' <<EOF |
|
72
by Colin Watson
* Add $partition_offset to $bootpart when deciding which partition to make |
1073 |
$grub_package grub-pc/install_devices multiselect $(devices_to_ids $bootdevs)
|
73
by Colin Watson
Preseed grub-pc/install_devices_empty while installing grub-pc, since we |
1074 |
$grub_package grub-pc/install_devices_empty boolean false
|
1075 |
$grub_package grub-pc/install_devices_empty seen false
|
|
0.2.3
by Felix Zielcke
* Merge from Ubuntu: |
1076 |
EOF
|
1077 |
fi
|
|
1078 |
||
7
by Colin Watson
* Resynchronise with Debian. |
1079 |
db_progress STEP 1
|
1080 |
db_progress INFO grub-installer/progress/step_config_loader |
|
1081 |
||
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
1082 |
if [ "$bootfstype" = "zfs" ]; then |
1083 |
# Required by update-grub on ZFS
|
|
0.2.18
by Colin Watson, Updated translations
* Ensure that /boot/zfs exists in the target before copying zpool.cache to |
1084 |
mkdir -p $ROOT/boot/zfs
|
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
1085 |
cp /boot/zfs/zpool.cache $ROOT/boot/zfs/
|
1086 |
fi
|
|
1087 |
||
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1088 |
# Delete for idempotency
|
1089 |
rm -f $ROOT/boot/grub/$menu_file |
|
7
by Colin Watson
* Resynchronise with Debian. |
1090 |
update_grub |
1091 |
||
0.1.2
by Frans Pop
Add support for MMC/SD card devices (mmcblkX). |
1092 |
# For SATA RAID/multipath the grub root may need fixing up
|
1093 |
# For dmraid we can end up with e.g. '(sil_aiahbgbgaaaj1)', or we can end up
|
|
1094 |
# with '(hd0,0)' when it should be a higher partition
|
|
1095 |
# TODO: This should really be better supported in update-grub
|
|
1096 |
if [ "$frdev" ] && \ |
|
1097 |
! grep -q "^# groot=(hd0,$frgrubroot)" $ROOT/boot/grub/$menu_file; then |
|
1098 |
info "Fixing up the grub root to '(hd0,$frgrubroot)'" |
|
1099 |
sed -i "/^# groot/s/(.*)/(hd0,$frgrubroot)/" $ROOT/boot/grub/$menu_file |
|
1100 |
update_grub |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1101 |
fi
|
1102 |
||
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1103 |
# Set a password if asked
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1104 |
if [ "$grub_version" = "grub" ] ; then |
32
by Colin Watson, Colin Watson, James Westby
[ Colin Watson ] |
1105 |
# Set up a password if asked or preseeded.
|
1106 |
password= |
|
1107 |
db_get grub-installer/password-crypted |
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1108 |
if [ "$RET" = false ] || [ "$RET" = true ]; then |
32
by Colin Watson, Colin Watson, James Westby
[ Colin Watson ] |
1109 |
# password-crypted used to be a boolean template
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1110 |
error "Preseeding of encrypted passwords changed! Check installation guide."
|
1111 |
exit 1 |
|
1112 |
elif [ "$RET" ]; then |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1113 |
password="$RET" |
32
by Colin Watson, Colin Watson, James Westby
[ Colin Watson ] |
1114 |
else
|
1115 |
PW_PRIO=low |
|
1116 |
while :; do |
|
1117 |
password="" |
|
1118 |
db_input $PW_PRIO grub-installer/password || true |
|
1119 |
if ! db_go; then |
|
1120 |
# back up to menu
|
|
1121 |
db_progress STOP |
|
1122 |
exit 10 |
|
1123 |
fi
|
|
1124 |
||
1125 |
db_get grub-installer/password |
|
1126 |
if [ "$RET" ]; then |
|
1127 |
password="$RET" |
|
1128 |
db_input $PW_PRIO grub-installer/password-again || true |
|
1129 |
if ! db_go; then |
|
1130 |
db_progress STOP |
|
1131 |
exit 10 |
|
1132 |
fi
|
|
1133 |
||
1134 |
db_get grub-installer/password-again |
|
1135 |
if [ "$password" = "$RET" ]; then |
|
1136 |
break
|
|
1137 |
else
|
|
1138 |
db_input critical grub-installer/password-mismatch || true |
|
1139 |
if ! db_go; then |
|
1140 |
db_progress STOP |
|
1141 |
exit 10 |
|
1142 |
fi
|
|
1143 |
fi
|
|
1144 |
else
|
|
1145 |
# The user doesn't want a password
|
|
1146 |
break
|
|
1147 |
fi
|
|
1148 |
# We only get here if passwords don't match
|
|
1149 |
PW_PRIO=critical |
|
1150 |
db_set grub-installer/password ""
|
|
1151 |
db_set grub-installer/password-again ""
|
|
1152 |
db_fset grub-installer/password seen false
|
|
1153 |
db_fset grub-installer/password-again seen false
|
|
1154 |
done
|
|
1155 |
if [ "$password" ]; then |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1156 |
password=$(echo -e "md5crypt\n$password" | \ |
32
by Colin Watson, Colin Watson, James Westby
[ Colin Watson ] |
1157 |
$chroot $ROOT \ |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1158 |
grub --batch --device-map=/dev/null 2>&1 | \ |
1159 |
grep "^Encrypted:" | cut -d' ' -f2) |
|
1160 |
fi
|
|
32
by Colin Watson, Colin Watson, James Westby
[ Colin Watson ] |
1161 |
fi
|
1162 |
||
1163 |
if [ "$password" ]; then |
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1164 |
echo "password --md5 $password" >/tmp/menu.lst.password |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1165 |
# Add a line to menu.lst to use the given password
|
1166 |
# The line is appended after the commented example
|
|
1167 |
sed -i '/^# password/r /tmp/menu.lst.password' $ROOT/boot/grub/$menu_file |
|
1168 |
# By default, menu.lst is world-readable, which is not so good if it
|
|
1169 |
# contains a password.
|
|
1170 |
chmod o-r $ROOT/boot/grub/$menu_file |
|
1171 |
rm -f /tmp/menu.lst.password |
|
1172 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
1173 |
fi
|
1174 |
||
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1175 |
bootdev_directory="" |
44
by Colin Watson
* Hide GRUB menu if grub-installer/bootdev_directory is preseeded; this is |
1176 |
hide_menu="" |
24
by Colin Watson
Support grub-installer/bootdev_directory preseeding to make use of the |
1177 |
if db_get grub-installer/bootdev_directory && [ "$RET" ]; then |
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1178 |
bootdev_directory="$RET" |
40
by Colin Watson
Cope with new UUID-style groot when handling |
1179 |
# Be careful to deal with either UUID-style or non-UUID-style groot.
|
41
by Colin Watson
grub4dos can't handle UUIDs, so tweak previous change to continue using |
1180 |
# grub4dos doesn't recognise UUIDs yet.
|
1181 |
sed -i "s:^\(# groot=\)[^(].*:\1():; s:^\(# groot=([^)]*)\).*:\1$bootdev_directory:" $ROOT/boot/grub/$menu_file |
|
44
by Colin Watson
* Hide GRUB menu if grub-installer/bootdev_directory is preseeded; this is |
1182 |
hide_menu=1 |
24
by Colin Watson
Support grub-installer/bootdev_directory preseeding to make use of the |
1183 |
fi
|
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
1184 |
if [ "$grub_version" = grub ]; then |
1185 |
# Add user parameters to menu.lst; some options are only added to
|
|
1186 |
# the default entry for a kernel instead of all entries. We can't do
|
|
1187 |
# this in the same place as the grub2 case because we need the menu
|
|
1188 |
# file to exist.
|
|
80
by Colin Watson
'nosplash' doesn't work because it isn't passed through by user-params. |
1189 |
if db_get debian-installer/splash && [ "$RET" = false ]; then |
79
by Colin Watson
Historically, Ubuntu's default behaviour in the absence of command-line |
1190 |
sed -i 's!^\(# defoptions=.*\) splash\( \|$\)!\1\2!' $ROOT/boot/grub/$menu_file |
1191 |
fi
|
|
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
1192 |
if [ "$defopt_params" ]; then |
1193 |
sed -i "s!^\(# defoptions=.*\)!\1 $defopt_params!" $ROOT/boot/grub/$menu_file |
|
1194 |
fi
|
|
1195 |
if [ "$kopt_params" ]; then |
|
1196 |
sed -i "s!^\(# kopt=.*\)!\1 $kopt_params!" $ROOT/boot/grub/$menu_file |
|
1197 |
fi
|
|
1198 |
# In either case, update the Debian kernel entries
|
|
59
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1199 |
if [ "$user_params" ] || [ "$bootdev_directory" ]; then |
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
1200 |
update_grub |
1201 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
1202 |
fi
|
1203 |
||
83
by Colin Watson, Soren Hansen
[ Soren Hansen ] |
1204 |
if db_get grub-installer/timeout
|
1205 |
then
|
|
1206 |
# Check whether it's a number
|
|
1207 |
if [ "$RET" -eq "$RET" ] 2> /dev/null |
|
1208 |
then
|
|
1209 |
timeout="$RET" |
|
1210 |
fi
|
|
1211 |
fi
|
|
1212 |
||
58
by Colin Watson
Handle showing the menu and raising the timeout for grub2 if other |
1213 |
if [ -z "$hide_menu" ] && [ -s /tmp/os-probed ]; then |
7
by Colin Watson
* Resynchronise with Debian. |
1214 |
# Other operating systems are installed, so show the menu by default
|
1215 |
# and raise the timeout.
|
|
58
by Colin Watson
Handle showing the menu and raising the timeout for grub2 if other |
1216 |
if [ "$grub_version" = grub ]; then |
1217 |
sed -i 's/^hiddenmenu[[:space:]]*$/#hiddenmenu/;
|
|
1218 |
s/^\(timeout[[:space:]][[:space:]]*\).*/\110/' \ |
|
1219 |
$ROOT/boot/grub/menu.lst
|
|
1220 |
else
|
|
1221 |
sed -i 's/^GRUB_HIDDEN_TIMEOUT=.*/#&/;
|
|
1222 |
s/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=10/' \ |
|
1223 |
$ROOT/etc/default/grub
|
|
1224 |
update_grub # propagate to grub.cfg
|
|
1225 |
fi
|
|
83
by Colin Watson, Soren Hansen
[ Soren Hansen ] |
1226 |
elif [ -n "$timeout" ]; then |
1227 |
# Leave a slight delay
|
|
1228 |
if [ "$grub_version" = grub ]; then |
|
1229 |
sed -i 's/^hiddenmenu[[:space:]]*$/#hiddenmenu/;
|
|
1230 |
s/^\(timeout[[:space:]][[:space:]]*\).*/\1'$timeout'/' \ |
|
1231 |
$ROOT/boot/grub/menu.lst
|
|
1232 |
else
|
|
1233 |
sed -i 's/^GRUB_HIDDEN_TIMEOUT=.*/#&/;
|
|
1234 |
s/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT='$timeout'/' \ |
|
1235 |
$ROOT/etc/default/grub
|
|
1236 |
update_grub # propagate to grub.cfg
|
|
1237 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
1238 |
fi
|
1239 |
||
19
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1240 |
if [ "$serial" ] ; then |
1241 |
# Modify menu.lst so _grub_ uses serial console.
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1242 |
case $grub_package in |
1243 |
grub)
|
|
1244 |
(
|
|
1245 |
grub_serial_console $serial
|
|
1246 |
echo "terminal serial" |
|
1247 |
cat $ROOT/boot/grub/$menu_file |
|
1248 |
) >$ROOT/boot/grub/$menu_file.new |
|
1249 |
mv $ROOT/boot/grub/$menu_file.new $ROOT/boot/grub/$menu_file |
|
1250 |
;;
|
|
1251 |
grub-pc)
|
|
1252 |
if grep -q "^GRUB_TERMINAL=" $ROOT/etc/default/grub; then |
|
1253 |
sed -i $ROOT/etc/default/grub -e "s/^\(GRUB_TERMINAL\)=.*/\1=serial/g" |
|
1254 |
else
|
|
1255 |
echo "GRUB_TERMINAL=serial" >> $ROOT/etc/default/grub |
|
1256 |
fi
|
|
1257 |
if grep -q "^GRUB_SERIAL_COMMAND=" $ROOT/etc/default/grub ; then |
|
74
by Evan Dandrea, Joel Ebel
[ Joel Ebel ] |
1258 |
sed -i $ROOT/etc/default/grub -e "s/^\(GRUB_SERIAL_COMMAND\)=.*/\1=\"`grub_serial_console $serial`\"/g" |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1259 |
else
|
74
by Evan Dandrea, Joel Ebel
[ Joel Ebel ] |
1260 |
echo "GRUB_SERIAL_COMMAND=\"`grub_serial_console $serial`\"" >> $ROOT/etc/default/grub |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1261 |
fi
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1262 |
update_grub # propagate to grub.cfg
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1263 |
;;
|
1264 |
esac
|
|
19
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1265 |
fi
|
1266 |
||
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1267 |
# Generate menu.lst additions for other OSes
|
7
by Colin Watson
* Resynchronise with Debian. |
1268 |
tmpfile=/tmp/menu.lst.extras |
1269 |
OLDIFS="$IFS" |
|
1270 |
IFS="$newline" |
|
55
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1271 |
|
1272 |
no_floppy="" |
|
1273 |
if $chroot $ROOT dpkg --compare-versions $grub_debian_version ge 1.96+20090609-1 ; then |
|
1274 |
no_floppy="--no-floppy" |
|
1275 |
fi
|
|
1276 |
||
7
by Colin Watson
* Resynchronise with Debian. |
1277 |
for os in $(cat /tmp/os-probed); do |
1278 |
IFS="$OLDIFS" |
|
1279 |
title=$(echo "$os" | cut -d: -f2) |
|
1280 |
shortname=$(echo "$os" | cut -d: -f3) |
|
1281 |
type=$(echo "$os" | cut -d: -f4) |
|
1282 |
case "$type" in |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1283 |
chain)
|
1284 |
partition=$(mapdevfs $(echo "$os" | cut -d: -f1)) |
|
1285 |
grubdrive=$(convert "$partition") || true |
|
1286 |
if [ -n "$grubdrive" ]; then |
|
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
1287 |
case $grub_version in |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1288 |
grub) grub_write_chain ;; |
0.2.10
by Robert Millan, Otavio Salvador, Colin Watson, Robert Millan, Updated translations
[ Otavio Salvador ] |
1289 |
grub2) grub2_write_chain ;; |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1290 |
esac
|
1291 |
fi
|
|
7
by Colin Watson
* Resynchronise with Debian. |
1292 |
;;
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1293 |
linux)
|
1294 |
partition=$(echo "$os" | cut -d: -f1) |
|
1295 |
mappedpartition=$(mapdevfs "$partition") |
|
1296 |
IFS="$newline" |
|
1297 |
for entry in $(linux-boot-prober "$partition"); do |
|
7
by Colin Watson
* Resynchronise with Debian. |
1298 |
IFS="$OLDIFS" |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1299 |
bootpart=$(echo "$entry" | cut -d: -f2) |
1300 |
mappedbootpart=$(mapdevfs "$bootpart") || true |
|
1301 |
if [ -z "$mappedbootpart" ]; then |
|
1302 |
mappedbootpart="$bootpart" |
|
1303 |
fi
|
|
1304 |
label=$(echo "$entry" | cut -d : -f3) |
|
1305 |
if [ -z "$label" ]; then |
|
1306 |
label="$title" |
|
1307 |
fi
|
|
1308 |
kernel=$(echo "$entry" | cut -d : -f4) |
|
1309 |
initrd=$(echo "$entry" | cut -d : -f5) |
|
1310 |
if echo "$kernel" | grep -q '^/boot/' && \ |
|
1311 |
[ "$mappedbootpart" != "$mappedpartition" ]; then |
|
33
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1312 |
# separate /boot partition
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1313 |
kernel=$(echo "$kernel" | sed 's!^/boot!!') |
1314 |
initrd=$(echo "$initrd" | sed 's!^/boot!!') |
|
1315 |
grubdrive=$(convert "$mappedbootpart") || true |
|
1316 |
else
|
|
1317 |
grubdrive=$(convert "$mappedpartition") || true |
|
1318 |
fi
|
|
1319 |
params="$(echo "$entry" | cut -d : -f6-) $serial" |
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1320 |
case $grub_version in |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1321 |
grub) grub_write_linux ;; |
1322 |
grub2) grub2_write_linux ;; |
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1323 |
esac
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1324 |
IFS="$newline" |
1325 |
done
|
|
1326 |
IFS="$OLDIFS" |
|
1327 |
;;
|
|
1328 |
hurd)
|
|
1329 |
partition=$(mapdevfs $(echo "$os" | cut -d: -f1)) |
|
1330 |
grubdrive=$(convert "$partition") || true |
|
1331 |
hurddrive=$(hurd_convert "$partition") || true |
|
1332 |
# Use the standard hurd boilerplate to boot it.
|
|
1333 |
case $grub_version in |
|
1334 |
grub) grub_write_hurd ;; |
|
1335 |
grub2) grub2_write_hurd ;; |
|
1336 |
esac
|
|
1337 |
;;
|
|
1338 |
*)
|
|
1339 |
info "unhandled: $os" |
|
7
by Colin Watson
* Resynchronise with Debian. |
1340 |
;;
|
1341 |
esac
|
|
1342 |
IFS="$newline" |
|
1343 |
done
|
|
1344 |
IFS="$OLDIFS" |
|
1345 |
rm -f /tmp/os-probed |
|
1346 |
||
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1347 |
if [ -s $tmpfile ] ; then |
1348 |
case $grub_version in |
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1349 |
grub)
|
63
by Colin Watson
* Fix some hardcoded uses of /target. |
1350 |
grub_write_divider |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1351 |
cat $tmpfile >> $ROOT/boot/grub/$menu_file |
1352 |
;;
|
|
1353 |
grub2)
|
|
0.1.11
by Felix Zielcke, Colin Watson, Felix Zielcke
[ Colin Watson ] |
1354 |
if ! $chroot $ROOT which os-prober >/dev/null 2>&1; then |
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
1355 |
cat > $ROOT/etc/grub.d/30_otheros << EOF |
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1356 |
#!/bin/sh
|
1357 |
exec tail -n +3 \$0
|
|
1358 |
EOF
|
|
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
1359 |
cat $tmpfile >> $ROOT/etc/grub.d/30_otheros |
1360 |
chmod +x $ROOT/etc/grub.d/30_otheros
|
|
1361 |
update_grub # propagate 30_otheros to grub.cfg
|
|
1362 |
fi
|
|
26
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1363 |
;;
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1364 |
esac
|
7
by Colin Watson
* Resynchronise with Debian. |
1365 |
rm -f $tmpfile
|
1366 |
fi
|
|
1367 |
||
1368 |
db_progress STEP 1
|
|
1369 |
db_progress INFO grub-installer/progress/step_update_etc |
|
1370 |
||
0.1.8
by Colin Watson, Felix Zielcke, Colin Watson, Updated translations
[ Felix Zielcke ] |
1371 |
if [ -e $ROOT/etc/kernel-img.conf ] ; then |
1372 |
sed -i 's/do_bootloader = yes/do_bootloader = no/' $ROOT/etc/kernel-img.conf |
|
1373 |
fi
|
|
0.2.8
by Colin Watson, Updated translations
* Only set postinst_hook and postrm_hook in /etc/kernel-img.conf if |
1374 |
if [ ! -e $ROOT/etc/kernel/postinst.d/zz-update-grub ] && \ |
1375 |
[ -z "$(grep update-grub $ROOT/etc/kernel-img.conf)" ]; then |
|
7
by Colin Watson
* Resynchronise with Debian. |
1376 |
(
|
18
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1377 |
echo "postinst_hook = update-grub" |
1378 |
echo "postrm_hook = update-grub" |
|
19
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
1379 |
) >> $ROOT/etc/kernel-img.conf |
7
by Colin Watson
* Resynchronise with Debian. |
1380 |
fi
|
1381 |
||
1382 |
db_progress STEP 1
|
|
1383 |
db_progress STOP |