Codebase list partman-auto / b7a54cd
The components of partman added to the official repository. r7449 Anton Zinoviev 20 years ago
24 changed file(s) with 810 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 20 biggest_free
1 50 some_device
2 80 custom
0 #!/bin/sh
1
2 . /lib/partman/definitions.sh
3
4 mypart=''
5 mysize=0
6
7 for dev in $DEVICES/*; do
8 [ -d $dev ] || continue
9 cd $dev
10 open_dialog PARTITIONS
11 while { read_line num id size type fs path name; [ "$id" ]; }; do
12 if [ "$fs" = free ] && ! longint_le $size $mysize; then
13 mysize=$size
14 mypart=$dev//$id
15 fi
16 done
17 close_dialog
18 done
19
20 if [ "$mypart" ]; then
21 db_metaget partman-auto/text/use_biggest_free description
22 printf "$mypart\t$RET"
23 fi
0 #!/bin/sh
1
2 dev=${1%//*}
3 id=${1#*//}
4
5 autopartition $dev $id
6
0 #!/bin/sh
1
2 . /lib/partman/definitions.sh
3
4 db_metaget partman-auto/text/custom_partitioning description
5 printf "custom\t$RET"
0 partman-auto/automatically_partition
0 #!/bin/sh
1
2 . /lib/partman/definitions.sh
3
4 mypart=''
5 mysize=0
6
7 for dev in $DEVICES/*; do
8 [ -d "$dev" ] || continue
9 db_subst partman-auto/text/use_device DEVICE $(device_name $dev)
10 db_metaget partman-auto/text/use_device description
11 printf "$dev\t$RET"
12 done
13
14
0 #!/bin/sh
1
2 . /lib/partman/definitions.sh
3
4 dev=$1
5
6 cd $dev
7 open_dialog NEW_LABEL msdos # FIXME: defaults for non-i386
8 close_dialog
9
10 # Different types partition tables support different visuals. Some
11 # have partition names other don't have, some have extended and
12 # logical partitions, others don't. Hence we have to regenerate the
13 # list of the visuals
14 if [ -f visuals ]; then
15 rm visuals
16 fi
17
18 myfreespace=''
19 open_dialog PARTITIONS
20 while { read_line num id size type fs path name; [ "$id" ]; }; do
21 if [ "$fs" = free ]; then
22 myfreespace=$id
23 fi
24 done
25 close_dialog
26
27 autopartition $dev $myfreespace
28
0 #!/bin/sh
1
2 . /lib/partman/definitions.sh
3
4 # If you are curious why partman-auto is so slow, it is because
5 # update-all is slow
6 update_all () {
7 local dev num id size type fs path name partitions
8 for dev in $DEVICES/*; do
9 [ -d "$dev" ] || continue
10 cd $dev
11 partitions=''
12 open_dialog PARTITIONS
13 while { read_line num id size type fs path name; [ "$id" ]; }; do
14 partitions="$partitions $id"
15 done
16 close_dialog
17 for id in $partitions; do
18 update_partition $dev $id
19 done
20 done
21 }
22
23 autopartitioning_failed () {
24 db_fset partman-auto/autopartitioning_failed seen false
25 db_input critical partman-auto/autopartitioning_failed || true
26 db_go || true
27 update_all
28 exit 1
29 }
30
31 unnamed=0
32
33 decode_recipe () {
34 local ram line word min factor max fs -
35 unnamed=$(($unnamed + 1))
36 ram=$(cat /proc/meminfo | grep ^Mem: | { read x y z; echo $y; }) # in bytes
37 ram=$(expr 000000"$ram" : '0*\(.*\)......$') # convert to megabytes
38 name="Unnamed.${unnamed}"
39 scheme=''
40 line=''
41 for word in $(cat $1); do
42 case $word in
43 :)
44 name=$line
45 line=''
46 ;;
47 ::)
48 db_metaget $line description
49 if [ "$RET" ]; then
50 name=$RET
51 else
52 name="Unnamed.${unnamed}"
53 fi
54 line=''
55 ;;
56 .)
57 # correct errors in order not to crash parted_server
58 set -- $line
59 if expr "$1" : '[0-9][0-9]*$' >/dev/null; then
60 min=$1
61 elif expr "$1" : '[0-9][0-9]*%$' >/dev/null; then
62 min=$(($ram * ${1%?} / 100))
63 else
64 min=2200000000
65 fi
66 if expr "$2" : '[0-9][0-9]*%$' >/dev/null; then
67 factor=$(($ram * ${2%?} / 100))
68 elif expr "$2" : '[0-9][0-9]*$' >/dev/null; then
69 factor=$2
70 else
71 factor=$min
72 fi
73 if [ "$factor" -lt "$min" ]; then
74 factor="$min"
75 fi
76 if expr "$3" : '[0-9][0-9]*$' >/dev/null; then
77 max=$3
78 elif expr "$3" : '[0-9][0-9]*%$' >/dev/null; then
79 max=$(($ram * ${3%?} / 100))
80 else
81 max=$min
82 fi
83 if [ "$max" -lt "$min" ]; then
84 max="$min"
85 fi
86 case "$4" in
87 ext2|ext3|linux-swap|fat16|fat32)
88 fs="$4"
89 ;;
90 *)
91 fs=ext2
92 ;;
93 esac
94 shift; shift; shift; shift
95 line="$min $factor $max $fs $*"
96 if [ "$scheme" ]; then
97 scheme="${scheme}${NL}${line}"
98 else
99 scheme="$line"
100 fi
101 line=''
102 ;;
103 *)
104 if [ "$line" ]; then
105 line="$line $word"
106 else
107 line="$word"
108 fi
109 esac
110 done
111 }
112
113 foreach_partition () {
114 local - doing IFS partition former last
115 doing=$1
116 IFS="$NL"
117 former=''
118 for partition in $scheme; do
119 restore_ifs
120 if [ "$former" ]; then
121 set -- $former
122 last=no
123 eval "$doing"
124 fi
125 former="$partition"
126 done
127 if [ "$former" ]; then
128 set -- $former
129 last=yes
130 eval "$doing"
131 fi
132 }
133
134 min_size () {
135 local size
136 size=0
137 foreach_partition '
138 size=$(($size + $1))'
139 echo $size
140 }
141
142 factor_sum () {
143 local factor
144 factor=0
145 foreach_partition '
146 factor=$(($factor + $2))'
147 echo $factor
148 }
149
150 partition_before () {
151 local num id size type fs path name result found
152 result=''
153 found=no
154 open_dialog PARTITIONS
155 while { read_line num id size type fs path name; [ "$id" ]; }; do
156 if [ "$id" = "$1" ]; then
157 found=yes
158 fi
159 if [ $found = no ]; then
160 result=$id
161 fi
162 done
163 close_dialog
164 echo $result
165 }
166
167 partition_after () {
168 local num id size type fs path name result found
169 result=''
170 found=no
171 open_dialog PARTITIONS
172 while { read_line num id size type fs path name; [ "$id" ]; }; do
173 if [ $found = yes -a -z "$result" ]; then
174 result=$id
175 fi
176 if [ "$id" = "$1" ]; then
177 found=yes
178 fi
179 done
180 close_dialog
181 echo $result
182 }
183
184 pull_primary () {
185 primary=''
186 secondary=''
187 foreach_partition '
188 if
189 [ -z "$primary" ] \
190 && echo $* | grep '\''\$primary{'\'' >/dev/null
191 then
192 primary="$*"
193 else
194 if [ -z "$secondary" ]; then
195 secondary="$*"
196 else
197 secondary="${secondary}${NL}$*"
198 fi
199 fi'
200 }
201
202 setup_partition () {
203 local id flags file line
204 id=$1; shift
205 while [ "$1" ]; do
206 case "$1" in
207 \$bootable{)
208 while [ "$1" != '}' -a "$1" ]; do
209 shift
210 done
211 open_dialog GET_FLAGS $id
212 flags=$(read_paragraph)
213 close_dialog
214 open_dialog SET_FLAGS $id
215 write_line "$flags"
216 write_line boot
217 write_line NO_MORE
218 close_dialog
219 ;;
220 \$*{)
221 while [ "$1" != '}' -a "$1" ]; do
222 shift
223 done
224 ;;
225 *{)
226 file=${1%?}
227 [ -d $id ] || mkdir $id
228 >$id/$file
229 shift
230 line=''
231 while [ "$1" != '}' -a "$1" ]; do
232 if [ "$1" = ';' ]; then
233 echo "$line" >>$id/$file
234 else
235 if [ "$line" ]; then
236 line="$line $1"
237 else
238 line="$1"
239 fi
240 fi
241 shift
242 done
243 echo "$line" >>$id/$file
244 esac
245 shift
246 done
247 return 0
248 }
249
250 # Let us be safe and update the directories
251 update_all
252
253 dev=$1
254 free_space=$2
255
256 cd $dev
257 open_dialog PARTITION_INFO $free_space
258 read_line x1 x2 free_size free_type x3 x4 x5
259 close_dialog
260
261 if [ "$free_type" = unusable ]; then
262 db_fset partman-auto/unusable_space seen false
263 db_input critical partman-auto/unusable_space || true
264 db_go || true
265 exit 1
266 fi
267
268 free_size=$(expr 000000"$free_size" : '0*\(.*\)......$') # convert to megabytes
269
270 choices=''
271 for recipe in /lib/partman/recipes/*; do
272 [ -f "$recipe" ] || continue
273 decode_recipe $recipe
274 if [ $(min_size) -le $free_size ]; then
275 choices="${choices}${recipe}${TAB}${name}${NL}"
276 fi
277 done
278
279 db_metaget partman-auto/text/expert_recipe description
280 choices="${choices}expert${TAB}${RET}"
281
282 db_fset partman-auto/choose_recipe seen false
283 debconf_select high partman-auto/choose_recipe "$choices" no_default
284 if [ "$?" = 255 ]; then
285 exit 0
286 fi
287
288 case $RET in
289 expert)
290 db_fset partman-auto/expert_recipe seen false
291 db_input critical partman-auto/expert_recipe || true
292 if ! db_go; then
293 exit 1
294 fi
295 decode_recipe $RET
296 ;;
297 *)
298 decode_recipe $RET
299 ;;
300 esac
301
302
303 # Make factors small numbers so we can multiply on them.
304 # Also ensure that fact, max and fs are valid
305 # (Ofcourse in valid recipes they must be valid.)
306 factsum=$(($(factor_sum) - $(min_size)))
307 scheme=$(
308 foreach_partition '
309 local min fact max fs
310 min=$1
311 fact=$((($2 - $min) * 100 / $factsum))
312 max=$3
313 fs=$4
314 case "$fs" in
315 ext2|ext3|linux-swap|fat16|fat32)
316 true
317 ;;
318 *)
319 fs=ext2
320 ;;
321 esac
322 shift; shift; shift; shift
323 echo $min $fact $max $fs $*'
324 )
325
326 oldscheme=''
327 while [ "$scheme" != "$oldscheme" ]; do
328 oldscheme="$scheme"
329 factsum=$(factor_sum)
330 unallocated=$(($free_size - $(min_size)))
331 if [ $unallocated -lt 0 ]; then
332 unallocated=0
333 fi
334 scheme=$(
335 foreach_partition '
336 local min fact max newmin
337 min=$1
338 fact=$2
339 max=$3
340 shift; shift; shift
341 newmin=$(($min + $unallocated * $fact / $factsum))
342 if [ $newmin -le $max ]; then
343 echo $newmin $fact $max $*
344 else
345 echo $max 0 $max $*
346 fi'
347 )
348 done
349
350 while
351 [ "$free_type" = pri/log ] \
352 && echo $scheme | grep '\$primary{' >/dev/null
353 do
354 pull_primary
355 set -- $primary
356 open_dialog NEW_PARTITION primary $4 $free_space beginning ${1}000001
357 read_line num id size type fs path name
358 close_dialog
359 if [ -z "$id" ]; then
360 autopartitioning_failed
361 fi
362 neighbour=$(partition_after $id)
363 if [ "$neighbour" ]; then
364 open_dialog PARTITION_INFO $neighbour
365 read_line x1 new_free_space x2 new_free_type fs x3 x4
366 close_dialog
367 fi
368 if
369 [ -z "$neighbour" -o "$fs" != free -o "$new_free_type" = unusable ]
370 then
371 open_dialog DELETE_PARTITION $id
372 close_dialog
373 open_dialog NEW_PARTITION primary $4 $free_space end ${1}000001
374 read_line num id size type fs path name
375 close_dialog
376 if [ -z "$id" ]; then
377 autopartitioning_failed
378 fi
379 neighbour=$(partition_before $id)
380 if [ "$neighbour" ]; then
381 open_dialog PARTITION_INFO $neighbour
382 read_line x1 new_free_space x2 new_free_type fs x3 x4
383 close_dialog
384 fi
385 if
386 [ -z "$neighbour" -o "$fs" != free -o "$new_free_type" = unusable ]
387 then
388 open_dialog DELETE_PARTITION $id
389 close_dialog
390 autopartitioning_failed
391 fi
392 fi
393 shift; shift; shift; shift
394 setup_partition $id $*
395 primary=''
396 scheme="$secondary"
397 free_space=$new_free_space
398 free_type="$new_free_type"
399 done
400
401 foreach_partition '
402 if [ -z "$free_space" ]; then
403 autopartitioning_failed
404 fi
405 open_dialog PARTITION_INFO $free_space
406 read_line x1 free_space x2 free_type fs x3 x4
407 close_dialog
408 if [ "$fs" != free ]; then
409 free_type=unusable
410 fi
411 case "$free_type" in
412 primary|logical)
413 type="$free_type"
414 ;;
415 pri/log)
416 type=logical
417 ;;
418 unusable)
419 autopartitioning_failed
420 ;;
421 esac
422 if [ "$last" = yes ]; then
423 open_dialog NEW_PARTITION $type $4 $free_space full ${1}000001
424 else
425 open_dialog NEW_PARTITION $type $4 $free_space beginning ${1}000001
426 fi
427 read_line num id size type fs path name
428 close_dialog
429 if [ -z "$id" ]; then
430 autopartitioning_failed
431 fi
432 shift; shift; shift; shift
433 setup_partition $id $*
434 free_space=$(partition_after $id)'
435
436 update_all
0 #!/bin/sh
1
2 . /usr/share/debconf/confmodule
3
4
5 db_metaget partman-auto/text/automatically_partition description
6 printf "auto\t$RET"
7
0 #!/bin/sh
1
2 . /lib/partman/definitions.sh
3
4 ask_user /lib/partman/automatically_partition || true
5
0 partman-auto (1) unstable; urgency=low
1
2 * First version.
3
4 -- Anton Zinoviev <[email protected]> Sat, 3 Jan 2004 18:28:41 +0200
0 Source: partman-auto
1 Section: debian-installer
2 Priority: optional
3 Maintainer: Debian Install System Team <[email protected]>
4 Uploaders: Anton Zinoviev <[email protected]>
5 Build-Depends: debhelper (>= 4.1.13), po-debconf (>= 0.5.0)
6 Standards-Version: 3.5.6
7
8 Package: partman-auto
9 Architecture: all
10 Depends: partman
11 Enhances: partman
12 Description: Automatically partition storage devices (partman)
13 This package adds to the main partitioning menu of partman an item
14 `Automatically partition the storage devices'. For each free space
15 it also adds an item `Automatically partition this free space'.
0 This package is under the GNU GPL version 2, or any later
1 version at your option.
2 On Debian system, the GPL is available in
3 /usr/share/common-licenses/GPL-2
0 #!/bin/sh
1
2 set -e
3
4 PACKAGE=$(dh_listpackages)
5 partman=debian/${PACKAGE}/lib/partman
6
7 install -d $partman/$1
8
9 cp -r $1/* $partman/$1/
10
11 if [ -f $partman/$1/_numbers ]; then
12 numbers=$(cat $partman/$1/_numbers)
13 rm $partman/$1/_numbers
14 echo "$numbers" |
15 while read number name; do
16 set -e
17 mv $partman/$1/$name $partman/$1/${number}${name}
18 done
19 fi
20
0 [type: gettext/rfc822deb] templates
0 #
1 # Translators, if you are not familiar with the PO format, gettext
2 # documentation is worth reading, especially sections dedicated to
3 # this format, e.g. by running:
4 # info -n '(gettext)PO Files'
5 # info -n '(gettext)Header Entry'
6 #
7 # Some information specific to po-debconf are available at
8 # /usr/share/doc/po-debconf/README-trans
9 # or http://www.debian.org/intl/l10n/po-debconf/README-trans
10 #
11 # Developers do not need to manually edit POT or PO files.
12 #
13 #, fuzzy
14 msgid ""
15 msgstr ""
16 "Project-Id-Version: PACKAGE VERSION\n"
17 "Report-Msgid-Bugs-To: \n"
18 "POT-Creation-Date: 2003-12-29 18:57+0200\n"
19 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
20 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
21 "Language-Team: LANGUAGE <[email protected]>\n"
22 "MIME-Version: 1.0\n"
23 "Content-Type: text/plain; charset=CHARSET\n"
24 "Content-Transfer-Encoding: 8bit\n"
25
26 #. Type: text
27 #. Description
28 #: ../templates:3
29 msgid "Please choose how the storage devices should be partitioned"
30 msgstr ""
31
32 #. Type: text
33 #. Description
34 #: ../templates:7
35 msgid "Automatically partition the storage devices"
36 msgstr ""
37
38 #. Type: text
39 #. Description
40 #: ../templates:11
41 msgid "Use the biggest continuous free space"
42 msgstr ""
43
44 #. Type: text
45 #. Description
46 #: ../templates:15
47 msgid "Use the first storage device -- ${DEVICE}"
48 msgstr ""
49
50 #. Type: text
51 #. Description
52 #: ../templates:19
53 msgid "Do custom partitioning"
54 msgstr ""
0 #!/usr/bin/make -f
1 # Sample debian/rules that uses debhelper.
2 # GNU copyright 1997 to 1999 by Joey Hess.
3
4 # Uncomment this to turn on verbose mode.
5 #export DH_VERBOSE=1
6 export DH_COMPAT=4
7
8 PACKAGE=$(shell dh_listpackages)
9 VERSION=$(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
10 ARCH=$(shell dpkg --print-architecture)
11 FILENAME=$(PACKAGE)_$(VERSION)_$(ARCH).udeb
12 PRIORITY=$(shell grep ^Priority: debian/control | cut -d ' ' -f 2)
13
14 build: build-stamp
15 build-stamp:
16 dh_testdir
17 touch build-stamp
18
19 clean:
20 dh_testdir
21 dh_testroot
22 rm -f build-stamp
23 rm -f `find . -name '*~'`
24 dh_clean
25
26 install: build
27 dh_testdir
28 dh_testroot
29 dh_clean -k
30 dh_install autopartition bin
31 debian/install-rc recipes
32 debian/install-rc choose_partition
33 debian/install-rc automatically_partition
34
35 binary-indep: build install
36 dh_testdir
37 dh_testroot
38 dh_installdebconf
39 dh_fixperms
40 dh_installdeb
41 dh_gencontrol -- -fdebian/files~
42 dpkg-distaddfile $(FILENAME) debian-installer $(PRIORITY)
43 dh_builddeb --filename=$(FILENAME)
44
45 binary-arch: build install
46
47 binary: binary-indep binary-arch
48 .PHONY: build clean binary-indep binary-arch binary install
0 Template: partman-auto/autopartitioning_failed
1 Type: note
2 _Description: Automatical partitioning failed
3 The attempt to partition automatically failed. Probably already
4 there are too many (primary) partitions in the partition table.
5
6 Template: partman-auto/automatically_partition
7 Type: select
8 Choices: ${CHOICES}
9 _Description: Please choose how the storage devices should be partitioned
10
11 Template: partman-auto/choose_recipe
12 Type: select
13 Choices: ${CHOICES}
14 _Description: Please choose one of the following partitioning schemes
15
16 Template: partman-auto/unusable_space
17 Type: note
18 _Description: The chosen free space is unusable
19 The automatical partitioninf failed because the chosen free space is
20 unusable. Probably already there are too many (primary) partitions
21 in the partition table.
22
23 Template: partman-auto/expert_recipe
24 Type: string
25 _Description: Please enter the partitioning scheme
26
27 Template: partman-auto/text/automatically_partition
28 Type: text
29 _Description: Automatically partition the storage devices
30
31 Template: partman-auto/text/use_biggest_free
32 Type: text
33 _Description: Use the biggest continuous free space
34
35 Template: partman-auto/text/use_device
36 Type: text
37 # for example "Use the whole space of IDE0 master - Maxtor 46L489"
38 _Description: Use the whole space of ${DEVICE}
39
40 Template: partman-auto/text/custom_partitioning
41 Type: text
42 _Description: Do custom partitioning
43
44 Template: partman-auto/text/expert_recipe
45 Type: text
46 _Description: Manually enter the partitioning scheme (experts only)
47
48 Template: partman-auto/text/simple_scheme
49 Type: text
50 _Description: /, /home and swap
51
52 Template: partman-auto/text/full_scheme
53 Type: text
54 _Description: /, /usr, /usr/local, /var, /var/mail, /tmp, /home and swap
55
0 30 simple
1 60 full
0 partman-auto/text/full_scheme ::
1
2 30 400 150 ext3
3 $primary{ }
4 $bootable{ }
5 format{ }
6 method{ format }
7 filesystem{ ext3 }
8 mountpoint{ / } .
9 100% 300% 400% linux-swap
10 format{ }
11 method{ format }
12 filesystem{ linux-swap } .
13 1000 3000 5000 ext3
14 format{ }
15 method{ format }
16 filesystem{ ext3 }
17 mountpoint{ /usr } .
18 10 300 700 ext3
19 format{ }
20 method{ format }
21 filesystem{ ext3 }
22 mountpoint{ /usr/local } .
23 100 500 1000 ext3
24 format{ }
25 method{ format }
26 filesystem{ ext3 }
27 mountpoint{ /var } .
28 200 700 200000 ext3
29 format{ }
30 method{ format }
31 filesystem{ ext3 }
32 mountpoint{ /var/mail } .
33 100 500 1000 ext3
34 format{ }
35 method{ format }
36 filesystem{ ext3 }
37 mountpoint{ /tmp } .
38 100 10000 1000000000 ext3
39 format{ }
40 method{ format }
41 filesystem{ ext3 }
42 mountpoint{ /home } .
0 partman-auto/text/simple_scheme ::
1 1000 3000 5000 ext3
2 $primary{ }
3 $bootable{ }
4 format{ }
5 method{ format }
6 filesystem{ ext3 }
7 mountpoint{ / } .
8 200% 300% 400% linux-swap
9 format{ }
10 method{ format }
11 filesystem{ linux-swap } .
12 100 10000 1000000000 ext3
13 format{ }
14 method{ format }
15 filesystem{ ext3 }
16 mountpoint{ /home } .