diff --git a/.gitignore b/.gitignore index 44a116c..6b7eb95 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,19 @@ /asahi-scripts-20221122.tar.gz /asahi-scripts-20221129.tar.gz /asahi-scripts-20221206.tar.gz +/asahi-scripts-20221220.tar.gz +/asahi-scripts-20230530.tar.gz +/asahi-scripts-20230606.tar.gz +/asahi-scripts-20230821.tar.gz +/asahi-scripts-20231217.tar.gz +/asahi-scripts-20231218.tar.gz +/asahi-scripts-20231219.tar.gz +/asahi-scripts-20231219.1.tar.gz +/asahi-scripts-20240411.tar.gz +/asahi-scripts-20240429.tar.gz +/asahi-scripts-20240822.tar.gz +/asahi-scripts-20250128.tar.gz +/asahi-scripts-20250130.tar.gz +/asahi-scripts-20250426.tar.gz +/asahi-scripts-20250426.1.tar.gz +/asahi-scripts-20250713.tar.gz diff --git a/0001-update-m1n1-Expand-DTBS-if-it-is-a-directory.patch b/0001-update-m1n1-Expand-DTBS-if-it-is-a-directory.patch new file mode 100644 index 0000000..e9659e7 --- /dev/null +++ b/0001-update-m1n1-Expand-DTBS-if-it-is-a-directory.patch @@ -0,0 +1,35 @@ +From 5fb7712c7c2692b77c21a6d799db29f6cefb388f Mon Sep 17 00:00:00 2001 +From: Janne Grunau +Date: Tue, 19 Aug 2025 22:55:33 +0200 +Subject: [PATCH 1/2] update-m1n1: Expand $DTBS if it is a directory + +Allows limiting the included devices to Apple silicon macs now that the +kernel has device-trees for iphones, ipads and T2 macs as well. +Avoids having each distribution to modify their default update-m1n1 +configuration for this. + +Signed-off-by: Janne Grunau +--- + update-m1n1 | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/update-m1n1 b/update-m1n1 +index ae274eb..dcd79fa 100755 +--- a/update-m1n1 ++++ b/update-m1n1 +@@ -24,6 +24,12 @@ if [ -z "$DTBS" ]; then + exit 1 + fi + ++# If ${DTBS} is a directory expand it to include dtbs from all Apple silicon ++# macs. ++if [ -d "$DTBS" ]; then ++ DTBS="${DTBS}/apple/t6*.dtb ${DTBS}/apple/t81*.dtb" ++fi ++ + umount=false + + m1n1config=/run/m1n1.conf +-- +2.50.1 + diff --git a/0002-fedora-update-m1n1-handle-dangling-boot-dtb-symlinks.patch b/0002-fedora-update-m1n1-handle-dangling-boot-dtb-symlinks.patch new file mode 100644 index 0000000..9507e81 --- /dev/null +++ b/0002-fedora-update-m1n1-handle-dangling-boot-dtb-symlinks.patch @@ -0,0 +1,36 @@ +From d24ee482717237afbf6cbbbabbd0dd4eea772f8a Mon Sep 17 00:00:00 2001 +From: Janne Grunau +Date: Tue, 19 Aug 2025 23:10:23 +0200 +Subject: [PATCH 2/2] fedora: update-m1n1: handle dangling /boot/dtb symlinks + +At kernel-install time the target of the /boot/dtb symlink might not +exists yet for newly installed targets. Use +"/usr/lib/modules/${KERNEL_VERSION}/dtb" instead. + +Signed-off-by: Janne Grunau +--- + update-m1n1 | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/update-m1n1 b/update-m1n1 +index dcd79fa..87de029 100755 +--- a/update-m1n1 ++++ b/update-m1n1 +@@ -24,6 +24,14 @@ if [ -z "$DTBS" ]; then + exit 1 + fi + ++# Fedora: handle broken /boot/dtb symlinks by reading the link, ++# extracting the kernel version and using the dtb directory from ++# "/usr/lib/modules/${KERNEL_VERSION}/". ++if [ -L "$DTBS" -a ! -d "$DTBS" ]; then ++ KVER=$(readlink "$DTBS" | sed -e 's/^dtb-//') ++ DTBS="/usr/lib/modules/${KVER}/dtb" ++fi ++ + # If ${DTBS} is a directory expand it to include dtbs from all Apple silicon + # macs. + if [ -d "$DTBS" ]; then +-- +2.50.1 + diff --git a/15-update-m1n1.install b/15-update-m1n1.install new file mode 100644 index 0000000..b5ce56f --- /dev/null +++ b/15-update-m1n1.install @@ -0,0 +1,22 @@ +#!/usr/bin/sh +# SPDX-License-Identifier: MIT +# thin wrapper to execute `update-m1n1` on kernel updates +# depends on grubby's "10-devicetree.install" + +COMMAND="$1" + +# execute only on aarch64, can't check for Apple silicon systems as the install +# images are created on generic aarch64 systems. +if [ "$(uname -m)" != aarch64 ]; then + exit 0 +fi + +case "${COMMAND}" in + # always run update-m1n1 and rely on its no change detection for removals + # of old kernels. + add|remove) + exec /usr/bin/update-m1n1 + ;; +esac + +exit 0 diff --git a/asahi-scripts.spec b/asahi-scripts.spec index e7c70aa..ecd42cb 100644 --- a/asahi-scripts.spec +++ b/asahi-scripts.spec @@ -1,5 +1,5 @@ Name: asahi-scripts -Version: 20221206 +Version: 20250713 Release: %autorelease Summary: Miscellaneous admin scripts for Asahi Linux @@ -7,40 +7,43 @@ License: MIT URL: https://github.com/AsahiLinux/asahi-scripts Source: %{url}/archive/%{version}/%{name}-%{version}.tar.gz Source: update-m1n1.sysconfig +Source2: 15-update-m1n1.install + +Patch01: 0001-update-m1n1-Expand-DTBS-if-it-is-a-directory.patch +Patch02: 0002-fedora-update-m1n1-handle-dangling-boot-dtb-symlinks.patch BuildArch: noarch BuildRequires: make BuildRequires: sed +BuildRequires: systemd-rpm-macros Requires: bash Requires: coreutils Requires: grep Requires: sed +Requires: systemd-udev Requires: util-linux-core %description This package contains miscellaneous admin scripts for the Asahi Linux reference distro. -%package -n asahi-fwextract +%package -n asahi-fwupdate Summary: Asahi Linux firmware extractor Requires: %{name} = %{version}-%{release} -Requires: python3dist(asahi-firmware) +# Not using python3dist(asahi-firmware) because its version is fixed +Requires: python3-asahi_firmware >= 0.5.4 -%description -n asahi-fwextract -Asahi Linux firmware extractor. +%description -n asahi-fwupdate +Asahi Linux firmware updater. %package -n dracut-asahi Summary: Dracut config for Apple Silicon Macs Requires: dracut Requires: linux-firmware-vendor = %{version}-%{release} -Provides: dracut-config-asahi = %{version}-%{release} -Obsoletes: dracut-config-asahi < 20220821-5 -Provides: update-vendor-firmware = %{version}-%{release} -Obsoletes: update-vendor-firmware < 20220918.2-8 %description -n dracut-asahi Dracut config for Apple Silicon Macs. @@ -57,15 +60,28 @@ over properly from the initramfs. Summary: Keep m1n1 up to date Requires: %{name} = %{version}-%{release} - Requires: bash Requires: gzip Requires: m1n1 Requires: uboot-images-armv8 +# grubby's /usr/lib/kernel/install.d/10-devicetree.install creates the +# /boot/dtb symlink update-m1n1 uses to construct the 2nd stage m1n1 image +Requires: grubby %description -n update-m1n1 Keep m1n1 up to date on Apple Silicon systems. +%package -n asahi-battery +Summary: Asahi Linux battery charge control scripts + +Requires: %{name} = %{version}-%{release} +Requires: systemd +Requires: systemd-udev + +%description -n asahi-battery +Asahi Linux battery charge control scripts restore charge_control_end_threshold +on system start. + %prep %autosetup -p1 @@ -80,22 +96,34 @@ Keep m1n1 up to date on Apple Silicon systems. install -Ddpm0755 %{buildroot}%{_prefix}/lib/firmware/vendor install -Dpm0644 %SOURCE1 %{buildroot}%{_sysconfdir}/sysconfig/update-m1n1 +# Install kernel-install script +install -Dpm0755 -t %{buildroot}%{_kernel_install_dir} %{SOURCE2} -%transfiletriggerin -n update-m1n1 -- %{_libdir}/m1n1 %{_datadir}/uboot/apple_m1 /boot/dtb- +%transfiletriggerin -n asahi-fwupdate -- %{_sbindir}/asahi-fwupdate %{_bindir}/asahi-fwextract +%{_sbindir}/asahi-fwupdate || : + +# This needs to be a separate trigger because we can't use python3_sitearch here +%transfiletriggerin -n asahi-fwupdate -- /usr/lib/python +grep -q 'asahi_firmware' && %{_sbindir}/asahi-fwupdate || : + +# We can't use _libdir here because it gets incorrectly expanded to /usr/lib +%transfiletriggerin -n update-m1n1 -- /usr/lib/m1n1 /usr/lib64/m1n1 /usr/share/uboot/apple_m1 /etc/m1n1.conf %{_sbindir}/update-m1n1 || : %files %license LICENSE %{_datadir}/%{name}/ %{_sbindir}/asahi-diagnose +%{_udevhwdbdir}/65-autosuspend-override-asahi-sdhci.hwdb -%files -n asahi-fwextract +%files -n asahi-fwupdate %license LICENSE -%{_sbindir}/asahi-fwextract +%{_sbindir}/asahi-fwupdate %files -n dracut-asahi %license LICENSE %{_prefix}/lib/dracut/dracut.conf.d/10-asahi.conf +%{_prefix}/lib/dracut/modules.d/91kernel-modules-asahi/ %{_prefix}/lib/dracut/modules.d/99asahi-firmware/ %files -n linux-firmware-vendor @@ -104,9 +132,15 @@ install -Dpm0644 %SOURCE1 %{buildroot}%{_sysconfdir}/sysconfig/update-m1n1 %files -n update-m1n1 %license LICENSE -%config(noreplace) %{_sysconfdir}/m1n1.conf %config(noreplace) %{_sysconfdir}/sysconfig/update-m1n1 +%{_kernel_install_dir}/15-update-m1n1.install %{_sbindir}/update-m1n1 +%files -n asahi-battery +%{_unitdir}/macsmc-battery-charge-control-end-threshold.path +%{_unitdir}/macsmc-battery-charge-control-end-threshold.service +%{_udevrulesdir}/93-macsmc-battery-charge-control.rules +%ghost %config(noreplace) %{_sysconfdir}/udev/macsmc-battery.conf + %changelog %autochangelog diff --git a/sources b/sources index a708605..46303e9 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (asahi-scripts-20221206.tar.gz) = 41cf25e6b396a935a71a5417bf1cefda0c5444e1e5e3db66a0e89863820a33e491b369964b5ca91c04686cb3e8aa9ca2ae08b679402cef7172fa8a18940b5ebc +SHA512 (asahi-scripts-20250713.tar.gz) = cb94711a556e4b8b4e171540d7026f93ad03afe3a359e8888bc63c09a17d521af1da3299fd3af89ad1fd3c3cb55b0b508ae307b4a9dacb48d45bbdfa50e4f767 diff --git a/update-m1n1.sysconfig b/update-m1n1.sysconfig index 6d440e5..68b20fb 100644 --- a/update-m1n1.sysconfig +++ b/update-m1n1.sysconfig @@ -1,3 +1,4 @@ M1N1="/usr/lib64/m1n1/m1n1.bin" U_BOOT="/usr/share/uboot/apple_m1/u-boot-nodtb.bin" -DTBS=/boot/dtb-*/apple/* +# limit DTBS to Mx and Mx Pro/Max/Ultra +DTBS="/boot/dtb"