Add support for writing sizes as a number plus a percentage of RAM, e.g.
"2000+50%". This is useful when doing automatic partitioning with the
expectation of creating swap files.
r59001
Colin Watson
14 years ago
|
0 |
partman-auto (87) UNRELEASED; urgency=low
|
|
1 |
|
|
2 |
* Add support for writing sizes as a number plus a percentage of RAM, e.g.
|
|
3 |
"2000+50%". This is useful when doing automatic partitioning with the
|
|
4 |
expectation of creating swap files.
|
|
5 |
|
|
6 |
-- Colin Watson <[email protected]> Tue, 16 Jun 2009 13:07:21 +0100
|
|
7 |
|
0 | 8 |
partman-auto (86) unstable; urgency=low
|
1 | 9 |
|
2 | 10 |
[ Colin Watson ]
|
53 | 53 |
set -- $line
|
54 | 54 |
if expr "$1" : '[0-9][0-9]*$' >/dev/null; then
|
55 | 55 |
min=$1
|
|
56 |
elif expr "$1" : '[0-9][0-9]*+[0-9][0-9]*%$' >/dev/null; then
|
|
57 |
ram_percent="${1#*+}"
|
|
58 |
ram_percent="${ram_percent%?}"
|
|
59 |
min=$((${1%%+*} + $ram * $ram_percent / 100))
|
56 | 60 |
elif expr "$1" : '[0-9][0-9]*%$' >/dev/null; then
|
57 | 61 |
min=$(($ram * ${1%?} / 100))
|
58 | 62 |
else # error
|
59 | 63 |
min=2200000000 # there is no so big storage device jet
|
60 | 64 |
fi
|
61 | |
if expr "$2" : '[0-9][0-9]*%$' >/dev/null; then
|
|
65 |
if expr "$2" : '[0-9][0-9]*+[0-9][0-9]*%$' >/dev/null; then
|
|
66 |
ram_percent="${2#*+}"
|
|
67 |
ram_percent="${ram_percent%?}"
|
|
68 |
factor=$((${2%%+*} + $ram * $ram_percent / 100))
|
|
69 |
elif expr "$2" : '[0-9][0-9]*%$' >/dev/null; then
|
62 | 70 |
factor=$(($ram * ${2%?} / 100))
|
63 | 71 |
elif expr "$2" : '[0-9][0-9]*$' >/dev/null; then
|
64 | 72 |
factor=$2
|
|
71 | 79 |
if [ "$3" = "-1" ] || \
|
72 | 80 |
expr "$3" : '[0-9][0-9]*$' >/dev/null; then
|
73 | 81 |
max=$3
|
|
82 |
elif expr "$3" : '[0-9][0-9]*+[0-9][0-9]*%$' >/dev/null; then
|
|
83 |
ram_percent="${3#*+}"
|
|
84 |
ram_percent="${ram_percent%?}"
|
|
85 |
max=$((${3%%+*} + $ram * $ram_percent / 100))
|
74 | 86 |
elif expr "$3" : '[0-9][0-9]*%$' >/dev/null; then
|
75 | 87 |
max=$(($ram * ${3%?} / 100))
|
76 | 88 |
else # error
|