Skip to content

Commit 7bdce6d

Browse files
clarisSkirmisher
authored andcommitted
New package: asahi-base
1 parent 0eab923 commit 7bdce6d

5 files changed

Lines changed: 163 additions & 0 deletions

File tree

srcpkgs/asahi-base/files/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright The Asahi Linux Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This conf adds modules necessary for using Linux on Apple Silicon Macs,
2+
# which are not otherwise included due to being soft dependencies.
3+
4+
# For NVMe & SMC
5+
add_drivers+=" apple-mailbox "
6+
7+
# For NVMe
8+
add_drivers+=" nvme_apple "
9+
10+
# For USB and HID
11+
add_drivers+=" pinctrl-apple-gpio "
12+
13+
# For USB
14+
add_drivers+=" i2c-apple tps6598x apple-dart dwc3 dwc3-of-simple xhci-pci pcie-apple "
15+
16+
# For HID
17+
add_drivers+=" spi-apple spi-hid-apple spi-hid-apple-of "
18+
19+
# For RTC
20+
add_drivers+=" rtc-macsmc simple-mfd-spmi spmi-apple-controller nvmem_spmi_mfd "
21+
22+
# SMC drivers that are builtins with the current config
23+
#add_drivers+=" macsmc macsmc-rtkit gpio_macsmc "
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: MIT
3+
4+
set -e
5+
6+
BOOT_PART="/boot"
7+
BOOT_ROOT="$(grub-mkrelpath $BOOT_PART)"
8+
BOOT_ROOT="${BOOT_ROOT:-/}"
9+
EFI_PART="/boot/efi"
10+
GRUB_DIR="$BOOT_PART/grub"
11+
CONFIG="$GRUB_DIR/grub.cfg"
12+
TARGET="$EFI_PART/EFI/BOOT/BOOTAA64.EFI"
13+
MODULES="ext2 fat part_gpt search"
14+
15+
[ -f /etc/default/update-grub-image ] && . /etc/default/update-grub-image
16+
17+
uuid="$(grub-probe "$BOOT_PART" -t fs_uuid)"
18+
part="$(grub-probe "$BOOT_PART" -t drive | sed -e 's/(.*,/hd0,/' | tr -d ')')"
19+
20+
if [ -z "$uuid" ]; then
21+
echo "Error: Unable to determine boot filesystem UUID"
22+
exit 1
23+
fi
24+
25+
echo "UUID: $uuid"
26+
echo "Partition: $part"
27+
28+
cat > /tmp/grub-core.cfg <<EOF
29+
search.fs_uuid $uuid root $part
30+
set prefix=(\$root)"$BOOT_ROOT/grub"
31+
EOF
32+
33+
echo "Generating GRUB image..."
34+
mkdir -p "$GRUB_DIR/arm64-efi"
35+
grub-mkimage \
36+
--directory '/usr/lib/grub/arm64-efi' \
37+
-c /tmp/grub-core.cfg \
38+
--prefix "$part$BOOT_ROOT/grub" \
39+
--output "$GRUB_DIR"/arm64-efi/core.efi \
40+
--format arm64-efi \
41+
--compression auto \
42+
$MODULES
43+
44+
mkdir -p "$(dirname $TARGET)"
45+
cp "$GRUB_DIR"/arm64-efi/core.efi "$TARGET"
46+
rm /tmp/grub-core.cfg
47+
48+
grub-mkconfig -o "$CONFIG"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: MIT
3+
4+
set -e
5+
6+
VENDORFW=/boot/efi/vendorfw
7+
TARGET=/lib/firmware
8+
TARGET_MANIFEST=".vendorfw.manifest"
9+
10+
[ -f /etc/default/update-vendor-firmware ] && . /etc/default/update-vendor-firmware
11+
12+
if [ ! -d "$VENDORFW" ]; then
13+
echo "No vendor firmware available"
14+
exit 0
15+
fi
16+
17+
if [ ! -f "$VENDORFW/manifest.txt" ]; then
18+
echo "$VENDORFW/manifest.txt not found"
19+
exit 1
20+
fi
21+
22+
if [ ! -f "$VENDORFW/firmware.tar" ]; then
23+
echo "$VENDORFW/firmware.tar not found"
24+
exit 1
25+
fi
26+
27+
mkdir -p "$TARGET"
28+
cd "$TARGET"
29+
30+
[ -f "$TARGET_MANIFEST" ] && \
31+
cmp -s "$TARGET_MANIFEST" "$VENDORFW/manifest.txt" && exit 0
32+
33+
echo "Extracting updated vendor firmware..."
34+
tar xf "$VENDORFW/firmware.tar"
35+
36+
if [ -f "$TARGET_MANIFEST" ]; then
37+
echo "Cleaning up obsolete firmware..."
38+
manifest_sorted=$(mktemp)
39+
target_manifest_sorted=$(mktemp)
40+
sort "$VENDORFW/manifest.txt" | "$manifest_sorted"
41+
sort "$TARGET_MANIFEST" | "$target_manifest_sorted"
42+
comm "$manifest_sorted" "$target_manifest_sorted" -13 \
43+
| while read type name rest; do
44+
rm -v "$name" || true
45+
dir="$(dirname "$name")"
46+
rmdir "$dir" 2>/dev/null || true
47+
done
48+
rm "$manifest_sorted" "$target_manifest_sorted"
49+
fi
50+
51+
cp "$VENDORFW/manifest.txt" "$TARGET_MANIFEST"
52+
53+
echo "Done"

srcpkgs/asahi-base/template

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Template file for 'asahi-base'
2+
pkgname=asahi-base
3+
version=20220327
4+
revision=1
5+
archs="aarch64*"
6+
build_style=meta
7+
depends="linux-asahi asahi-uboot m1n1 dracut"
8+
short_desc="Void Linux Apple Silicon support package"
9+
maintainer="Will Springer <skirmisher@protonmail.com>"
10+
license="MIT"
11+
homepage="http://asahilinux.org"
12+
13+
do_install() {
14+
vbin "$FILESDIR/update-grub-image"
15+
vbin "$FILESDIR/update-vendor-firmware"
16+
vinstall "$FILESDIR/dracut-asahi.conf" 644 usr/lib/dracut/dracut.conf.d 10-asahi.conf
17+
vlicense "$FILESDIR/LICENSE"
18+
}

0 commit comments

Comments
 (0)