-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_recipes
More file actions
executable file
·396 lines (354 loc) · 6.9 KB
/
build_recipes
File metadata and controls
executable file
·396 lines (354 loc) · 6.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
#!/bin/sh
set -e
# partman-auto recipe generator for default, amd64, amd64-efi, armhf, arm64, arm64-efi, ppc64el, riscv64
# partition limit definitions
# 1st number is the minimum size in MB; %RAM is not supported
# 2nd number is the percentage of available disk space to use, is used to calculate the priority
# 3rd number is the maximum size in MB; %RAM is supported
# common limits
EFI="768 2 1024"
BOOT="768 2 1024"
SWAP="500 5 100%"
# limits for atomic recipe
ROOT_ATOMIC="8000 85 -1"
# limits for home recipe
ROOT_HOME="7500 5 100000"
HOME_HOME="1000 80 -1"
# limits for multi recipe
ROOT_MULTI="7000 5 100000"
VAR_MULTI="2000 2 40000"
TMP_MULTI="500 1 3000"
HOME_MULTI="1000 77 -1"
# limits for server recipe
ROOT_SERVER="5000 5 100000"
VAR_SERVER="2000 2 40000"
SWAP_SERVER="500 5 1024"
SRV_SERVER="1000 78 -1"
# limits for small_disk recipe
EFI_SMALL="512 3 1024"
ROOT_SMALL="2000 84 -1"
SWAP_SMALL="500 6 100%"
# for consistency with partman-auto-lvm
factor_pv=900
boot() {
local min=$1 prio=$2 max=$3 filesystem
if [ "$boot_fs" = '$default_filesystem' ]; then
filesystem='$default_filesystem{ }'
else
filesystem="filesystem{ $boot_fs }"
fi
echo "$min $prio $max $boot_fs
$boot_option method{ format }
format{ }
use_filesystem{ }
$filesystem
mountpoint{ /boot } ."
}
filesystem() {
local min=$1 prio=$2 max=$3 mountpoint=$4 option=
if [ "$mountpoint" = / ]; then
option="$root_option"
fi
echo "$min $prio $max \$default_filesystem
$lvm_option$option method{ format }
format{ }
use_filesystem{ }
\$default_filesystem{ }
mountpoint{ $mountpoint } ."
}
swap() {
local min=$1 prio=$2 max=$3
echo "$min $prio $max linux-swap
$lvm_option$reuse_option method{ swap }
format{ } ."
}
perc_sum() {
local s=0 min perc max
while [ -n "$1" ]; do
perc=$(echo $1 | {
read min perc max
echo $perc
})
s=$(($perc+$s))
shift
done
echo $s
}
limits() {
local min=$1 perc=$2 max=$3 d=$4
echo $min $(($perc*factor_pv/$d+$min)) $max
}
d=$(perc_sum "$ROOT_ATOMIC" "$SWAP")
EFI_ATOMIC="$(limits $EFI $d)"
BOOT_ATOMIC="$(limits $BOOT $d)"
ROOT_ATOMIC="$(limits $ROOT_ATOMIC $d)"
SWAP_ATOMIC="$(limits $SWAP $d)"
header_atomic='partman-auto/text/atomic_scheme ::
'
atomic() {
boot $BOOT_ATOMIC
echo
filesystem $ROOT_ATOMIC /
echo
swap $SWAP_ATOMIC
}
d=$(perc_sum "$ROOT_HOME" "$SWAP" "$HOME_HOME")
EFI_HOME="$(limits $EFI $d)"
BOOT_HOME="$(limits $BOOT $d)"
ROOT_HOME="$(limits $ROOT_HOME $d)"
SWAP_HOME="$(limits $SWAP $d)"
HOME_HOME="$(limits $HOME_HOME $d)"
header_home='partman-auto/text/home_scheme ::
'
home() {
boot $BOOT_HOME
echo
filesystem $ROOT_HOME /
echo
swap $SWAP_HOME
echo
filesystem $HOME_HOME /home
}
d=$(perc_sum "$ROOT_MULTI" "$VAR_MULTI" "$SWAP" "$TMP_MULTI" "$HOME_MULTI")
EFI_MULTI="$(limits $EFI $d)"
BOOT_MULTI="$(limits $BOOT $d)"
ROOT_MULTI="$(limits $ROOT_MULTI $d)"
VAR_MULTI="$(limits $VAR_MULTI $d)"
SWAP_MULTI="$(limits $SWAP $d)"
TMP_MULTI="$(limits $TMP_MULTI $d)"
HOME_MULTI="$(limits $HOME_MULTI $d)"
header_multi='partman-auto/text/multi_scheme ::
'
multi() {
boot $BOOT_MULTI
echo
filesystem $ROOT_MULTI /
echo
filesystem $VAR_MULTI /var
echo
swap $SWAP_MULTI
echo
filesystem $TMP_MULTI /tmp
echo
filesystem $HOME_MULTI /home
}
d=$(perc_sum "$ROOT_SERVER" "$VAR_SERVER" "$SWAP_SERVER" "$SRV_SERVER")
EFI_SERVER="$(limits $EFI $d)"
BOOT_SERVER="$(limits $BOOT $d)"
ROOT_SERVER="$(limits $ROOT_SERVER $d)"
VAR_SERVER="$(limits $VAR_SERVER $d)"
SWAP_SERVER="$(limits $SWAP_SERVER $d)"
SRV_SERVER="$(limits $SRV_SERVER $d)"
header_server='partman-auto/text/server_scheme ::
'
server() {
boot $BOOT_SERVER
echo
filesystem $ROOT_SERVER /
echo
filesystem $VAR_SERVER /var
echo
swap $SWAP_SERVER
echo
filesystem $SRV_SERVER /srv
}
d=$(perc_sum "$ROOT_SMALL" "$SWAP_SMALL")
EFI_SMALL="$(limits $EFI_SMALL $d)"
BOOT_SMALL="$(limits $BOOT $d)"
ROOT_SMALL="$(limits $ROOT_SMALL $d)"
SWAP_SMALL="$(limits $SWAP_SMALL $d)"
header_small='partman-auto/text/small_disk ::
'
small_disk() {
boot $BOOT_SMALL
echo
filesystem $ROOT_SMALL /
echo
swap $SWAP_SMALL
}
defaultignore=' $defaultignore{ }
'
primary=' $primary{ }
'
bootable=' $bootable{ }
'
legacy_boot=' $legacy_boot{ }
'
lvmok=' $lvmok{ }
'
reusemethod=' $reusemethod{ }
'
biosgrub() {
echo '1 1 1 free
$iflabel{ gpt }
$reusemethod{ }
method{ biosgrub } .'
}
efi() {
local min=$1 prio=$2 max=$3
echo "$min $prio $max"' free
$primary{ }
$iflabel{ msdos gpt }
$reusemethod{ }
method{ efi }
format{ } .'
}
prep() {
echo '8 1 1 prep
$primary{ }
$bootable{ }
method{ prep } .'
}
uboot() {
echo "18 18 18 free
$uboot_option."
}
for arch in default amd64 amd64-efi armhf arm64 arm64-efi ppc64el riscv64; do
case "$arch" in
default)
efi=
boot_fs=ext2
boot_option=
root_option=
lvm_option="$lvmok"
reuse_option="$reusemethod"
arch_part="$(biosgrub)
"
dir=recipes
;;
amd64)
efi=
boot_fs=ext4
boot_option="$defaultignore"
root_option=
lvm_option="$lvmok"
reuse_option="$reusemethod"
arch_part="$(biosgrub)
"
dir=recipes-amd64
;;
amd64-efi)
efi=yes
boot_fs=ext4
boot_option="$defaultignore"
root_option=
lvm_option="$lvmok"
reuse_option="$reusemethod"
arch_part=
# efi partition limits depend on recipe
dir=recipes-amd64-efi
;;
armhf)
efi=
boot_fs=ext4
boot_option="$primary$bootable"
root_option="$primary"
lvm_option="$lvmok"
reuse_option=
arch_part=
dir=recipes-armhf
;;
arm64)
efi=
uboot_option='$primary{ } '
boot_fs=ext4
boot_option="$primary$bootable$legacy_boot"
root_option="$primary"
lvm_option="$lvmok"
reuse_option=
arch_part="$(uboot)
"
dir=recipes-arm64
;;
arm64-efi)
efi=yes
uboot_option=
boot_fs=ext4
boot_option="$defaultignore"
root_option=
lvm_option="$lvmok"
reuse_option="$reusemethod"
arch_part="$(uboot)
"
# efi partition limits depend on recipe
dir=recipes-arm64-efi
;;
ppc64el)
efi=
boot_fs=ext2
boot_option="$primary"
root_option="$primary"
lvm_option="$lvmok"
reuse_option=
arch_part="$(prep)
"
dir=recipes-ppc64el
;;
riscv64)
efi=
boot_fs=ext4
boot_option="$defaultignore"
root_option=
lvm_option="$lvmok"
reuse_option="$reusemethod"
arch_part=
dir=recipes-riscv64
;;
*)
echo "wrong arch: $arch"
exit 1
esac
mkdir -p "$dir"
{
echo "$header_atomic"
echo -n "$arch_part"
if [ "$efi" = yes ]; then
efi $EFI_ATOMIC
echo
fi
atomic
} > "$dir"/atomic
{
echo "$header_home"
echo -n "$arch_part"
if [ "$efi" = yes ]; then
efi $EFI_HOME
echo
fi
home
} > "$dir"/home
{
echo "$header_multi"
echo -n "$arch_part"
if [ "$efi" = yes ]; then
efi $EFI_MULTI
echo
fi
multi
} > "$dir"/multi
{
echo "$header_server"
echo -n "$arch_part"
if [ "$efi" = yes ]; then
efi $EFI_SERVER
echo
fi
server
} > "$dir"/server
{
echo "$header_small"
echo -n "$arch_part"
if [ "$efi" = yes ]; then
efi $EFI_SMALL
echo
fi
small_disk
} > "$dir"/small_disk
cat << EOF > "$dir"/_numbers
30 atomic
50 home
80 multi
90 server
95 small_disk
EOF
done