-
Notifications
You must be signed in to change notification settings - Fork 31
/
update-m1n1
executable file
·60 lines (48 loc) · 1.36 KB
/
update-m1n1
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
#!/bin/sh
# SPDX-License-Identifier: MIT
set -e
[ -e /etc/default/update-m1n1 ] && . /etc/default/update-m1n1
[ -n "$M1N1_UPDATE_DISABLED" ] && exit 0
if [ -e "$(dirname "$0")"/functions.sh ]; then
. "$(dirname "$0")"/functions.sh
else
. /usr/share/asahi-scripts/functions.sh
fi
: ${SOURCE:="/usr/lib/asahi-boot/"}
: ${M1N1:="$SOURCE/m1n1.bin"}
: ${U_BOOT:="$SOURCE/u-boot-nodtb.bin"}
: ${TARGET:="$1"}
: ${DTBS:=$(/bin/ls -d /lib/modules/*-ARCH | sort -rV | head -1)/dtbs/*.dtb}
: ${CONFIG:=/etc/m1n1.conf}
umount=false
m1n1config=/run/m1n1.conf
>"$m1n1config"
if [ -e "$CONFIG" ]; then
info "Reading m1n1 config from $CONFIG:"
while read line; do
case "$line" in
"") ;;
\#*) ;;
chosen.*=*|display=*)
echo "$line" >> "$m1n1config"
info " Option: $line"
;;
*)
warn " Ignoring unknown option: $line"
;;
esac
done <$CONFIG
fi
if [ -z "$TARGET" ]; then
mount_sys_esp /run/.system-efi
TARGET="/run/.system-efi/m1n1/boot.bin"
umount=true
fi
cat "$M1N1" $DTBS >"${TARGET}.new"
gzip -c "$U_BOOT" >>"${TARGET}.new"
cat "$m1n1config" >>"${TARGET}.new"
[ -e "$TARGET" ] && mv -f "$TARGET" "${TARGET}.old"
mv -f "${TARGET}.new" "$TARGET"
echo "m1n1 updated at ${TARGET}"
$umount && umount /run/.system-efi
true