# Maintainer: David P. # Contributor: André Silva # Contributor: Márcio Silva # Contributor: Nicolás Reynolds # Contributor: Sorin-Mihai Vârgolici # Contributor: Michał Masłowski # Contributor: Luke Shumaker # Contributor: Luke R. pkgbase=linux-libre-hardened _pkgbasever=4.16-gnu _pkgver=4.16.6-gnu _hardenedver=a _replacesarchkernel=('linux%') # '%' gets replaced with _kernelname _replacesoldkernels=() # '%' gets replaced with _kernelname _replacesoldmodules=() # '%' gets replaced with _kernelname _srcname=linux-${_pkgbasever%-*} _archpkgver=${_pkgver%-*} pkgver=${_pkgver//-/_}.${_hardenedver} pkgrel=1 arch=('x86_64') url="https://jxself.org/git/linux-libre-hardened.git" license=('GPL2') makedepends=('xmlto' 'kmod' 'inetutils' 'bc' 'libelf') makedepends_armv7h=('git') options=('!strip') source=( "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_pkgbasever}/linux-libre-${_pkgbasever}.tar.xz"{,.sign} "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_pkgver}/patch-${_pkgbasever}-${_pkgver}.xz"{,.sign} "https://github.com/anthraxx/linux-hardened/releases/download/${_pkgver%-*}.${_hardenedver}/linux-hardened-${_pkgver%-*}.${_hardenedver}.patch"{,.sig} "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_clut224.ppm"{,.sig} "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_mono.pbm"{,.sig} "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_vga16.ppm"{,.sig} # the main kernel config files 'config.x86_64' # pacman hooks for depmod and initramfs regeneration '60-linux.hook' '90-linux.hook' # standard config files for mkinitcpio ramdisk 'linux.preset' # other patches 'change-console-loglevel-motormouth.patch' '0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch' '0002-fix-Atmel-maXTouch-touchscreen-support.patch' 'drm-i915-edp-Only-use-the-alternate-fixed-mode-if-its-asked-for.patch' 'fix-vboxguest-on-guests-with-more-than-4G-RAM.patch' 'partially-revert-swiotlb-remove-various-exports.patch' ) validpgpkeys=( '474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva '65EEFE022108E2B708CBFCF7F9E712E59AF5F22A' # Daniel Micay '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78' # David P. 'E240B57E2C4630BA768E2F26FC1B547C8D8172C8' # Levente Polyak ) sha512sums=('c6805b3649cd71cfef272384958b33da23a00908e795592470bf711dd67886ab7d7610e7d4ae8a2230fa7483466636465ed9744444464a078de37b41c3db23e0' 'SKIP' '6e23ed3a88bae4be0b07424ad900adce3ca985050f23f5ab9878b54ae3bd8de1868f1dc52d8c66614be7016e2e3ae3efad78a415e4554048fad53fe2106c0b00' 'SKIP' '07e72b775cffbf259eb0febd51aeb90f737b465b45c785ceb61f221308c620747d60d2a870680a6264dc14dcde4c9006c8bdf8b2bded3988904ea7898d4400a7' 'SKIP' '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3' 'SKIP' '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1' 'SKIP' '7a3716bfe3b9f546da309c7492f3e08f8f506813afeb1c737a474c83313d5c313cf4582b65215c2cfce3b74d9d1021c96e8badafe8f6e5b01fe28d2b5c61ae78' 'SKIP' '5643b3fc465a6f1e238cb32f037f04a8f4d11961a31962fac2c2f0a7e6c372575868d2491643076906de0fa4f51e4a8f051af19362cb2d7b8b1fd8209f18fe0a' '7ad5be75ee422dda3b80edd2eb614d8a9181e2c8228cd68b3881e2fb95953bf2dea6cbe7900ce1013c9de89b2802574b7b24869fc5d7a95d3cc3112c4d27063a' '4a8b324aee4cccf3a512ad04ce1a272d14e5b05c8de90feb82075f55ea3845948d817e1b0c6f298f5816834ddd3e5ce0a0e2619866289f3c1ab8fd2f35f04f44' '2dc6b0ba8f7dbf19d2446c5c5f1823587de89f4e28e9595937dd51a87755099656f2acec50e3e2546ea633ad1bfd1c722e0c2b91eef1d609103d8abdc0a7cbaf' '0a1a18aa8a6cbf1bab406d356786d2c35fe52608c25bef8beefe440b8a015ba59375106f8b04051ae2225e158420875a82ee07d5b88a2f2087afeb102e8966c0' '02af4dd2a007e41db0c63822c8ab3b80b5d25646af1906dc85d0ad9bb8bbf5236f8e381d7f91cf99ed4b0978c50aee37cb9567cdeef65b7ec3d91b882852b1af' 'b8fe56e14006ab866970ddbd501c054ae37186ddc065bb869cf7d18db8c0d455118d5bda3255fb66a0dde38b544655cfe9040ffe46e41d19830b47959b2fb168' '46f470d6f4df2b697db656e262d20c198e623da7332da5e35299834480a6f1ef9d3567b4827a4f3a3bd83ef4c3082d95045a437fea1f22f83a76e07bed508e2d' '71408629596f01141ac45a9a8592dd91f4e3a6ed68c88cfe016fcc8128a3d770adedc4d0fe7f025d55afa67b8c0961d6d716256ef57e4aed473f788233244442' '4905635c0d94dedcc098a902b731cbfb63b2cbcdf35404a769cb71f257aead0977a526887e8d55badf9fd029ed2d125c9b8c38b0980bda028a667be0ebc0821b') _kernelname=${pkgbase#linux-libre} _grsecname=-grsec _replacesarchkernel=("${_replacesarchkernel[@]/\%/${_kernelname}}") _replacesarchgrsec=("${_replacesarchkernel[@]/${_kernelname}/${_grsecname}}") _replacesgrsec=("${pkgbase/${_kernelname}/${_grsecname}}") _replacesoldkernels=("${_replacesoldkernels[@]/\%/${_kernelname}}") _replacesoldmodules=("${_replacesoldmodules[@]/\%/${_kernelname}}") prepare() { cd ${_srcname} # add upstream patch if [ "${_pkgbasever}" != "${_pkgver}" ]; then patch -p1 -i ../patch-${_pkgbasever}-${_pkgver} fi # linux hardened patch patch -Np1 -i ../linux-hardened-${_pkgver%-*}.${_hardenedver}.patch # add freedo as boot logo install -m644 -t drivers/video/logo \ ../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm} # add latest fixes from stable queue, if needed # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git # https://bugs.archlinux.org/task/56711 patch -Np1 -i ../drm-i915-edp-Only-use-the-alternate-fixed-mode-if-its-asked-for.patch # NVIDIA driver compat patch -Np1 -i ../partially-revert-swiotlb-remove-various-exports.patch # https://bugs.archlinux.org/task/58153 patch -Np1 -i ../fix-vboxguest-on-guests-with-more-than-4G-RAM.patch # maintain the TTY over USB disconnects # http://www.coreboot.org/EHCI_Gadget_Debug patch -p1 -i ../0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch # fix Atmel maXTouch touchscreen support # https://labs.parabola.nu/issues/877 # http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html patch -p1 -i ../0002-fix-Atmel-maXTouch-touchscreen-support.patch # set CONSOLE_LOGLEVEL_MOTORMOUTH to 1 # https://labs.parabola.nu/issues/1754 patch -p1 -i ../change-console-loglevel-motormouth.patch cat ../config.${CARCH} - >.config </dev/null } build() { cd ${_srcname} make bzImage modules } _package() { pkgdesc="The ${pkgbase^} kernel and modules" [ "${pkgbase}" = "linux-libre" ] && groups=('base' 'base-openrc') depends=('coreutils' 'linux-libre-firmware' 'kmod' 'mkinitcpio>=0.7') optdepends=('crda: to set the correct wireless channels of your country') provides=("${_replacesarchkernel[@]/%/=${_archpkgver}}" "LINUX-ABI_VERSION=${_pkgver%%-*}") conflicts=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}") replaces=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}" "${_replacesarchgrsec[@]}" "${_replacesgrsec[@]}") backup=("etc/mkinitcpio.d/${pkgbase}.preset") install=linux.install cd ${_srcname} # get kernel version _kernver="$(make kernelrelease)" _basekernel=${_kernver%%-*} _basekernel=${_basekernel%.*} mkdir -p "${pkgdir}"/{boot,usr/lib/modules} make INSTALL_MOD_PATH="${pkgdir}/usr" modules_install cp arch/x86/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}" # make room for external modules local _extramodules="extramodules-${_basekernel}${_kernelname}" ln -s "../${_extramodules}" "${pkgdir}/usr/lib/modules/${_kernver}/extramodules" # add real version for building modules and running depmod from hook echo "${_kernver}" | install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_extramodules}/version" # remove build and source links rm "${pkgdir}"/usr/lib/modules/${_kernver}/{source,build} # now we call depmod... depmod -b "${pkgdir}/usr" -F System.map "${_kernver}" # add vmlinux install -Dt "${pkgdir}/usr/lib/modules/${_kernver}/build" -m644 vmlinux # sed expression for following substitutions local _subst=" s|%PKGBASE%|${pkgbase}|g s|%KERNVER%|${_kernver}|g s|%EXTRAMODULES%|${_extramodules}|g " # hack to allow specifying an initially nonexisting install file sed "${_subst}" "${startdir}/${install}" > "${startdir}/${install}.pkg" true && install=${install}.pkg # install mkinitcpio preset file sed "${_subst}" ../linux.preset | install -Dm644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset" # install pacman hooks sed "${_subst}" ../60-linux.hook | install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/60-${pkgbase}.hook" sed "${_subst}" ../90-linux.hook | install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook" } _package-headers() { pkgdesc="Header files and scripts for building modules for ${pkgbase^} kernel" provides=("${_replacesarchkernel[@]/%/-headers=${_archpkgver}}") conflicts=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}") replaces=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}" "${_replacesarchgrsec[@]/%/-headers}" "${_replacesgrsec[@]/%/-headers}") cd ${_srcname} local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build" install -Dt "${_builddir}" -m644 Makefile .config Module.symvers install -Dt "${_builddir}/kernel" -m644 kernel/Makefile mkdir "${_builddir}/.tmp_versions" cp -t "${_builddir}" -a include scripts install -Dt "${_builddir}/arch/x86" -m644 arch/x86/Makefile install -Dt "${_builddir}/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s cp -t "${_builddir}/arch/x86" -a arch/x86/include install -Dt "${_builddir}/drivers/md" -m644 drivers/md/*.h install -Dt "${_builddir}/net/mac80211" -m644 net/mac80211/*.h # http://bugs.archlinux.org/task/13146 install -Dt "${_builddir}/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h # http://bugs.archlinux.org/task/20402 install -Dt "${_builddir}/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h install -Dt "${_builddir}/drivers/media/tuners" -m644 drivers/media/tuners/*.h # add xfs and shmem for aufs building mkdir -p "${_builddir}"/{fs/xfs,mm} # copy in Kconfig files find . -name Kconfig\* -exec install -Dm644 {} "${_builddir}/{}" \; # add objtool for external module building and enabled VALIDATION_STACK option install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool # remove unneeded architectures local _arch for _arch in "${_builddir}"/arch/*/; do [[ ${_arch} == */x86/ ]] && continue rm -r "${_arch}" done # remove files already in linux-docs package rm -r "${_builddir}/Documentation" # remove now broken symlinks find -L "${_builddir}" -type l -printf 'Removing %P\n' -delete # Fix permissions chmod -R u=rwX,go=rX "${_builddir}" # strip scripts directory local _binary _strip while read -rd '' _binary; do case "$(file -bi "${_binary}")" in *application/x-sharedlib*) _strip="${STRIP_SHARED}" ;; # Libraries (.so) *application/x-archive*) _strip="${STRIP_STATIC}" ;; # Libraries (.a) *application/x-executable*) _strip="${STRIP_BINARIES}" ;; # Binaries *) continue ;; esac /usr/bin/strip ${_strip} "${_binary}" done < <(find "${_builddir}/scripts" -type f -perm -u+w -print0 2>/dev/null) } _package-docs() { pkgdesc="Kernel hackers manual - HTML documentation that comes with the ${pkgbase^} kernel" provides=("${_replacesarchkernel[@]/%/-docs=${_archpkgver}}") conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}") replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}" "${_replacesarchgrsec[@]/%/-docs}" "${_replacesgrsec[@]/%/-docs}") cd ${_srcname} local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build" mkdir -p "${_builddir}" cp -t "${_builddir}" -a Documentation # Fix permissions chmod -R u=rwX,go=rX "${_builddir}" } pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs") for _p in ${pkgname[@]}; do eval "package_${_p}() { $(declare -f "_package${_p#${pkgbase}}") _package${_p#${pkgbase}} }" done # vim:set ts=8 sts=2 sw=2 et: