107 lines
3.3 KiB
Bash
107 lines
3.3 KiB
Bash
# Copyright 2026 Gentoo Authors
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
EAPI=8
|
|
|
|
inherit toolchain-funcs
|
|
|
|
MY_PV=${PV/_p/-}
|
|
MY_KV=${MY_PV}-cachyos-eac
|
|
SDBOOT_PV=262.2_1-1
|
|
KEY_PV=1-2
|
|
SETTINGS_PV=1.4.5-1
|
|
MIRROR=https://mirror.cachyos.org/repo/x86_64/cachyos
|
|
|
|
DESCRIPTION="CachyOS-signed kernel and systemd-boot for Easy Anti-Cheat Linux v2"
|
|
HOMEPAGE="https://wiki.cachyos.org/configuration/easy_anti_cheat/"
|
|
SRC_URI="
|
|
${MIRROR}/linux-cachyos-eac-${MY_PV}-x86_64.pkg.tar.zst
|
|
${MIRROR}/systemd-boot-cachyos-signed-${SDBOOT_PV}-x86_64.pkg.tar.zst
|
|
${MIRROR}/cachyos-eac-signing-key-${KEY_PV}-any.pkg.tar.zst
|
|
${MIRROR}/cachyos-settings-1%3A${SETTINGS_PV}-any.pkg.tar.zst
|
|
-> cachyos-settings-${SETTINGS_PV}-any.pkg.tar.zst
|
|
"
|
|
S=${WORKDIR}
|
|
|
|
LICENSE="GPL-2 LGPL-2.1+ GPL-3+ GPL-1"
|
|
SLOT="0"
|
|
KEYWORDS="~amd64"
|
|
# Stripping or re-signing anything here breaks the CachyOS signatures EAC checks.
|
|
RESTRICT="mirror strip"
|
|
|
|
RDEPEND="
|
|
app-crypt/efitools
|
|
app-crypt/sbctl
|
|
app-crypt/sbsigntools
|
|
app-crypt/tpm2-tools
|
|
dev-libs/openssl
|
|
sys-apps/kmod[zstd]
|
|
sys-boot/efibootmgr
|
|
sys-kernel/dracut
|
|
"
|
|
BDEPEND="
|
|
app-arch/zstd
|
|
sys-apps/kmod
|
|
virtual/pkgconfig
|
|
"
|
|
|
|
src_unpack() {
|
|
local f
|
|
for f in ${A}; do
|
|
tar -xf "${DISTDIR}/${f}" || die "unpacking ${f} failed"
|
|
done
|
|
}
|
|
|
|
src_prepare() {
|
|
default
|
|
# eac-status takes the ESP, kernel and boot loader locations from eac-boot.
|
|
sed -i \
|
|
-e 's#esp=$(bootctl --print-esp-path 2>/dev/null || echo /boot)#esp=$(eac-boot esp)#' \
|
|
-e 's#"$esp/$(cat /etc/machine-id)/linux-cachyos-eac#"$(eac-boot kernel-dir)#' \
|
|
-e 's#"$esp/EFI/cachyos-eac/systemd-bootx64.efi"#"$(eac-boot loader)"#' \
|
|
usr/bin/eac-status || die
|
|
grep -q 'esp=$(eac-boot esp)' usr/bin/eac-status || die "eac-status: ESP patch did not apply"
|
|
[[ $(grep -c '$(eac-boot kernel-dir)' usr/bin/eac-status) == 2 ]] || die "eac-status: kernel-dir patch did not apply"
|
|
grep -q '"$(eac-boot loader)"' usr/bin/eac-status || die "eac-status: loader patch did not apply"
|
|
}
|
|
|
|
src_install() {
|
|
# Wherever this system's kmod looks for modules (/lib/modules on Gentoo).
|
|
MODULES_DIR=$($(tc-getPKG_CONFIG) --variable=module_directory kmod)
|
|
: "${MODULES_DIR:=/lib/modules}"
|
|
|
|
dodir "${MODULES_DIR}"
|
|
cp -a "usr/lib/modules/${MY_KV}" "${ED}${MODULES_DIR}/" || die
|
|
fowners -R root:root "${MODULES_DIR}/${MY_KV}"
|
|
|
|
insinto /usr/lib/cachyos-eac
|
|
doins usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed
|
|
|
|
insinto /usr/share/cachyos-eac
|
|
doins usr/share/cachyos-eac/cachyos-eac-ca.{crt,der}
|
|
# Only used by `sbctl enroll-keys --custom` with sbctl's default keydir; eac-boot enroll reads the copy above.
|
|
insinto /var/lib/sbctl/keys/custom/db
|
|
doins var/lib/sbctl/keys/custom/db/cachyos-eac-ca.der
|
|
|
|
dosbin usr/bin/eac-status "${FILESDIR}"/eac-boot
|
|
dodoc "${FILESDIR}"/README.md
|
|
}
|
|
|
|
pkg_postinst() {
|
|
depmod -b "${EROOT:-/}" "${MY_KV}" || die
|
|
|
|
if [[ -z ${ROOT} && -f $(eac-boot loader 2>/dev/null) ]]; then
|
|
eac-boot update || ewarn "eac-boot update failed, run it by hand"
|
|
else
|
|
elog "First-time setup: eac-boot enroll, eac-boot setup, then enable Secure Boot."
|
|
elog "Boot it with eac-boot boot and check it with eac-status."
|
|
elog "Details: README in ${EROOT}/usr/share/doc/${PF}/"
|
|
fi
|
|
}
|
|
|
|
pkg_postrm() {
|
|
# depmod output is not owned by the package
|
|
[[ -n ${MODULES_DIR} && ! -d ${EROOT}${MODULES_DIR}/${MY_KV}/kernel ]] || return 0
|
|
rm -rf "${EROOT}${MODULES_DIR}/${MY_KV}"
|
|
}
|