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
|
From: Tobias Heider <me@tobhe.de>
Date: Sun, 12 Feb 2023 01:23:08 +0100
Subject: debian: Adjust update-m1n1 for debian.
---
update-m1n1 | 50 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 6 deletions(-)
diff --git a/update-m1n1 b/update-m1n1
index 9dd745c..bf0c183 100755
--- a/update-m1n1
+++ b/update-m1n1
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# SPDX-License-Identifier: MIT
set -e
@@ -13,17 +13,55 @@ else
. /usr/share/asahi-scripts/functions.sh
fi
-: ${SOURCE:="/usr/lib/asahi-boot/"}
-: ${M1N1:="$SOURCE/m1n1.bin"}
-: ${U_BOOT:="$SOURCE/u-boot-nodtb.bin"}
+: ${M1N1:="/usr/lib/m1n1/m1n1.bin"}
: ${TARGET:="$1"}
+: ${DTBS:=$(/bin/ls -d /usr/lib/linux-image-*asahi*/apple 2>/dev/null | sort -rV | head -1)/*.dtb}
: ${CONFIG:=/etc/m1n1.conf}
-if [ -z "$DTBS" ]; then
- warn "ERROR: DTBS config unset or empty, see `/etc/default/update-m1n1`"
+U_BOOT_DEF="/usr/lib/u-boot/apple_m1/u-boot-nodtb.bin"
+U_BOOT_ALT="/usr/lib/u-boot-asahi/u-boot-nodtb.bin"
+if [ -z "$U_BOOT" ]; then
+ if [ -f "$U_BOOT_DEF" ]; then
+ # Use Debian's u-boot as default unless otherwise specified
+ U_BOOT="$U_BOOT_DEF"
+ elif [ -f "$U_BOOT_ALT" ]; then
+ # Most third parties have the u-boot binary at a specific
+ # path, different than Debian's. Use it as a fallback to
+ # avoid breaking users' systems if it exists, but warn that
+ # that they must set U_BOOT explicitly in /etc/default/update-m1n1
+ #
+ # Note: when this fallback is removed, switch to setting U_BOOT's
+ # path via ': ${U_BOOT:=/usr/lib/u-boot/apple_m1/u-boot-nodtb.bin}'
+ # and add U_BOOT to the other file checks
+ warn "WARNING: Found alternative bootloader (only), please set"
+ warn " U_BOOT=$U_BOOT_ALT"
+ warn " in /etc/default/update-m1n1 or YOUR SYSTEM MIGHT"
+ warn " NOT BOOT in the future!"
+ warn
+ U_BOOT="$U_BOOT_ALT"
+ else
+ warn "ERROR: $U_BOOT_DEF not found, will not update m1n1"
+ exit 1
+ fi
+elif [ ! -f "$U_BOOT" ]; then
+ warn "ERROR: $U_BOOT not found, will not update m1n1"
exit 1
fi
+if [ ! -f "$M1N1" ]; then
+ warn "ERROR: $M1N1 not found, will not update m1n1"
+ exit 1
+fi
+
+for dtb in $DTBS; do
+ if [ ! -f "$dtb" ]; then
+ warn "ERROR: DTBs not found, will not update m1n1"
+ exit 1
+ else
+ break
+ fi
+done
+
umount=false
m1n1config=/run/m1n1.conf
|