-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·78 lines (70 loc) · 3.08 KB
/
build
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
#!/usr/bin/env sh
output="BOOTX64.EFI"
if [ $# -gt 0 ]; then
output="$1"
fi
dir="."
if [ -d "$1" ]; then
dir="$1"
output="$output.efi"
fi
echo "Using $dir/grub.cfg for $output"
echo "Grub modules dir: ${ENV_GRUB_MODULES_DIR:=/usr/lib/grub/x86_64-efi/}"
echo "Compression: ${ENV_GRUB_COMPRESS_COMMAND:=xz -9}"
# xz -9
# gzip -9
# zstd does not seem to work
# compressing each file individually, xz seems to perform best
export MODULES="$ENV_GRUB_MODULES_BASE $ENV_GRUB_MODULES_FS $ENV_GRUB_MODULES_CRYPTO $ENV_GRUB_MODULES_LUKS"
(cd "$dir" \
&& rm -rf memdisk \
&& mkdir -p memdisk/boot/grub/x86_64-efi \
&& cd memdisk \
&& envsubst '$ENV_GRUB_CRYPTODISK_UUID $ENV_GRUB_FS_UUID $ENV_GRUB_HINT $ENV_GRUB_CHAINLOAD_PREFIX $ENV_GRUB_CHAINLOAD_EFI $ENV_GRUB_LOG_LEVEL $ENV_GRUB_RETRY_TIMEOUT $MODULES' \
< ../grub.cfg.template | $ENV_GRUB_COMPRESS_COMMAND > boot/grub/grub.cfg \
&& for mod in $MODULES; do cat $ENV_GRUB_MODULES_DIR$mod.mod > boot/grub/x86_64-efi/$mod.mod; done \
&& for mod in normal fshelp extcmd net priority_queue bufio datetime boot terminal gettext echo sleep test configfile part_gpt fat search_label search_fs_file efinet diskfilter procfs afsplitter pbkdf2; do cat $ENV_GRUB_MODULES_DIR$mod.mod > boot/grub/x86_64-efi/$mod.mod; done \
&& (cd boot/grub && tar -c x86_64-efi | $ENV_GRUB_COMPRESS_COMMAND > ../x86_64-efi.tar.xz && rm -rf x86_64-efi) \
&& tar -cf ../memdisk.tar boot)
## create a efi grub boot image
## the config gets embedded and should decrypt the disk and chainload the grub residing there
## loaded modules should only be necessary for what's happening in the embedded script
## todo maybe some eyecandy --> distinguishable for me that everything works as it should ;D
grub-mkimage --config "initial.cfg" --compression auto --output "$output" \
--format x86_64-efi --memdisk="$dir/memdisk.tar" \
memdisk tar \
loopback \
`#gzio` \
xzio \
`#zstd`
## about the mods used
## ===================
# | mod | description
# |----------------|--------------------
# | fat | support read fat fs
# | part_gpt | support gpt partitions
# | test | command to test expressions
# | search | to search for the root device
# | search_fs_uuid | to allow uuids for the search
# | cryptodisk | encryption
# | luks | luks encryption
# | lvm | lvm support
# | xfs | xfs support
# | ext2 | ext2 support (+ ext3/ext4)
# | configfile | read the "chainloaded" configfile
# | gcry_sha256 | sha256 for encryption
# | gcry_sha512 | sha512
# | gcry_rijndael | for encryption (AES)
# |----------------|--------------------
# | other interesting mods |
# |----------------|-------------------
# | gfmenu | eyecandy?
# | hashsum | check hashsums: to check external sources like images
# | jpeg | eyecandy?
# | keystatus | show a caps-lock warning ?
# | normal | normal mode ?
# | png | eyecandy?
# | probe | easier info?
# | progress | eyecandy?
# | verify | check file signatures
# | gcry_rsa | rsa signatures?