# Maintainer: David P. # Contributor: André Silva # Contributor: Márcio Silva # Contributor: fauno # Contributor: Sorin-Mihai Vârgolici # Contributor: Michał Masłowski # Contributor: Luke Shumaker # Contributor: Luke R. # Contributor: Andreas Grapentin # Based on linux package pkgbase=linux-libre # Build stock kernel #pkgbase=linux-libre-custom # Build kernel with a different name _pkgbasever=4.17-gnu _pkgver=4.17.3-gnu _replacesarchkernel=('linux%') # '%' gets replaced with _kernelname _replacesoldkernels=() # '%' gets replaced with _kernelname _replacesoldmodules=() # '%' gets replaced with _kernelname _srcname=linux-${_pkgbasever%-*} _archpkgver=${_pkgver%-*} pkgver=${_pkgver//-/_} pkgrel=1 rcnrel=armv7-x3 arch=('i686' 'x86_64' 'armv7h') url="https://linux-libre.fsfla.org/" license=('GPL2') makedepends=('xmlto' 'kmod' 'inetutils' 'bc' 'libelf') 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://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.i686' 'config.x86_64' 'config.armv7h' # pacman hooks for depmod and initramfs regeneration '60-linux.hook' '90-linux.hook' # standard config files for mkinitcpio ramdisk 'linux.preset' # armv7h patches "https://repo.parabola.nu/other/rcn-libre/patches/${_pkgver%-*}/rcn-libre-${_pkgver%-*}-${rcnrel}.patch"{,.sig} '0001-ARM-atags-add-support-for-Marvell-s-u-boot.patch' '0002-ARM-atags-fdt-retrieve-MAC-addresses-from-Marvell-bo.patch' '0003-SMILE-Plug-device-tree-file.patch' '0004-fix-mvsdio-eMMC-timing.patch' '0005-net-smsc95xx-Allow-mac-address-to-be-set-as-a-parame.patch' '0006-set-default-cubietruck-led-triggers.patch' '0007-exynos4412-odroid-set-higher-minimum-buck2-regulator.patch' '0008-ARM-dove-enable-ethernet-on-D3Plug.patch' '0009-power-add-power-sequence-library.patch' '0010-usb-core-add-power-sequence-handling-for-USB-devices.patch' '0011-ARM-dts-imx6qdl-Enable-usb-node-children-with-reg.patch' '0012-ARM-dts-imx6qdl-udoo.dtsi-fix-onboard-USB-HUB-proper.patch' '0013-ARM-dts-imx6q-evi-Fix-onboard-hub-reset-line.patch' # other patches '0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch' '0002-fix-Atmel-maXTouch-touchscreen-support.patch' '0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch' '0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch' '0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.patch' ) validpgpkeys=( '474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78' # David P. ) sha512sums=('a09014005d64839e958cabb20dbd50e051907b1afea2f517f41f0a9312fa1bc8447690e64ec0e6488a778be8a7384891c003f39029ff5799f9884482628aadf2' 'SKIP' 'f885c0025d1c5c4a7b194fc0c59c602760a2e4bc382c8dd66987d8de8c4c18d463793d137c9beb0030edb63bedd215587e6bf3e254d8e03f1f59ffe49ee1752f' 'SKIP' '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3' 'SKIP' '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1' 'SKIP' '7a3716bfe3b9f546da309c7492f3e08f8f506813afeb1c737a474c83313d5c313cf4582b65215c2cfce3b74d9d1021c96e8badafe8f6e5b01fe28d2b5c61ae78' 'SKIP' '9a897b19362b258da51ca29cf9515e5bdcacb4cb8104cf348e093d9abed0a9a7d4ad998c23fef63ed2e481001b3551606f5e35906e8140fce51456853ef44023' '7878c940cdd241be4299d38427756f5f69635880bc130e2167dc998452aafcd43443f609c772d90b430cfffd95b6bec2037bd66a55f63f97c720067c62ff3436' '858be61cb6dfd5cafb6e4175902315433c62c733aad9f1a60a6f286c020c3beab0bb9cc7e8959a94644920689c362292d3659b0b9a69b91ecf69c77e8986d01e' '7ad5be75ee422dda3b80edd2eb614d8a9181e2c8228cd68b3881e2fb95953bf2dea6cbe7900ce1013c9de89b2802574b7b24869fc5d7a95d3cc3112c4d27063a' '4a8b324aee4cccf3a512ad04ce1a272d14e5b05c8de90feb82075f55ea3845948d817e1b0c6f298f5816834ddd3e5ce0a0e2619866289f3c1ab8fd2f35f04f44' '2dc6b0ba8f7dbf19d2446c5c5f1823587de89f4e28e9595937dd51a87755099656f2acec50e3e2546ea633ad1bfd1c722e0c2b91eef1d609103d8abdc0a7cbaf' 'e48864992df4f40d828a5dc5cb5d35e520b9d498638f0e44d2c2c21dc9b0555d3d211e655cf15bd2e1f5d23594f8f380aa2d8a4293b0cdf4dc6c53020ba6d421' 'SKIP' '8b946f1baa0ecbae0d70781ff67d9cc6ab4abbb8c5768bfd1fbf211de3a3d17f3b9c5a0e5bc588bd90a730051bdfb6b530ab2b30b8142e9adb33f84684b008fe' '382ae823f4a1c9105ab9bae6a5d2871eba7f1a888da3a2acdb17cecdbe542613f2f27bb5aaab236d205593bebb57cd91cb7d3de9b70b837f35c3eeb96ace44e3' '1f1826e3e1be079f6153e927151d3d0beaed5ed6b5032841d443f25d5af89c0c769d2ba00c5b95cb7338bc7bc04ea65a312116640431e7fbe17e9850f43df894' '1c578fa28c25557b2ad647974330c4238f3bd70212bda23d1eac45ca7815b573768ec88d61c7d2b61e59d48f58d25883b2f862124b6bacafde754b8883d6cdb5' '0be0572cee24d7d34782f8b0fb2e8597bd7ad1ccc2603e1fd7372f7e8cae9ba5f1e627aaa2960aa4f145032e2ddee11021a226bbcd1439c24a61cb66d82b13a6' 'c0568844b4eae0ff56ff4293d075b4523ef69e75c2ee0349c3a5460c18a048bafad3f95bad957fc3692c43d7843354ee0603048d17d73c6ac0b97162e1c295c2' 'dd889b8e64baef3f9fee6a75111f4e1c5c420a8c72e25d89ff0db765bd7fbbae985a7cc6327d8bdb80e32d59e7fca9dc2e0dee2c4811bfdbab32783ce29ea842' 'a34fc71e4dccadba3bef57cdb5fddb8524771b095a437d0449bc76da031dcc40edb083209f25731b58478a2c713f7245676adfed22a453a74aa85cf245a76944' '6cd12c8947a661fda1a1f0f1d84cfaa8d6f66300d4495a59131b7df1ed6b10ce21cddb3291d25f1ebb0798d9b711af68c18b46c34122425b21f946000ab743e8' 'ae2432ade54b0a703473ed804a08fc6346bf20b427dd56d0bd188bf56398aee3dc61e3e7740353943a7928992073894215f222c24a46fe5440a2058567ba5452' '09ee66f32cdc0d17a200e1f87175030a0180158840dec18be45f6329039f08100782a9f30af939a09f94fa4ab11739620c9993078555de5a5b1942affad3047f' '9a2ef810d62c2120e6a662f4c58e4644dac83e6fd8317ce7d5641421b89ac60de117204e4fa4024c76a61db495a066802af37c21a9470c536b8d86ae0ac398ba' '850e6b8684db4dd6946f69690caaa34a350228d3fed0e08b461835337250c78f511d064fb8fcd2003c5112e68fd9a66b61111c5e3ca4f53b80a0922d8d5f5fba' '02af4dd2a007e41db0c63822c8ab3b80b5d25646af1906dc85d0ad9bb8bbf5236f8e381d7f91cf99ed4b0978c50aee37cb9567cdeef65b7ec3d91b882852b1af' 'b8fe56e14006ab866970ddbd501c054ae37186ddc065bb869cf7d18db8c0d455118d5bda3255fb66a0dde38b544655cfe9040ffe46e41d19830b47959b2fb168' 'b6133ce52c3a900d34db23568aaf5cdffab3d50b5e9c2008f1f7fcc650cb434101c718b5446e525ebe71050b0591d3be66ac930cf9986c906abcc3bfcf42f763' '8ed1b4ef95120e9025299d9ae392cba49905bfcb29e3a1dfb9dd95a7925f25f52f57774b381410d70167cf2edef99271e7c12fac2b1aa4e9c8aa6655d150d22c' 'cddf8e907b4fbb5935a5239dd5a2b788b3f3fa1f91825d5191d154434a62c4dc16f4ccffc2ea4c5446d0c69457a918f9a2ca6d817bae3ddd694df4b50ab3e89b') _kernelname=${pkgbase#linux-libre} _replacesarchkernel=("${_replacesarchkernel[@]/\%/${_kernelname}}") _replacesoldkernels=("${_replacesoldkernels[@]/\%/${_kernelname}}") _replacesoldmodules=("${_replacesoldmodules[@]/\%/${_kernelname}}") case "${CARCH}" in i686|x86_64) KARCH=x86;; armv7h) KARCH=arm;; esac prepare() { cd ${_srcname} # add upstream patch if [ "${_pkgbasever}" != "${_pkgver}" ]; then patch -p1 -i ../patch-${_pkgbasever}-${_pkgver} fi if [ "${CARCH}" = "armv7h" ]; then # RCN patch (CM3 firmware deblobbed and AUFS/WireGuard removed) # Note: For stability reasons, AUFS has been removed in the RCN patch. # We are supporting AUFS in linux-libre-pck through PCK patch. # See https://wiki.parabola.nu/PCK for further details. patch -p1 -i ../rcn-libre-${_pkgver%-*}-${rcnrel}.patch # ALARM patches patch -p1 -i ../0001-ARM-atags-add-support-for-Marvell-s-u-boot.patch patch -p1 -i ../0002-ARM-atags-fdt-retrieve-MAC-addresses-from-Marvell-bo.patch patch -p1 -i ../0003-SMILE-Plug-device-tree-file.patch patch -p1 -i ../0004-fix-mvsdio-eMMC-timing.patch patch -p1 -i ../0005-net-smsc95xx-Allow-mac-address-to-be-set-as-a-parame.patch patch -p1 -i ../0006-set-default-cubietruck-led-triggers.patch patch -p1 -i ../0007-exynos4412-odroid-set-higher-minimum-buck2-regulator.patch patch -p1 -i ../0008-ARM-dove-enable-ethernet-on-D3Plug.patch patch -p1 -i ../0009-power-add-power-sequence-library.patch patch -p1 -i ../0010-usb-core-add-power-sequence-handling-for-USB-devices.patch patch -p1 -i ../0011-ARM-dts-imx6qdl-Enable-usb-node-children-with-reg.patch patch -p1 -i ../0012-ARM-dts-imx6qdl-udoo.dtsi-fix-onboard-USB-HUB-proper.patch patch -p1 -i ../0013-ARM-dts-imx6q-evi-Fix-onboard-hub-reset-line.patch fi # 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 # disable USER_NS for non-root users by default patch -Np1 -i ../0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch # https://bugs.archlinux.org/task/56711 patch -Np1 -i ../0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch # https://bugs.archlinux.org/task/56780 patch -Np1 -i ../0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.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 cat ../config.${CARCH} - >.config </dev/null } build() { cd ${_srcname} if [ "${CARCH}" = "armv7h" ]; then make ${MAKEFLAGS} LOCALVERSION= zImage modules dtbs elif [ "${CARCH}" = "x86_64" ] || [ "${CARCH}" = "i686" ]; then make ${MAKEFLAGS} LOCALVERSION= bzImage modules fi } _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[@]}") 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 if [ "${CARCH}" = "armv7h" ]; then make LOCALVERSION= INSTALL_DTBS_PATH="${pkgdir}/boot/dtbs/${pkgbase}" dtbs_install cp arch/$KARCH/boot/zImage "${pkgdir}/boot/vmlinuz-${pkgbase}" elif [ "${CARCH}" = "x86_64" ] || [ "${CARCH}" = "i686" ]; then cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}" fi # 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}" if [ "${CARCH}" = "x86_64" ] || [ "${CARCH}" = "i686" ]; then # add vmlinux install -Dt "${pkgdir}/usr/lib/modules/${_kernver}/build" -m644 vmlinux fi # sed expression for following substitutions if [ "${CARCH}" = "armv7h" ]; then local _subst=" s|/boot/vmlinuz-%PKGBASE%|${_kernver}|g s|%PKGBASE%|${pkgbase}|g s|%KERNVER%|${_kernver}|g s|%EXTRAMODULES%|${_extramodules}|g " elif [ "${CARCH}" = "x86_64" ] || [ "${CARCH}" = "i686" ]; then local _subst=" s|%PKGBASE%|${pkgbase}|g s|%KERNVER%|${_kernver}|g s|%EXTRAMODULES%|${_extramodules}|g " fi # 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}") 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/${KARCH}" -m644 arch/${KARCH}/Makefile install -Dt "${_builddir}/arch/${KARCH}/kernel" -m644 arch/${KARCH}/kernel/asm-offsets.s if [[ ${CARCH} = i686 ]]; then install -t "${_builddir}/arch/${KARCH}" -m644 arch/${KARCH}/Makefile_32.cpu fi cp -t "${_builddir}/arch/${KARCH}" -a arch/${KARCH}/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 if [[ -e tools/objtool/objtool ]]; then install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool fi # remove unneeded architectures local _arch for _arch in "${_builddir}"/arch/*/; do [[ ${_arch} == */${KARCH}/ ]] && continue rm -r "${_arch}" done # remove files already in linux-docs package rm -r "${_builddir}/Documentation" # parabola changes # # since we don't want to diverge too much from arch's pkgbuild, we'll # start marking our changes as such if [ "${CARCH}" = "armv7h" ]; then for i in dove exynos omap2; do mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/mach-${i}" cp -a arch/${KARCH}/mach-${i}/include "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/mach-${i}/" done for i in omap orion samsung versatile; do mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/plat-${i}" cp -a arch/${KARCH}/plat-${i}/include "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/plat-${i}/" done fi # end of parabola changes # 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}") 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: