Codebase list partman-auto / 0aa0266
Simplify the logic of the main partman script. Rename auto.d as display.d. Document display.d and check.d in partman-doc.sgml r48612 Anton Zinoviev 16 years ago
7 changed file(s) with 133 addition(s) and 129 deletion(s). Raw diff Collapse all Expand all
+0
-1
auto.d/_numbers less more
0 10 initial_auto
+0
-126
auto.d/initial_auto less more
0 #!/bin/sh
1
2 . /usr/share/debconf/confmodule
3 . /lib/partman/definitions.sh
4 . /lib/partman/auto-shared.sh
5
6 dev_to_partman () {
7 local dev_name="$1"
8
9 local mapped_dev_name="$(mapdevfs $dev_name)"
10 if [ -n "$mapped_dev_name" ]; then
11 dev_name="$mapped_dev_name"
12 fi
13
14 for dev in $DEVICES/*; do
15 [ -d "$dev" ] || continue
16
17 # mapdevfs both to allow for different ways to refer to the
18 # same device using devfs, and to allow user input in
19 # non-devfs form
20 if [ "$(mapdevfs $(cat $dev/device))" = "$dev_name" ]; then
21 echo $dev
22 fi
23 done
24 }
25
26 # Skip if no disks detected and don't run on S/390
27 if [ -z "$(get_auto_disks)" ] || \
28 [ "$(udpkg --print-architecture)" = s390 ]; then
29 exit 0
30 fi
31
32 # Only run the first time
33 if [ -f /var/lib/partman/initial_auto ]; then
34 exit 0
35 fi
36 [ -d /var/lib/partman ] || mkdir /var/lib/partman
37 touch /var/lib/partman/initial_auto
38
39 # See if any autopartition method has been set
40 method=""
41 if db_get partman-auto/method && [ "$RET" ]; then
42 method="$RET"
43 fi
44
45 # See if any autopartition disks have been set
46 disks=""
47 if db_get partman-auto/disk && [ "$RET" ]; then
48 disks="$RET"
49 fi
50
51 # If there's only one disk, then preseeding partman-auto/disk is
52 # unnecessary, and sometimes inconvenient in heterogeneous environments
53 if [ "$method" ] && [ -z "$disks" ]; then
54 DEVS="$(get_auto_disks)"
55 if [ "$(echo "$DEVS" | wc -l)" -eq 1 ]; then
56 disks="$(cat "${DEVS%$TAB*}"/device)"
57 fi
58 fi
59
60 # If both are set, let's try to do a completely automatic partitioning
61 if [ "$method" ] && [ "$disks" ]; then
62 # The code for the methods could be merged, but in the future non-regular
63 # methods may support multiple disks
64 case "$method" in
65 regular)
66 for disk in $disks; do
67 id=$(dev_to_partman "$disk") || true
68 if [ -n "$id" ]; then
69 autopartition "$id"
70 exit 0
71 fi
72 done
73 exit 1
74 ;;
75 lvm)
76 search-path autopartition-lvm || exit 1
77 for disk in $disks; do
78 id=$(dev_to_partman "$disk") || true
79 if [ -n "$id" ]; then
80 autopartition-lvm "$id"
81 exit 0
82 fi
83 done
84 exit 1
85 ;;
86 crypto)
87 search-path autopartition-crypto || exit 1
88 for disk in $disks; do
89 id=$(dev_to_partman "$disk") || true
90 if [ -n "$id" ]; then
91 autopartition-crypto "$id"
92 exit 0
93 fi
94 done
95 exit 1
96 ;;
97 raid)
98 # Partition all the disks given ready for
99 # partman-auto-raid
100 for disk in $disks; do
101 id=$(dev_to_partman "$disk") || true
102 if [ -n "$id" ]; then
103 autopartition "$id"
104 fi
105 done
106 exit 0
107 ;;
108 *)
109 logger -t partman-auto "Unsupported method '$method'"
110 exit 1
111 ;;
112 esac
113 fi
114
115 echo "partman-auto/init_automatically_partition" > /lib/partman/automatically_partition/question
116 code=99 # signals a retry
117 while [ $code = 99 ]; do
118 ask_user /lib/partman/automatically_partition
119 code=$?
120 done
121 if [ $code -lt 100 ]; then
122 rm -f /var/lib/partman/initial_auto # try again
123 fi
124 echo "partman-auto/automatically_partition" > /lib/partman/automatically_partition/question
125 exit $code
99 # 255: backup from subsidiary question; break and return to
1010 # choose_partition menu
1111 # 100-254: attempt to skip the manual partitioner (from
12 # auto.d), which isn't appropriate if the manual partitioner
12 # display.d), which isn't appropriate if the manual partitioner
1313 # has already been displayed, so treat this exactly like
1414 # backup
1515 exit 0
77 * Fix divide-by-zero error if the sum of the factors in the scheme is
88 equal to the sum of the minimum sizes, or if we run off the maximum size
99 of the recipe before we run out of disk to allocate.
10
11 [ Anton Zinoviev ]
12 * Rename auto.d to display.d.
1013
1114 -- Frans Pop <[email protected]> Sun, 13 May 2007 04:05:45 +0200
1215
3636 debian/install-rc choose_partition
3737 debian/install-rc free_space
3838 debian/install-rc automatically_partition
39 debian/install-rc auto.d
39 debian/install-rc display.d
4040
4141 binary-arch: build install
4242 dh_testdir
0 10 initial_auto
0 #!/bin/sh
1
2 . /lib/partman/definitions.sh
3
4 # Only run the first time
5 if [ -f /var/lib/partman/initial_auto ]; then
6 exit 0
7 fi
8
9 . /lib/partman/auto-shared.sh
10
11 dev_to_partman () {
12 local dev_name="$1"
13
14 local mapped_dev_name="$(mapdevfs $dev_name)"
15 if [ -n "$mapped_dev_name" ]; then
16 dev_name="$mapped_dev_name"
17 fi
18
19 for dev in $DEVICES/*; do
20 [ -d "$dev" ] || continue
21
22 # mapdevfs both to allow for different ways to refer to the
23 # same device using devfs, and to allow user input in
24 # non-devfs form
25 if [ "$(mapdevfs $(cat $dev/device))" = "$dev_name" ]; then
26 echo $dev
27 fi
28 done
29 }
30
31 # Skip if no disks detected and don't run on S/390
32 if [ -z "$(get_auto_disks)" ] || \
33 [ "$(udpkg --print-architecture)" = s390 ]; then
34 exit 0
35 fi
36
37 [ -d /var/lib/partman ] || mkdir /var/lib/partman
38 touch /var/lib/partman/initial_auto
39
40 # See if any autopartition method has been set
41 method=""
42 if db_get partman-auto/method && [ "$RET" ]; then
43 method="$RET"
44 fi
45
46 # See if any autopartition disks have been set
47 disks=""
48 if db_get partman-auto/disk && [ "$RET" ]; then
49 disks="$RET"
50 fi
51
52 # If there's only one disk, then preseeding partman-auto/disk is
53 # unnecessary, and sometimes inconvenient in heterogeneous environments
54 if [ "$method" ] && [ -z "$disks" ]; then
55 DEVS="$(get_auto_disks)"
56 if [ "$(echo "$DEVS" | wc -l)" -eq 1 ]; then
57 disks="$(cat "${DEVS%$TAB*}"/device)"
58 fi
59 fi
60
61 # If both are set, let's try to do a completely automatic partitioning
62 if [ "$method" ] && [ "$disks" ]; then
63 # The code for the methods could be merged, but in the future non-regular
64 # methods may support multiple disks
65 case "$method" in
66 regular)
67 for disk in $disks; do
68 id=$(dev_to_partman "$disk") || true
69 if [ -n "$id" ]; then
70 autopartition "$id"
71 exit 0
72 fi
73 done
74 exit 1
75 ;;
76 lvm)
77 search-path autopartition-lvm || exit 1
78 for disk in $disks; do
79 id=$(dev_to_partman "$disk") || true
80 if [ -n "$id" ]; then
81 autopartition-lvm "$id"
82 exit 0
83 fi
84 done
85 exit 1
86 ;;
87 crypto)
88 search-path autopartition-crypto || exit 1
89 for disk in $disks; do
90 id=$(dev_to_partman "$disk") || true
91 if [ -n "$id" ]; then
92 autopartition-crypto "$id"
93 exit 0
94 fi
95 done
96 exit 1
97 ;;
98 raid)
99 # Partition all the disks given ready for
100 # partman-auto-raid
101 for disk in $disks; do
102 id=$(dev_to_partman "$disk") || true
103 if [ -n "$id" ]; then
104 autopartition "$id"
105 fi
106 done
107 exit 0
108 ;;
109 *)
110 logger -t partman-auto "Unsupported method '$method'"
111 exit 1
112 ;;
113 esac
114 fi
115
116 echo "partman-auto/init_automatically_partition" > /lib/partman/automatically_partition/question
117 code=99 # signals a retry
118 while [ $code = 99 ]; do
119 ask_user /lib/partman/automatically_partition
120 code=$?
121 done
122 if [ $code -lt 100 ]; then
123 rm -f /var/lib/partman/initial_auto # try again
124 fi
125 echo "partman-auto/automatically_partition" > /lib/partman/automatically_partition/question
126 exit $code