Lines 6-11
PROG="alterator-lilo"
Link Here
|
6 |
destdir="@DESTROOTDIR@" |
6 |
destdir="@DESTROOTDIR@" |
7 |
lilo_template="@INSTALL3_DATA@/lilo.conf.template" |
7 |
lilo_template="@INSTALL3_DATA@/lilo.conf.template" |
8 |
lilo_conf_new="/tmp/lilo.conf" |
8 |
lilo_conf_new="/tmp/lilo.conf" |
|
|
9 |
blkid_args="-c /dev/null -w /dev/null" |
9 |
|
10 |
|
10 |
workdir= |
11 |
workdir= |
11 |
sections= |
12 |
sections= |
Lines 77-83
convert_bootdev() {
Link Here
|
77 |
device_exists "$bootdev" || return 1 |
78 |
device_exists "$bootdev" || return 1 |
78 |
fi |
79 |
fi |
79 |
|
80 |
|
80 |
if ! boot_uuid="UUID=$(/sbin/blkid -o value -s UUID "$bootdev" 2>/dev/null)"; then |
81 |
if ! boot_uuid="UUID=$(/sbin/blkid $blkid_args -o value -s UUID "$bootdev" 2>/dev/null)"; then |
81 |
error "$bootdev: Unable to get UUID" |
82 |
error "$bootdev: Unable to get UUID" |
82 |
return 1 |
83 |
return 1 |
83 |
fi |
84 |
fi |
Lines 89-95
convert_bootdev() {
Link Here
|
89 |
sed -i -e "s#^boot=.*#boot=\"$bootdev\"#" "$lilo_conf" |
90 |
sed -i -e "s#^boot=.*#boot=\"$bootdev\"#" "$lilo_conf" |
90 |
} |
91 |
} |
91 |
|
92 |
|
|
|
93 |
partitions_list() { |
94 |
sfdisk -l 2>/dev/null | |
95 |
sed -r -e '\#^/dev/#!d' \ |
96 |
-e 's#[[:space:]]+# #g' \ |
97 |
-e 's#^(/dev/[^[:space:]]+) ([[:digit:]])#\1 x \2#' |
98 |
} |
99 |
|
100 |
set_bootable() { |
101 |
local boot="$1" |
102 |
|
103 |
if [ -z "$boot" ]; then |
104 |
debug "$fn: Something wrong! first argument is emply" |
105 |
return 0 |
106 |
fi |
107 |
device_exists "$boot" || return 0 |
108 |
|
109 |
local dev= num= |
110 |
|
111 |
dev="$(printf %s "$boot" |sed -r -e 's,^(/dev/.*[^0-9])[0-9]+$,\1,')" |
112 |
device_exists "$dev" || return 0 |
113 |
|
114 |
num="$(printf %s "$boot" |sed -r -e 's,^/dev/.*[^0-9]([0-9]+)$,\1,')" |
115 |
[ -n "$num" ] || return 0 |
116 |
|
117 |
debug "set_bootable(): set bootable flag on '$boot' partittion (dev='$dev', num='$num')" |
118 |
sfdisk "$dev" -A "$num" |
119 |
} |
120 |
|
121 |
bootable_flag() { |
122 |
local bootdev="/dev/${1#/dev/}" |
123 |
|
124 |
if sfdisk -s |cut -d: -f1 |grep -xqs "$bootdev"; then |
125 |
local firstdev= plist= |
126 |
|
127 |
plist="`partitions_list |grep "^$bootdev" |cut -d\ -f1,2`" |
128 |
printf %s "$plist" |grep -qs '[[:space:]]\*$' && |
129 |
return 0 |
130 |
|
131 |
firstdev="`printf %s "$plist" cut -d\ -f1 |head -1`" |
132 |
|
133 |
set_bootable "$firstdev" |
134 |
fi |
135 |
|
136 |
sfdisk -l 2>/dev/null |grep -qs "^$bootdev[[:space:]]" || |
137 |
return 0 |
138 |
|
139 |
set_bootable "$bootdev" |
140 |
} |
141 |
|
92 |
write_liloconf() { |
142 |
write_liloconf() { |
|
|
143 |
local bootdev="$(sed -r -n -e 's,^boot=\"([^\"]+)\",\1,p' "$lilo_conf_new")" |
144 |
|
93 |
convert_bootdev "$lilo_conf_new" || return 1 |
145 |
convert_bootdev "$lilo_conf_new" || return 1 |
94 |
|
146 |
|
95 |
if ! out="$(lilo -t -C "$lilo_conf_new" 2>&1 >/dev/null)"; then |
147 |
if ! out="$(lilo -t -C "$lilo_conf_new" 2>&1 >/dev/null)"; then |
Lines 99-105
write_liloconf() {
Link Here
|
99 |
debug "write_liloconf(): lilo test passed" |
151 |
debug "write_liloconf(): lilo test passed" |
100 |
[ ! -f /etc/lilo.conf ] || mv -f -- /etc/lilo.conf /etc/lilo.conf.save |
152 |
[ ! -f /etc/lilo.conf ] || mv -f -- /etc/lilo.conf /etc/lilo.conf.save |
101 |
mv -f -- "$lilo_conf_new" /etc/lilo.conf |
153 |
mv -f -- "$lilo_conf_new" /etc/lilo.conf |
102 |
lilo >/dev/null 2>&1 |
154 |
lilo >/dev/null 2>&1 && bootable_flag "$bootdev" |
103 |
} |
155 |
} |
104 |
|
156 |
|
105 |
write_section() { |
157 |
write_section() { |
Lines 291-301
find_others() {
Link Here
|
291 |
done < /proc/mounts |
343 |
done < /proc/mounts |
292 |
debug "exclude='$exclude'" |
344 |
debug "exclude='$exclude'" |
293 |
|
345 |
|
294 |
fdisk -l 2>/dev/null | |
346 |
partitions_list | |
295 |
sed -r \ |
|
|
296 |
-e '\#^/dev/#!d' \ |
297 |
-e 's#[[:space:]]+# #g' \ |
298 |
-e 's#^(/dev/[^[:space:]]+) ([[:digit:]])#\1 x \2#' | |
299 |
while read dev boot start end blocks id system; do |
347 |
while read dev boot start end blocks id system; do |
300 |
# We need only bootable partitions |
348 |
# We need only bootable partitions |
301 |
[ "$boot" = "*" ] || continue |
349 |
[ "$boot" = "*" ] || continue |