From 7afcfc7d2a073532a6dfc81e3916d1f86dc73456 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 14 Apr 2023 15:00:40 +0000 Subject: [PATCH] check if there is actually anything to extract from the firmware tarball on apple silicon so that we don't fill up the ramdisk by extracting the whole tarball while here, change the code so that the machdep.compatible sysctl gets read once and then that value is used in the script instead of calling sysctl several times from input and ok kn@, kettenis@ --- distrib/arm64/ramdisk/install.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/distrib/arm64/ramdisk/install.md b/distrib/arm64/ramdisk/install.md index b7ae7b04500..4be04259a86 100644 --- a/distrib/arm64/ramdisk/install.md +++ b/distrib/arm64/ramdisk/install.md @@ -1,4 +1,4 @@ -# $OpenBSD: install.md,v 1.44 2023/04/04 08:39:40 kn Exp $ +# $OpenBSD: install.md,v 1.45 2023/04/14 15:00:40 robert Exp $ # # # Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -34,12 +34,13 @@ MDBOOTSR=y NCPU=$(sysctl -n hw.ncpufound) +COMPATIBLE=$(sysctl -n machdep.compatible) MOUNT_ARGS_msdos="-o-l" md_installboot() { local _disk=$1 _chunks _bootdisk _mdec _plat - case $(sysctl -n machdep.compatible) in + case ${COMPATIBLE} in apple,*) _plat=apple;; raspberrypi,*) _plat=rpi;; esac @@ -89,7 +90,7 @@ md_prep_fdisk() { local bootsectorsize="32768" local bootfstype="msdos" - case $(sysctl -n machdep.compatible) in + case ${COMPATIBLE} in openbsd,acpi) bootsectorsize=532480;; esac @@ -206,18 +207,18 @@ md_consoleinfo() { CSPEED=115200;; esac - _fw=$(dmesgtail | sed -n '\!^bwfm0: failed!{s!^.*/\(.*\),.*$!\1!p;q;}') - case $(sysctl -n machdep.compatible) in + case ${COMPATIBLE} in apple,*) - _fw2=$(sysctl -n machdep.compatible | sed 's/.*apple,//') + _fw=$(dmesgtail | sed -n '\!^bwfm0: failed!{s!^.*/\(.*\),.*$!\1!p;q;}') + _fw2=${COMPATIBLE##*apple,} make_dev sd0 if mount -o ro /dev/sd0l /mnt2 2>/dev/null; then rm -rf /usr/mdec/rpi /etc/firmware/apple rm -rf /etc/firmware/brcm /etc/firmware/apple-bwfm if [[ -s /mnt2/vendorfw/firmware.tar ]]; then - tar -x -C /etc/firmware \ + [[ -n $_fw ]] && tar -x -C /etc/firmware \ -f /mnt2/vendorfw/firmware.tar "*$_fw*" 2>/dev/null - tar -x -C /etc/firmware \ + [[ -n $_fw2 ]] && tar -x -C /etc/firmware \ -f /mnt2/vendorfw/firmware.tar "*$_fw2*" 2>/dev/null mv /etc/firmware/brcm /etc/firmware/apple-bwfm 2>/dev/null fi -- 2.20.1