PKGBUILD 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. # Maintainer: David P. <megver83@parabola.nu>
  2. # Contributor: André Silva <emulatorman@hyperbola.info>
  3. # Contributor: Márcio Silva <coadde@hyperbola.info>
  4. # Based on linux-hardened package
  5. _replacesarchkernel=('linux%') # '%' gets replaced with kernel suffix
  6. _replacesoldkernels=() # '%' gets replaced with kernel suffix
  7. _replacesoldmodules=() # '%' gets replaced with kernel suffix
  8. pkgbase=linux-libre-hardened
  9. pkgver=5.11.11.hardened1
  10. pkgrel=1
  11. pkgdesc='Security-Hardened Linux-libre'
  12. url='https://linux-libre.fsfla.org/'
  13. arch=(x86_64)
  14. license=(GPL2)
  15. makedepends=(
  16. bc kmod libelf pahole cpio perl tar xz
  17. xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
  18. )
  19. options=('!strip')
  20. _srcname=linux-5.11
  21. _srctag=${pkgver%.*}-${pkgver##*.}
  22. source=(
  23. "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_srcname##*-}-gnu/linux-libre-${_srcname##*-}-gnu.tar.xz"{,.sign}
  24. "https://linux-libre.fsfla.org/pub/linux-libre/releases/${pkgver%.*}-gnu/patch-${_srcname##*-}-gnu-${pkgver%.*}-gnu.xz"{,.sign}
  25. "https://github.com/anthraxx/linux-hardened/releases/download/${_srctag}/linux-hardened-${_srctag}.patch"{,.sig}
  26. "https://repo.parabola.nu/other/linux-libre/logos/logo_linux_"{clut224.ppm,vga16.ppm,mono.pbm}{,.sig}
  27. config # the main kernel config file
  28. # maintain the TTY over USB disconnects
  29. # http://www.coreboot.org/EHCI_Gadget_Debug
  30. 0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch
  31. # fix Atmel maXTouch touchscreen support
  32. # https://labs.parabola.nu/issues/877
  33. # http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html
  34. 0002-fix-Atmel-maXTouch-touchscreen-support.patch
  35. # Arch Linux patches
  36. )
  37. validpgpkeys=(
  38. '474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva
  39. '65EEFE022108E2B708CBFCF7F9E712E59AF5F22A' # Daniel Micay
  40. '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78' # David P.
  41. 'E240B57E2C4630BA768E2F26FC1B547C8D8172C8' # Levente Polyak
  42. )
  43. sha512sums=('3a34006add9ea318b0c2863388925ba34d57d342535b00c9ebc61fbfc69ef206b64af21c35b101466508c4308b5da310743c8add74dd703e259612953104ae43'
  44. 'SKIP'
  45. 'b35fc1d243fa3fdfa2b50b8f01ccab297f958f497e58a104da18631fafe3923216f3f1e97b9c2bb9e719c8a7ae8cabe8198a1a82cb5e8e50488b64d7af4dc940'
  46. 'SKIP'
  47. '337023919483a10220b8b409d89047ee092202e4fc49af7165311f0793cfd373ab44e384e72dd8bfe886bdd9e0c7ce9bfec90bf9d4eb918ce55a2c5a2c6e8daf'
  48. 'SKIP'
  49. '13cb5bc42542e7b8bb104d5f68253f6609e463b6799800418af33eb0272cc269aaa36163c3e6f0aacbdaaa1d05e2827a4a7c4a08a029238439ed08b89c564bb3'
  50. 'SKIP'
  51. '7a3716bfe3b9f546da309c7492f3e08f8f506813afeb1c737a474c83313d5c313cf4582b65215c2cfce3b74d9d1021c96e8badafe8f6e5b01fe28d2b5c61ae78'
  52. 'SKIP'
  53. '267295aa0cea65684968420c68b32f1a66a22d018b9d2b2c1ef14267bcf4cb68aaf7099d073cbfefe6c25c8608bdcbbd45f7ac8893fdcecbf1e621abdfe9ecc1'
  54. 'SKIP'
  55. '03f76fca489d7203c9ff954c8868213bed0d312bebe1e2172636bb97c5eb61948bdacd48540234224a865fecab2063a5d3b5aa243ae174a760fad7c24601f517'
  56. '02af4dd2a007e41db0c63822c8ab3b80b5d25646af1906dc85d0ad9bb8bbf5236f8e381d7f91cf99ed4b0978c50aee37cb9567cdeef65b7ec3d91b882852b1af'
  57. 'b8fe56e14006ab866970ddbd501c054ae37186ddc065bb869cf7d18db8c0d455118d5bda3255fb66a0dde38b544655cfe9040ffe46e41d19830b47959b2fb168')
  58. _replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}")
  59. _replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}")
  60. _replacesoldmodules=("${_replacesoldmodules[@]/\%/${pkgbase#linux-libre}}")
  61. export KBUILD_BUILD_HOST=parabola
  62. export KBUILD_BUILD_USER=$pkgbase
  63. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  64. prepare() {
  65. cd $_srcname
  66. if [ "${_srcname##*-}" != "${pkgver%.*}" ]; then
  67. echo "Applying upstream patch..."
  68. patch -Np1 < "../patch-${_srcname##*-}-gnu-${pkgver%.*}-gnu"
  69. fi
  70. echo "Adding freedo as boot logo..."
  71. install -m644 -t drivers/video/logo \
  72. ../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}
  73. echo "Setting version..."
  74. sed -e "/^-EXTRAVERSION =/s/=/= -gnu/" -i "../linux-hardened-$_srctag.patch"
  75. scripts/setlocalversion --save-scmversion
  76. echo "-$pkgrel" > localversion.10-pkgrel
  77. echo "${pkgbase#linux-libre}" > localversion.20-pkgname
  78. local src
  79. for src in "${source[@]}"; do
  80. src="${src%%::*}"
  81. src="${src##*/}"
  82. [[ $src = *.patch ]] || continue
  83. echo "Applying patch $src..."
  84. patch -Np1 < "../$src"
  85. done
  86. echo "Setting config..."
  87. cp ../config .config
  88. make olddefconfig
  89. make -s kernelrelease > version
  90. echo "Prepared $pkgbase version $(<version)"
  91. }
  92. build() {
  93. cd $_srcname
  94. make all
  95. make htmldocs
  96. }
  97. _package() {
  98. pkgdesc="The $pkgdesc kernel and modules"
  99. depends=(coreutils kmod initramfs)
  100. optdepends=('crda: to set the correct wireless channels of your country'
  101. 'linux-libre-firmware: firmware images needed for some devices'
  102. 'usbctl: deny_new_usb control')
  103. provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
  104. provides+=("${_replacesarchkernel[@]/%/=${pkgver%.*}}" "LINUX-ABI_VERSION=${pkgver%.*}")
  105. conflicts=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  106. replaces=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  107. cd $_srcname
  108. local kernver="$(<version)"
  109. local modulesdir="$pkgdir/usr/lib/modules/$kernver"
  110. echo "Installing boot image..."
  111. # systemd expects to find the kernel here to allow hibernation
  112. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  113. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  114. # Used by mkinitcpio to name the kernel
  115. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  116. echo "Installing modules..."
  117. make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
  118. # remove build and source links
  119. rm "$modulesdir"/{source,build}
  120. }
  121. _package-headers() {
  122. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  123. provides=("${_replacesarchkernel[@]/%/-headers=${pkgver%.*}}")
  124. conflicts=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  125. replaces=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  126. cd $_srcname
  127. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  128. echo "Installing build files..."
  129. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  130. localversion.* version vmlinux
  131. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  132. install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
  133. cp -t "$builddir" -a scripts
  134. # add objtool for external module building and enabled VALIDATION_STACK option
  135. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  136. # add xfs and shmem for aufs building
  137. mkdir -p "$builddir"/{fs/xfs,mm}
  138. echo "Installing headers..."
  139. cp -t "$builddir" -a include
  140. cp -t "$builddir/arch/x86" -a arch/x86/include
  141. install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
  142. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  143. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  144. # http://bugs.archlinux.org/task/13146
  145. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  146. # http://bugs.archlinux.org/task/20402
  147. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  148. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  149. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  150. echo "Installing KConfig files..."
  151. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  152. echo "Removing unneeded architectures..."
  153. local arch
  154. for arch in "$builddir"/arch/*/; do
  155. [[ $arch = */x86/ ]] && continue
  156. echo "Removing $(basename "$arch")"
  157. rm -r "$arch"
  158. done
  159. echo "Removing documentation..."
  160. rm -r "$builddir/Documentation"
  161. echo "Removing broken symlinks..."
  162. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  163. echo "Removing loose objects..."
  164. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  165. echo "Stripping build tools..."
  166. local file
  167. while read -rd '' file; do
  168. case "$(file -bi "$file")" in
  169. application/x-sharedlib\;*) # Libraries (.so)
  170. strip -v $STRIP_SHARED "$file" ;;
  171. application/x-archive\;*) # Libraries (.a)
  172. strip -v $STRIP_STATIC "$file" ;;
  173. application/x-executable\;*) # Binaries
  174. strip -v $STRIP_BINARIES "$file" ;;
  175. application/x-pie-executable\;*) # Relocatable binaries
  176. strip -v $STRIP_SHARED "$file" ;;
  177. esac
  178. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  179. echo "Stripping vmlinux..."
  180. strip -v $STRIP_STATIC "$builddir/vmlinux"
  181. echo "Adding symlink..."
  182. mkdir -p "$pkgdir/usr/src"
  183. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  184. }
  185. _package-docs() {
  186. pkgdesc="Documentation for the $pkgdesc kernel"
  187. provides=("${_replacesarchkernel[@]/%/-docs=${pkgver%.*}}")
  188. conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  189. replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  190. cd $_srcname
  191. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  192. echo "Installing documentation..."
  193. local src dst
  194. while read -rd '' src; do
  195. dst="${src#Documentation/}"
  196. dst="$builddir/Documentation/${dst#output/}"
  197. install -Dm644 "$src" "$dst"
  198. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  199. echo "Adding symlink..."
  200. mkdir -p "$pkgdir/usr/share/doc"
  201. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  202. }
  203. pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
  204. for _p in "${pkgname[@]}"; do
  205. eval "package_$_p() {
  206. $(declare -f "_package${_p#$pkgbase}")
  207. _package${_p#$pkgbase}
  208. }"
  209. done
  210. # vim:set ts=8 sts=2 sw=2 et: