# Maintainer: Milan P. Stanić _flavor=asahi-gpu pkgname=linux-${_flavor} pkgver=6.1.0 kver=${pkgver//_/-} pkgdesc="Apple Silicon (M1 development kernel)" case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=1 _commit_id=f9c7334caaa6c85f4ef1c920198e248630493004 url="https://www.kernel.org" depends="initramfs-generator m1n1 u-boot-asahi" _depends_dev="perl gmp-dev elfutils-dev bash flex bison" makedepends="$_depends_dev sed bc linux-headers installkernel linux-firmware-any openssl-dev diffutils findutils" options="!strip !check" #subpackages="$pkgname-dev:_dev:$CBUILD_ARCH" source="linux-asahi-$pkgver-${_commit_id}.tar.gz::https://github.com/AsahiLinux/linux/archive/${_commit_id}.tar.gz config sensors.patch fix-drm-atomic.patch t8103-j293.dts.patch t600x-enable-speaker.patch " builddir="$srcdir/"linux-$_commit_id arch="aarch64" _carch="arm64" license="GPL-2.0" prepare() { local _patch_failed= cd $builddir case $pkgver in *.*.0);; *) msg "Applying patch-$pkgver.xz" # unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N ;; esac # first apply patches in specified order for i in $source; do case $i in *.patch) msg "Applying $i..." if ! patch -s -p1 -N -i "$srcdir"/$i; then echo $i >>failed _patch_failed=1 fi ;; esac done if ! [ -z "$_patch_failed" ]; then error "The following patches failed:" cat failed return 1 fi sed -i 's/^#EXTRAVERSION =/EXTRAVERSION =/' "$builddir"/Makefile sed -i 's/^EXTRAVERSION :=/#EXTRAVERSION :=/' "$builddir"/Makefile # remove localversion from patch if any rm -f localversion* oldconfig } oldconfig() { echo "-$pkgrel-$_flavor" > "$builddir"/localversion-alpine \ || return 1 cp "$srcdir"/config "$builddir"/.config make LLVM=1 -C "$srcdir"/linux-$_commit_id \ O="$builddir" \ ARCH="$_carch" \ listnewconfig oldconfig } build() { unset LDFLAGS export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" cd $builddir make LLVM=1 ARCH="$_carch" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" } _package() { local _buildflavor="$1" _outdir="$2" local _abi_release=${kver}-${pkgrel}-${_buildflavor} export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" cd $builddir # modules_install seems to regenerate a defect Modules.symvers on s390x. Work # around it by backing it up and restore it after modules_install cp Module.symvers Module.symvers.backup mkdir -p "$_outdir"/boot "$_outdir"/lib/modules local _install case "$CARCH" in arm*|aarch64) _install="zinstall dtbs_install";; *) _install=install;; esac make LLVM=1 -j1 modules_install $_install \ ARCH="$_carch" \ INSTALL_MOD_PATH="$_outdir" \ INSTALL_PATH="$_outdir"/boot \ INSTALL_DTBS_PATH="$_outdir/boot/dtbs-$_buildflavor" cp Module.symvers.backup Module.symvers rm -f "$_outdir"/lib/modules/${_abi_release}/build \ "$_outdir"/lib/modules/${_abi_release}/source rm -rf "$_outdir"/lib/firmware install -D -m644 include/config/kernel.release \ "$_outdir"/usr/share/kernel/$_buildflavor/kernel.release cp "$builddir"/.config $pkgdir/boot/config-$_flavor } # main flavor installs in $pkgdir package() { depends="$depends linux-firmware-any" _package $_flavor "$pkgdir" } _dev() { local _flavor=$(echo $subpkgname | sed -E 's/(^linux-|-dev$)//g') local _abi_release=${pkgver}-${pkgrel}-$_flavor # copy the only the parts that we really need for build 3rd party # kernel modules and install those as /usr/src/linux-headers, # simlar to what ubuntu does # # this way you dont need to install the 300-400 kernel sources to # build a tiny kernel module # pkgdesc="Headers and script for third party modules for $_flavor kernel" depends="$_depends_dev" local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release} export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" # first we import config, run prepare to set up for building # external modules, and create the scripts mkdir -p "$dir" cp "$srcdir"/config-$_flavor.${CARCH} "$dir"/.config echo "-$pkgrel-$_flavor" > "$dir"/localversion-alpine cd $builddir echo "Installing headers..." cp -t "$dir" -a $builddir/include install -Dt "${dir}" -m644 $builddir/Makefile install -Dt "${dir}/arch/${_carch}" -m644 $builddir/arch/${_carch}/Makefile install -Dt "${dir}/arch/${_carch}/kernel" -m644 $builddir/arch/${_carch}/kernel/asm-offsets.s cp -t "${dir}/arch/${_carch}" -a $builddir/arch/${_carch}/include install -Dt "$dir/drivers/md" -m644 drivers/md/*.h install -Dt "$dir/net/mac80211" -m644 net/mac80211/*.h # https://bugs.archlinux.org/task/13146 install -Dt "$dir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h # https://bugs.archlinux.org/task/20402 install -Dt "$dir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h install -Dt "$dir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h install -Dt "$dir/drivers/media/tuners" -m644 drivers/media/tuners/*.h # https://bugs.archlinux.org/task/71392 install -Dt "$dir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h echo "Installing KConfig files..." find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \; echo "Removing unneeded architectures..." local arch for arch in "$dir"/arch/*/; do case $(basename "$arch") in $_carch) continue ;; esac echo "Removing $(basename "$arch")" rm -r "$arch" done # echo "Removing documentation..." # rm -r "$builddir/Documentation" echo "Removing broken symlinks..." find -L "$builddir" -type l -printf 'Removing %P\n' -delete echo "Removing loose objects..." find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete echo "Stripping build tools..." local file while read -rd '' file; do case "$(file -bi "$file")" in application/x-sharedlib\;*) # Libraries (.so) strip -v $STRIP_SHARED "$file" ;; application/x-archive\;*) # Libraries (.a) strip -v $STRIP_STATIC "$file" ;; application/x-executable\;*) # Binaries strip -v $STRIP_BINARIES "$file" ;; application/x-pie-executable\;*) # Relocatable binaries strip -v $STRIP_SHARED "$file" ;; esac done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0) echo "Stripping vmlinux..." strip -v $STRIP_STATIC "$builddir/vmlinux" echo "Adding symlink..." mkdir -p "$subpkgdir"/lib/modules/${_abi_release} ln -sf /usr/src/linux-headers-${_abi_release} \ "$subpkgdir"/lib/modules/${_abi_release}/build } sha512sums=" c42294f30b28561fca5c7ef51b9f8e911def8f95af91c5b36954afaa893f011ba84436cdf1b2c102002e0f245c2eb5bb40d3819cd3ae63b93f1c942a6c21b689 linux-asahi-6.1.0-f9c7334caaa6c85f4ef1c920198e248630493004.tar.gz bb54c1db794502de02c5bac481f41b939efedaa5280f1002989f9ecc130f4355c9454e48f6d526fc93442add8d147cc90c0a25798462c090de919450a4c896b4 config 49dfcbc7e3d6d01fde548bfa4174e011fbb36ece94853d856e028f768da3ab156f77c01e0642e6d91f5f024f0c97d5de5847bb064e2a033f3237dfc66768049e sensors.patch c85a56d045f53bed26d066fe7bf5bf8f46867a96a6a8c8046c3720f42f6f303162b449bffea57d91a0bcf0b9ad701dcb5ef36659f4b88fec3016af6a6963f3aa fix-drm-atomic.patch 84c2cc2a01f52c7815e6c85d2b16118f7cdd1754ed9b5fbc6357a722dd66b30825428a497aaf5512e2596487afa0ca844ae6569b3bf277bb6bbf78e47cc05a7f t8103-j293.dts.patch a42700005e58d26710814c9b13aab36bc6d4242a5ebf9eb694473c5f3172c4a63cc235ea743eeec41d4bbac80565b4d34fc07eb23f2aa4c7c5e4b8ff0ec2b4fa t600x-enable-speaker.patch "