# Maintainer: jc_gargma # Maintainer (Arch): Levente Polyak # Contributor: Aqua-sama # Contributor (Arch): Daniel Micay # Contributor (Arch): Tobias Powalowski # Contributor (Arch): Thomas Baechler # # I maintain this because: # Parabola version patch script does not apply consistently # Parabola version lacks graysky gcc patch # Parabola version lacks ath9k regdom and raid6 algo patches # Parabola version is 300 Hz # Parabola version does not disable lockdown eee # Parabola version does not disable hdcp # Parabola version does not disable IME/PSP/TEE/SEV # Parabola version does not disable insecure filesystems # Parabola version does not disable VMware and HyperV _pkgbase=linux-hardened pkgbase=linux-libre-hardened _supver=5 _majver=10 _minver=17 _gccpatchver='20201113' _gccpatchger='10.1' _gccpatchker='5.8' _hardenedver=hardened1 if [ "$_minver" == "0" ]; then pkgver=${_supver}.${_majver} else pkgver=${_supver}.${_majver}.${_minver} fi pkgrel=1 pkgdesc='Security-Hardened Linux-libre' url='https://github.com/anthraxx/linux-hardened' arch=(x86_64) license=(GPL2) makedepends=( bc kmod libelf pahole cpio perl tar xz xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick ) #provides=('linux-libre-hardened') conflicts=('linux-hardened') options=('!strip') _srcname=linux-${_supver}.${_majver} _gnumajver=${_supver}.${_majver}-gnu _gnupkgver=${pkgver}-gnu source=( https://linux-libre.fsfla.org/pub/linux-libre/releases/${_gnumajver}/linux-libre-${_gnumajver}.tar.xz{,.sign} https://github.com/anthraxx/${_pkgbase}/releases/download/${pkgver}-${_hardenedver}/${_pkgbase}-${pkgver}-${_hardenedver}.patch{,.sig} config # the main kernel config file sphinx-workaround.patch # Sphinx 3.5 broke the build again 0002-HID-quirks-Add-Apple-Magic-Trackpad-2-to-hid_have_special_driver-list.patch kernel_gcc_patch-${_gccpatchver}.tar.gz::https://github.com/graysky2/kernel_gcc_patch/archive/${_gccpatchver}.tar.gz ath9k-regdom-hack.patch raid6-default-algo.patch ) if [ "$_minver" != "0" ]; then source+=(https://linux-libre.fsfla.org/pub/linux-libre/releases/${_gnupkgver}/patch-${_gnumajver}-${_gnupkgver}.xz{,.sign}) fi validpgpkeys=( '474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva 'E240B57E2C4630BA768E2F26FC1B547C8D8172C8' # Levente Polyak ) b2sums=('86103699a6bc906e85429430df098b0ddb7cfc8c887f98b37f994498388d634554e119eadb1b15f591bdf4f463e7efb7420e3e370af0029b7ed9e988a5f26b01' 'SKIP' '782a07c9b7b8e8e425e62c72458ae2babd489800180ea9af2ace43f290fb31dad1234eb6dea0db0e1507d3abfb4fa3d41107d7e8019a85205b55acc02179f732' 'SKIP' 'cefec4c8e794d53cd33ff54288647e696ee345bab140b271b19ba215cc6ae1900d5e21c0d3034d040cb6f6de307833c6df393b2edf88417f2505b3d8f37586e3' 'db64b425139c107c69f44624901ae50b5e604d4c9fdfe84f78c298f8ed7a7739033a72ec678c5c3c0e82e59809d97799d0c25f96c64ef5ae79910cb890fc7bfb' 'd8297e09f552a2d6bb24c2ba10481fd2b407057f3b24278e72a89233473460d339c83838791989773623178b5af80588fb4c484da2931f1040e313cce7ceca00' '7f1eb5938472f57748216bd00e0c875feab99fc1c5cb89babfea467ee30ca5c8e9fc5a691efe2e602bef1ea79820c5383822d7cec354b48d23321ccda8ee8127' 'b6ef77035611139fa9a6d5b8d30570e2781bb4da483bb569884b0bd0129b62e0b82a5a6776fefe43fee801c70d39de1ea4d4c177f7cedd5ac135e3c64f7b895a' 'fde132f3705d908e6f2147c78a2193289916d72304ca5efa2229d79fc3e57a857314ce94e71425caef2f7f7b6cf87f05ef86335dc8bd4be78e7035afe608005a' '72de1345d33b9e1819d2a0124728cbfa5d0e74425196c9aef319b91a9e60a7d6d56c508b949107722289adcc8db37973420486121ed964987af18de489627ca5' 'SKIP') export KBUILD_BUILD_HOST=arc4linux export KBUILD_BUILD_USER=$pkgbase export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" prepare() { cd $_srcname # add upstream patch if [ "$_minver" != "0" ]; then echo "Applying upstream patch" patch -Np1 < ../patch-${_gnumajver}-${_gnupkgver} fi # Remove the -gnu EXTRAVERSION sed -e "/^EXTRAVERSION =/s/= -gnu/=/" -i Makefile # Hotfixes echo "Applying hotfixes" patch -p1 -i ../0002-HID-quirks-Add-Apple-Magic-Trackpad-2-to-hid_have_special_driver-list.patch patch -p1 -i ../sphinx-workaround.patch # linux hardened patch echo "Applying hardened patch" patch -Np1 < ../linux-hardened-${pkgver}-${_hardenedver}.patch # Remove the -hardened EXTRAVERSION sed -e "/^EXTRAVERSION =/s/= -${_hardenedver}/= /" -i Makefile # graysky gcc patch echo "Applying graysky gcc patch" patch -p1 -i ../kernel_gcc_patch-${_gccpatchver}/enable_additional_cpu_optimizations_for_gcc_v${_gccpatchger}+_kernel_v${_gccpatchker}+.patch # Ignore ath9k eeprom patch echo "Applying ath9k patch" patch -p1 -i ../ath9k-regdom-hack.patch # Set default raid6 algo patch echo " Applying raid6 patch" patch -p1 -i ../raid6-default-algo.patch # Append pkgrel and patchset suffixes echo "Setting version..." scripts/setlocalversion --save-scmversion echo "-$pkgrel" > localversion.10-pkgrel echo "${pkgbase#linux}" > localversion.20-pkgname echo "Setting config..." # we are in src/linux-x.yy.zz, looking for a config next to the pkgbuild # if [ -f ${SRCDEST}/config.libre-hardened.previous ]; then # cp ${SRCDEST}/config.libre-hardened.previous .config # else cp ../config .config # fi make olddefconfig # make menuconfig # Remove sublevel when no sublevel exists if [ "$_minver" == "0" ]; then sed -i '/SUBLEVEL = 0/d' Makefile fi make -s kernelrelease > version # workaround for make -s kernelrelease not applying # localversion to version when changed using menuconfig grep -Po '(?<=CONFIG_LOCALVERSION=").*(?=")' .config > ../localversion echo "$pkgver" > ../version.temp cat "localversion.10-pkgrel" >> ../version.temp cat "localversion.20-pkgname" >> ../version.temp cat ../localversion >> ../version.temp cat ../version.temp | tr -d "\n" > version # back up the config # echo "Backing up config..." # cp .config ${SRCDEST}/config.libre-hardened.previous echo "Prepared $pkgbase version $(