/[d-i]/trunk/packages/partman/partman/partman
ViewVC logotype

Contents of /trunk/packages/partman/partman/partman

Parent Directory Parent Directory | Revision Log Revision Log


Revision 20549 - (show annotations) (download)
Wed Sep 1 19:43:26 2004 UTC (8 years, 8 months ago) by joeyh
File size: 4975 byte(s)
  * Resetting questions breaks preseeding, as the preseeded value is lost and
    the question is marked as not seen. So only reset questions after
    displaying them so the preseeding can take effect the first time.
  * Preseeding of eg, partman/confirm will now work.
1 #!/bin/sh
2
3 . /lib/partman/definitions.sh
4
5 abort () {
6 if [ -f /var/run/parted_server.pid ]; then
7 open_infifo
8 write_line "QUIT"
9 close_infifo
10 rm /var/run/parted_server.pid
11 fi
12 exit $1
13 }
14
15 confirm_changes () {
16 local dev x part partitions num id size type fs path name filesystem partitems items formatted_previously
17 # Compute the changes we are going to do
18 partitems=''
19 items=''
20 for dev in $DEVICES/*; do
21 [ -d "$dev" ] || continue
22 cd $dev
23
24 open_dialog IS_CHANGED
25 read_line x
26 close_dialog
27 if [ "$x" = yes ]; then
28 partitems="${partitems} $(humandev $(cat device))
29 "
30 fi
31
32 partitions=
33 open_dialog PARTITIONS
34 while { read_line num id size type fs path name; [ "$id" ]; }; do
35 [ "$fs" != free ] || continue
36 partitions="$partitions $id,$num"
37 done
38 close_dialog
39
40 formatted_previously=no
41 for part in $partitions; do
42 id=${part%,*}
43 num=${part#*,}
44 [ -f $id/method -a -f $id/format \
45 -a -f $id/visual_filesystem ] || continue
46 # if no filesystem (e.g. swap) should either be not
47 # formatted or formatted before the method is specified
48 [ -f $id/filesystem -o ! -f $id/formatted \
49 -o $id/formatted -ot $id/method ] || continue
50 # if it is already formatted filesystem it must be formatted
51 # before the method or filesystem is specified
52 [ ! -f $id/filesystem -o ! -f $id/formatted \
53 -o $id/formatted -ot $id/method \
54 -o $id/formatted -ot $id/filesystem ] ||
55 {
56 formatted_previously=yes
57 continue
58 }
59 filesystem=$(cat $id/visual_filesystem)
60 db_subst partman/text/confirm_item TYPE "$filesystem"
61 db_subst partman/text/confirm_item PARTITION "$num"
62 db_subst partman/text/confirm_item DEVICE $(humandev $(cat device))
63 db_metaget partman/text/confirm_item description
64
65 items="${items} ${RET}
66 "
67 done
68 done
69
70 if [ "$items" ]; then
71 db_metaget partman/text/confirm_item_header description
72 items="$RET
73 $items"
74 fi
75
76 if [ "$partitems" ]; then
77 db_metaget partman/text/confirm_partitem_header description
78 partitems="$RET
79 $partitems"
80 fi
81
82 if [ "$partitems$items" ]; then
83 if [ -z "$items" ]; then
84 x="$partitems"
85 elif [ -z "$partitems" ]; then
86 x="$items"
87 else
88 x="$partitems
89 $items"
90 fi
91 db_subst partman/confirm ITEMS "$x"
92 db_input critical partman/confirm
93 db_go || true
94 db_get partman/confirm
95 if [ "$RET" = false ]; then
96 db_reset partman/confirm
97 return 1
98 else
99 db_reset partman/confirm
100 return 0
101 fi
102 else
103 if [ "$formatted_previously" = no ]; then
104 db_input high partman/confirm_nochanges
105 db_go || true
106 db_get partman/confirm_nochanges
107 if [ "$RET" = false ]; then
108 db_reset partman/confirm_nochanges
109 return 1
110 else
111 db_reset partman/confirm_nochanges
112 return 0
113 fi
114 else
115 return 0
116 fi
117 fi
118 }
119
120 db_capb backup
121
122 # Measure the width of partman/text/number here to make things faster.
123 # number_width is used only in visual.d/number
124 db_metaget partman/text/number description
125 RET=$(printf "$RET" '')
126 RET=$(stralign 50 "$RET" | sed 's/[^ ]//g')
127 number_width=$((2 + 50 - ${#RET}))
128 export number_width
129
130
131 # Here is maybe not a good place to set deci (TODO)
132 #db_metaget partman/text/deci description
133 #deci="$RET"
134 #export deci
135
136 # The comma has special meaning for debconf. Lets force dot untill we
137 # discover where the comma has to be escaped..
138 deci='.'
139
140 #if [ -e /var/lib/partman ]; then
141 # rm -rf /var/lib/partman
142 #fi
143
144 mkdir /var/lib/partman
145
146 while true; do
147
148 initcount=`ls /lib/partman/init.d/* | wc -l`
149 db_progress START 0 $initcount partman/progress/init/title
150 for s in /lib/partman/init.d/*; do
151 if [ -x $s ]; then
152 base=$(basename $s | sed 's/[0-9]*//')
153 echo $base >&2
154 # Not every init script has, or needs, its own progress
155 # template. Add them to slow init scripts only.
156 if ! db_progress INFO partman/progress/init/$base; then
157 db_progress INFO partman/progress/init/fallback
158 fi
159 if ! $s; then
160 db_progress STOP
161 abort 10
162 fi
163 fi
164 db_progress STEP 1
165 done
166 db_progress STOP
167
168 while true; do
169 ask_user /lib/partman/choose_partition
170 exitcode=$?
171 if [ $exitcode -eq 255 ]; then
172 db_subst partman/confirm_abort ITEMS "$items"
173 db_input high partman/confirm_abort
174 db_go || true
175 db_get partman/confirm_abort
176 if [ "$RET" = true ]; then
177 db_reset partman/confirm_abort
178 abort 10 # back up to main menu
179 fi
180 db_reset partman/confirm_abort
181 elif [ $exitcode -ge 100 ] && confirm_changes; then
182 break
183 fi
184 done
185
186 for s in /lib/partman/commit.d/*; do
187 if [ -x $s ]; then
188 $s || continue 2
189 fi
190 done
191
192 for s in /lib/partman/finish.d/*; do
193 if [ -x $s ]; then
194 $s || {
195 status=$?
196 if [ "$status" = 1 ]; then
197 continue 2
198 else
199 abort $status
200 fi
201 }
202 fi
203 done
204
205 break
206 done

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5