summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Calligeros <jcalligeros99@gmail.com>2024-09-21 16:39:18 +1000
committerSam James <sam@gentoo.org>2024-11-17 05:20:45 +0000
commit41807551bac62f56be32313469bd4e0fda5cd54e (patch)
tree81c77bb96651715bfd245fad573450485fba3719 /sys-apps/asahi-scripts
parentdev-db/postgresql: build w/ -std=gnu17 (diff)
downloadgentoo-41807551bac62f56be32313469bd4e0fda5cd54e.tar.gz
gentoo-41807551bac62f56be32313469bd4e0fda5cd54e.tar.bz2
gentoo-41807551bac62f56be32313469bd4e0fda5cd54e.zip
sys-apps/asahi-scripts: add 20240822
Signed-off-by: James Calligeros <jcalligeros99@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'sys-apps/asahi-scripts')
-rw-r--r--sys-apps/asahi-scripts/Manifest1
-rw-r--r--sys-apps/asahi-scripts/asahi-scripts-20240822.ebuild41
-rw-r--r--sys-apps/asahi-scripts/files/99-update-m1n1.install2
-rw-r--r--sys-apps/asahi-scripts/files/asahi-scripts-macsmc-battery.openrc51
-rw-r--r--sys-apps/asahi-scripts/files/update-m1n1.gentoo.conf1
5 files changed, 96 insertions, 0 deletions
diff --git a/sys-apps/asahi-scripts/Manifest b/sys-apps/asahi-scripts/Manifest
index 1243dd233d81..58484ab54e5f 100644
--- a/sys-apps/asahi-scripts/Manifest
+++ b/sys-apps/asahi-scripts/Manifest
@@ -1 +1,2 @@
DIST asahi-scripts-20231219.1.tar.gz 10696 BLAKE2B 1a3103f093fa87f33f7bdc64340dbd61705ac88832b1a9a2cb015ae8ff7ccfc138b91d0f38505dcdb916ccef03a0f788dd2bbaac66fc32118ce8acb536791bdd SHA512 ab4462bd8b98558f57a1edb4ac9fb21535e6a2b8396f6774a3ea1160ad2de4f64ffb65a93d08e6112ea2d90050a1a368fd32d8a6e5b0d7a545961c57ac9d0639
+DIST asahi-scripts-20240822.tar.gz 12264 BLAKE2B 945bd549a768beb86b69bbdeae088df7d687a534d7003e62574349e40fcb84f37306e96aade89d2fd45882add0d1b31e99b647f38debce4f6fb9185ec848d2a8 SHA512 6b99abe8df63b928285d6af54ba745bf9ae7a53f3208c77b90158fa076d34feb091275343039b61320fc043b6021170ad63f0e6df933e6a0a3fbfe146f78caf5
diff --git a/sys-apps/asahi-scripts/asahi-scripts-20240822.ebuild b/sys-apps/asahi-scripts/asahi-scripts-20240822.ebuild
new file mode 100644
index 000000000000..d3c8f383db2a
--- /dev/null
+++ b/sys-apps/asahi-scripts/asahi-scripts-20240822.ebuild
@@ -0,0 +1,41 @@
+# Copyright 2022 James Calligeros <jcalligeros99@gmail.com>
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="8"
+
+DESCRIPTION="Apple Silicon support scripts"
+HOMEPAGE="https://asahilinux.org/"
+SRC_URI="https://github.com/AsahiLinux/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~arm64"
+
+RDEPEND="
+ virtual/udev
+"
+
+src_install() {
+ emake DESTDIR="${D}" PREFIX="/usr" SYS_PREFIX="" install-dracut
+ emake DESTDIR="${D}" PREFIX="/usr" install-macsmc-battery
+
+ newinitd "${FILESDIR}/${PN}-macsmc-battery.openrc" "macsmc-battery"
+
+ # install gentoo sys config
+ insinto /etc/default
+ newins "${FILESDIR}"/update-m1n1.gentoo.conf update-m1n1
+ exeinto /usr/lib/kernel/install.d/
+ doexe "${FILESDIR}/99-update-m1n1.install"
+}
+
+pkg_postinst() {
+ if [[ ! -e ${ROOT}/usr/lib/asahi-boot ]]; then
+ ewarn "These scripts are intended for use on Apple Silicon"
+ ewarn "machines with the Asahi tooling installed! Please"
+ ewarn "install sys-boot/m1n1, sys-boot/u-boot and"
+ ewarn "sys-firmware/asahi-firmware!"
+ fi
+
+ elog "Asahi scripts have been installed to /usr/. For more"
+ elog "information on how to use them, please visit the Wiki."
+}
diff --git a/sys-apps/asahi-scripts/files/99-update-m1n1.install b/sys-apps/asahi-scripts/files/99-update-m1n1.install
new file mode 100644
index 000000000000..ceab30398908
--- /dev/null
+++ b/sys-apps/asahi-scripts/files/99-update-m1n1.install
@@ -0,0 +1,2 @@
+#!/bin/bash
+update-m1n1
diff --git a/sys-apps/asahi-scripts/files/asahi-scripts-macsmc-battery.openrc b/sys-apps/asahi-scripts/files/asahi-scripts-macsmc-battery.openrc
new file mode 100644
index 000000000000..19e8363116fd
--- /dev/null
+++ b/sys-apps/asahi-scripts/files/asahi-scripts-macsmc-battery.openrc
@@ -0,0 +1,51 @@
+#!/sbin/openrc-run
+# Save and restore the SMC's charge end threshold
+
+extra_commands="save restore"
+
+depend() {
+ need udev
+}
+
+has_battery() {
+ if [ ! -e /sys/class/power_supply/macsmc-battery ]; then
+ eerror "macsmc-battery was not found!"
+ return 2
+ fi
+
+ return 0
+}
+
+restore() {
+ ebegin "Restoring macsmc-battery saved charge end threshold"
+
+ has_battery || return $?
+
+ if [ ! -e /etc/udev/macsmc-battery.conf ]; then
+ ewarn "No saved charge end threshold found! Saving current value..."
+ save
+ return $?
+ fi
+
+ sed -e 's/CHARGE_CONTROL_END_THRESHOLD=//' /etc/udev/macsmc-battery.conf > /sys/class/power_supply/macsmc-battery/charge_control_end_threshold
+ return 0
+}
+
+save() {
+ ebegin "Saving current macsmc-battery charge end threshold"
+
+ has_battery || return $?
+
+ sed -e 's/^/CHARGE_CONTROL_END_THRESHOLD=/' /sys/class/power_supply/macsmc-battery/charge_control_end_threshold > /etc/udev/macsmc-battery.conf
+ return 0
+}
+
+start() {
+ restore
+ eend $?
+}
+
+stop() {
+ save
+ eend $?
+}
diff --git a/sys-apps/asahi-scripts/files/update-m1n1.gentoo.conf b/sys-apps/asahi-scripts/files/update-m1n1.gentoo.conf
new file mode 100644
index 000000000000..64fecd746974
--- /dev/null
+++ b/sys-apps/asahi-scripts/files/update-m1n1.gentoo.conf
@@ -0,0 +1 @@
+DTBS=$(/bin/ls -d /boot/dtbs/* | sort -rV | head -1)/apple/*.dtb