forked from AsahiLinux/asahi-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asahi-fwupdate
executable file
·53 lines (41 loc) · 1.07 KB
/
asahi-fwupdate
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
#!/bin/sh
# SPDX-License-Identifier: MIT
set -eu
unset PYTHON
[ -e /etc/default/asahi-fwupdate ] && . /etc/default/asahi-fwupdate
: "${ASAHIFW:=}"
: "${VENDORFW:=}"
: "${VENDORFWTMP:=/run/.vendorfw-tmp}"
: "${PYTHON:=/usr/bin/python3}"
if [ -e "$(dirname "$0")"/functions.sh ]; then
. "$(dirname "$0")"/functions.sh
else
. /usr/share/asahi-scripts/functions.sh
fi
umount=false
if [ -z "$ASAHIFW" ] && [ -z "$VENDORFW" ]; then
mount_sys_esp /run/.system-efi
ASAHIFW="/run/.system-efi/asahi/"
VENDORFW="/run/.system-efi/vendorfw"
umount=true
fi
if [ ! -e "${ASAHIFW}/all_firmware.tar.gz" ]; then
echo "No firmware tarball found, skipping extraction"
exit 0
fi
if [ ! -d "$VENDORFW" ]; then
mkdir -p "$VENDORFW"
fi
if [ ! -d "$VENDORFWTMP" ]; then
mkdir -p "$VENDORFWTMP"
fi
echo "Upgrading vendor firmware package"
asahi-fwextract "$ASAHIFW" "$VENDORFWTMP"
rm -rf "$VENDORFW".new
mv "${VENDORFWTMP}" "$VENDORFW".new
rm -rf "$VENDORFW"
mv "$VENDORFW".new "$VENDORFW"
rm -rf "$VENDORFWTMP"
echo "Firmware upgraded"
$umount && umount /run/.system-efi
true