Convert BIOS GRUB boot area support to a method, thereby making it
impossible to accidentally put a filesystem on such a partition as well,
and making it simpler to preseed. See #491376. Thanks to Otavio Salvador
for reviewing this.
r60610
Colin Watson
14 years ago
0 | 0 | 10 change_name |
1 | 1 | 65 toggle_bootable |
2 | 2 | 66 change_flags |
3 | 67 toggle_biosgrub | |
4 | 3 | 80 resize |
5 | 4 | 83 copy |
6 | 5 | 87 delete |
0 | #!/bin/sh | |
1 | ||
2 | . /lib/partman/lib/base.sh | |
3 | ||
4 | dev=$1 | |
5 | id=$2 | |
6 | ||
7 | cd $dev | |
8 | ||
9 | valid_biosgrub=no | |
10 | open_dialog VALID_FLAGS $id | |
11 | while { read_line flag; [ "$flag" ]; }; do | |
12 | if [ "$flag" = bios_grub ]; then | |
13 | valid_biosgrub=yes | |
14 | fi | |
15 | done | |
16 | close_dialog | |
17 | ||
18 | [ $valid_biosgrub = yes ] || exit 0 | |
19 | ||
20 | biosgrub=no | |
21 | open_dialog GET_FLAGS $id | |
22 | while { read_line flag; [ "$flag" ]; }; do | |
23 | if [ "$flag" = bios_grub ]; then | |
24 | biosgrub=yes | |
25 | fi | |
26 | done | |
27 | close_dialog | |
28 | ||
29 | db_metaget partman-partitioning/text/biosgrub description | |
30 | description="$RET" | |
31 | ||
32 | if [ $biosgrub = yes ]; then | |
33 | db_metaget partman-partitioning/text/on description | |
34 | printf "nobiosgrub\t%s\${!TAB}%s\n" "$description" "${RET}" | |
35 | else | |
36 | db_metaget partman-partitioning/text/off description | |
37 | printf "biosgrub\t%s\${!TAB}%s\n" "$description" "${RET}" | |
38 | fi |
0 | #!/bin/sh | |
1 | ||
2 | . /lib/partman/lib/base.sh | |
3 | ||
4 | task=$1 | |
5 | dev=$2 | |
6 | id=$3 | |
7 | ||
8 | cd $dev | |
9 | ||
10 | if [ "$task" = biosgrub ]; then | |
11 | open_dialog PARTITION_INFO $id | |
12 | read_line x1 x2 x3 type x5 x6 x7 | |
13 | close_dialog | |
14 | fi | |
15 | ||
16 | new_flags='' | |
17 | open_dialog GET_FLAGS $id | |
18 | while { read_line flag; [ "$flag" ]; }; do | |
19 | if [ "$flag" != bios_grub ]; then | |
20 | if [ "$new_flags" ]; then | |
21 | new_flags="$new_flags | |
22 | $flag" | |
23 | else | |
24 | new_flags="$flag" | |
25 | fi | |
26 | fi | |
27 | done | |
28 | close_dialog | |
29 | ||
30 | if [ $task = biosgrub ]; then | |
31 | new_flags="$new_flags | |
32 | bios_grub" | |
33 | fi | |
34 | ||
35 | open_dialog SET_FLAGS $id | |
36 | write_line "$new_flags" | |
37 | write_line NO_MORE | |
38 | close_dialog | |
39 | ||
40 | partitions='' | |
41 | numparts=1 | |
42 | open_dialog PARTITIONS | |
43 | while { read_line num id size type fs path name; [ "$id" ]; }; do | |
44 | [ "$fs" != free ] || continue | |
45 | partitions="$partitions $id" | |
46 | numparts=$(($numparts + 1)) | |
47 | done | |
48 | close_dialog | |
49 | ||
50 | db_progress START 0 $numparts partman/text/please_wait | |
51 | db_progress INFO partman-partitioning/new_state | |
52 | ||
53 | for id in $partitions; do | |
54 | update_partition $dev $id | |
55 | db_progress STEP 1 | |
56 | done | |
57 | ||
58 | db_progress STOP |
0 | 45 biosgrub |
0 | #!/bin/sh | |
1 | ||
2 | . /lib/partman/lib/base.sh | |
3 | ||
4 | dev=$1 | |
5 | id=$2 | |
6 | ||
7 | cd "$dev" | |
8 | ||
9 | valid_biosgrub=no | |
10 | open_dialog VALID_FLAGS $id | |
11 | while { read_line flag; [ "$flag" ]; }; do | |
12 | if [ "$flag" = bios_grub ]; then | |
13 | valid_biosgrub=yes | |
14 | fi | |
15 | done | |
16 | close_dialog | |
17 | ||
18 | [ "$valid_biosgrub" = yes ] || exit 0 | |
19 | ||
20 | db_metaget partman/method_long/biosgrub description | |
21 | ||
22 | printf "biosgrub\t${RET}\n" |
0 | #!/bin/sh | |
1 | ||
2 | dev=$2 | |
3 | id=$3 | |
4 | ||
5 | mkdir -p $dev/$id | |
6 | ||
7 | echo biosgrub >$dev/$id/method | |
8 | >$dev/$id/bootable | |
9 | ||
10 | rm -f $dev/$id/use_filesystem | |
11 | rm -f $dev/$id/filesystem | |
12 | ||
13 | exit 0 |
0 | 0 | partman-partitioning (71) UNRELEASED; urgency=low |
1 | 1 | |
2 | 2 | * Upgrade to debhelper v7. |
3 | * Convert BIOS GRUB boot area support to a method, thereby making it | |
4 | impossible to accidentally put a filesystem on such a partition as well, | |
5 | and making it simpler to preseed. See #491376. Thanks to Otavio Salvador | |
6 | for reviewing this. | |
3 | 7 | |
4 | 8 | -- Colin Watson <cjwatson@debian.org> Fri, 28 Aug 2009 10:56:22 +0100 |
5 | 9 |
1 | 1 | active_partition lib/partman |
2 | 2 | free_space lib/partman |
3 | 3 | init.d lib/partman |
4 | update.d lib/partman | |
5 | choose_method lib/partman |
215 | 215 | # :sl2: |
216 | 216 | _Description: Name: |
217 | 217 | |
218 | Template: partman-partitioning/text/biosgrub | |
219 | Type: text | |
220 | # :sl3: | |
218 | Template: partman-partitioning/text/bootable | |
219 | Type: text | |
220 | # :sl2: | |
221 | _Description: Bootable flag: | |
222 | ||
223 | Template: partman-partitioning/text/on | |
224 | Type: text | |
225 | # :sl2: | |
226 | _Description: on | |
227 | ||
228 | Template: partman-partitioning/text/off | |
229 | Type: text | |
230 | # :sl2: | |
231 | _Description: off | |
232 | ||
233 | Template: partman-partitioning/text/resize | |
234 | Type: text | |
235 | # :sl2: | |
236 | _Description: Resize the partition (currently ${SIZE}) | |
237 | ||
238 | Template: partman-partitioning/text/copy | |
239 | Type: text | |
240 | # :sl2: | |
241 | _Description: Copy data from another partition | |
242 | ||
243 | Template: partman-partitioning/text/delete | |
244 | Type: text | |
245 | # :sl2: | |
246 | _Description: Delete the partition | |
247 | ||
248 | Template: partman-partitioning/text/new | |
249 | Type: text | |
250 | # :sl2: | |
251 | _Description: Create a new partition | |
252 | ||
253 | Template: partman-partitioning/text/label | |
254 | Type: text | |
255 | # :sl2: | |
256 | _Description: Create a new empty partition table on this device | |
257 | ||
258 | Template: partman/method_long/biosgrub | |
259 | Type: text | |
260 | # :sl5: | |
221 | 261 | # Setting to reserve a small part of the disk for use by BIOS-based bootloaders |
222 | 262 | # such as GRUB. |
223 | _Description: Reserve BIOS boot area: | |
224 | ||
225 | Template: partman-partitioning/text/bootable | |
226 | Type: text | |
227 | # :sl2: | |
228 | _Description: Bootable flag: | |
229 | ||
230 | Template: partman-partitioning/text/on | |
231 | Type: text | |
232 | # :sl2: | |
233 | _Description: on | |
234 | ||
235 | Template: partman-partitioning/text/off | |
236 | Type: text | |
237 | # :sl2: | |
238 | _Description: off | |
239 | ||
240 | Template: partman-partitioning/text/resize | |
241 | Type: text | |
242 | # :sl2: | |
243 | _Description: Resize the partition (currently ${SIZE}) | |
244 | ||
245 | Template: partman-partitioning/text/copy | |
246 | Type: text | |
247 | # :sl2: | |
248 | _Description: Copy data from another partition | |
249 | ||
250 | Template: partman-partitioning/text/delete | |
251 | Type: text | |
252 | # :sl2: | |
253 | _Description: Delete the partition | |
254 | ||
255 | Template: partman-partitioning/text/new | |
256 | Type: text | |
257 | # :sl2: | |
258 | _Description: Create a new partition | |
259 | ||
260 | Template: partman-partitioning/text/label | |
261 | Type: text | |
262 | # :sl2: | |
263 | _Description: Create a new empty partition table on this device | |
264 | ||
263 | _Description: Reserved BIOS boot area | |
264 | ||
265 | Template: partman/method_short/biosgrub | |
266 | Type: text | |
267 | # :sl5: | |
268 | # short variant of 'Reserved BIOS boot area' | |
269 | # Up to 10 character positions | |
270 | _Description: biosgrub | |
271 |
0 | #! /bin/sh | |
1 | ||
2 | # Set method "biosgrub" for all partitions that have the bios_grub flag set. | |
3 | ||
4 | . /lib/partman/lib/base.sh | |
5 | ||
6 | for dev in $DEVICES/*; do | |
7 | [ -d "$dev" ] || continue | |
8 | cd "$dev" | |
9 | partitions= | |
10 | open_dialog PARTITIONS | |
11 | while { read_line num id size type fs path name; [ "$id" ]; }; do | |
12 | if [ "$fs" != free ]; then | |
13 | partitions="$partitions $id" | |
14 | fi | |
15 | done | |
16 | close_dialog | |
17 | ||
18 | for id in $partitions; do | |
19 | biosgrub=no | |
20 | open_dialog GET_FLAGS $id | |
21 | while { read_line flag; [ "$flag" ]; }; do | |
22 | if [ "$flag" = bios_grub ]; then | |
23 | biosgrub=yes | |
24 | # cannot break here | |
25 | fi | |
26 | done | |
27 | close_dialog | |
28 | if [ "$biosgrub" = yes ]; then | |
29 | mkdir -p $id | |
30 | echo biosgrub >$id/method | |
31 | fi | |
32 | done | |
33 | done |
0 | #! /bin/sh | |
1 | ||
2 | # Remove the bios_grub flag for partitions whose method is not biosgrub, and | |
3 | # set it for partitions whose method is biosgrub. | |
4 | ||
5 | . /lib/partman/lib/base.sh | |
6 | ||
7 | dev=$1 | |
8 | num=$2 | |
9 | id=$3 | |
10 | size=$4 | |
11 | type=$5 | |
12 | fs=$6 | |
13 | path=$7 | |
14 | name=$8 | |
15 | ||
16 | cd $dev | |
17 | ||
18 | if [ "$fs" = free ]; then | |
19 | exit 0 | |
20 | fi | |
21 | ||
22 | method= | |
23 | if [ -f "$id/method" ]; then | |
24 | method="$(cat "$id/method")" | |
25 | fi | |
26 | ||
27 | has_biosgrub=no | |
28 | flags='' | |
29 | open_dialog GET_FLAGS "$id" | |
30 | while { read_line flag; [ "$flag" ]; }; do | |
31 | if [ "$flag" != bios_grub ]; then | |
32 | flags="${flags:+$flags$NL}$flag" | |
33 | else | |
34 | has_biosgrub=yes | |
35 | fi | |
36 | done | |
37 | close_dialog | |
38 | ||
39 | if [ "$method" = biosgrub ] && [ "$has_biosgrub" = no ]; then | |
40 | open_dialog SET_FLAGS "$id" | |
41 | write_line "$flags" | |
42 | write_line bios_grub | |
43 | write_line NO_MORE | |
44 | close_dialog | |
45 | elif [ "$method" != biosgrub ] && [ "$has_biosgrub" = yes ]; then | |
46 | open_dialog SET_FLAGS "$id" | |
47 | write_line "$flags" | |
48 | write_line NO_MORE | |
49 | close_dialog | |
50 | fi |
0 | #!/bin/sh | |
1 | ||
2 | . /usr/share/debconf/confmodule | |
3 | ||
4 | dev=$1 | |
5 | num=$2 | |
6 | id=$3 | |
7 | size=$4 | |
8 | type=$5 | |
9 | fs=$6 | |
10 | path=$7 | |
11 | name=$8 | |
12 | ||
13 | cd $dev | |
14 | ||
15 | [ -f $id/method ] || exit 0 | |
16 | method=$(cat $id/method) | |
17 | ||
18 | case "$method" in | |
19 | biosgrub) | |
20 | db_metaget partman/method_short/biosgrub description || RET='' | |
21 | printf "${RET:-biosgrub}" >$id/visual_filesystem | |
22 | >$id/visual_mountpoint | |
23 | ;; | |
24 | esac |