PKGBUILD 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. # Maintainer: David P. <megver83@parabola.nu>
  2. # Contributor: André Silva <emulatorman@hyperbola.info>
  3. # Contributor: Márcio Silva <coadde@hyperbola.info>
  4. # Contributor: Nicolás Reynolds <fauno@kiwwwi.com.ar>
  5. # Contributor: Sorin-Mihai Vârgolici <smv@yobicore.org>
  6. # Contributor: Michał Masłowski <mtjm@mtjm.eu>
  7. # Contributor: Luke R. <g4jc@openmailbox.org>
  8. # Based on linux-zen package
  9. # NOTE: Don't build htmldocs due to an error in sphinx
  10. _replacesarchkernel=('linux-zen')
  11. _replacesoldkernels=()
  12. _replacesoldmodules=()
  13. pkgbase=linux-libre-pck
  14. pkgver=5.11.11.pck1
  15. pkgrel=1
  16. pkgdesc='Linux-libre PCK'
  17. url='https://wiki.parabola.nu/PCK'
  18. arch=(i686 x86_64 armv7h)
  19. license=(GPL2)
  20. makedepends=(
  21. bc kmod libelf pahole cpio perl tar xz
  22. # xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
  23. )
  24. options=('!strip')
  25. _srcname=linux-5.11
  26. source=(
  27. "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_srcname##*-}-gnu/linux-libre-${_srcname##*-}-gnu.tar.xz"{,.sign}
  28. "https://linux-libre.fsfla.org/pub/linux-libre/releases/${pkgver%.*}-gnu/patch-${_srcname##*-}-gnu-${pkgver%.*}-gnu.xz"{,.sign}
  29. "https://repo.parabola.nu/other/pck/patches/${pkgver%.*}-gnu/patch-${pkgver%.*}-gnu-${pkgver##*.}.patch"{,.sig}
  30. config.i686 config.x86_64 config.armv7h # the main kernel config files
  31. linux-armv7h.preset # armv7h preset file for mkinitcpio ramdisk
  32. )
  33. validpgpkeys=(
  34. '474402C8C582DAFBE389C427BCB7CF877E7D47A7' # Alexandre Oliva
  35. '6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78' # David P.
  36. )
  37. sha512sums=('3a34006add9ea318b0c2863388925ba34d57d342535b00c9ebc61fbfc69ef206b64af21c35b101466508c4308b5da310743c8add74dd703e259612953104ae43'
  38. 'SKIP'
  39. 'b35fc1d243fa3fdfa2b50b8f01ccab297f958f497e58a104da18631fafe3923216f3f1e97b9c2bb9e719c8a7ae8cabe8198a1a82cb5e8e50488b64d7af4dc940'
  40. 'SKIP'
  41. 'fbd93c24e2615c2265e1feee8f6de3b9fc1c9f4192ff9b457f78689c4ceba094fb4fb80f723649f182cbda56cede932b188f9868cfb1f1bd0f17739734c8a41f'
  42. 'SKIP'
  43. '70ad0dc4c02670dfc6e7cbe45c018a2cc969638c99a807d1efb67043afef33f10462eacaf6f992401279d64b83093f3f39d0ec1d4d556efacca699835e5a7e1b'
  44. '90d48fb7c87684934904b98ebc0823cc30c9ebb31ccad95e2bf005b18597119af1d793d5a766b93c6cc7de16cca934c52d3a7b7ae5187931c71d89eac7e8f67a'
  45. '6728253ca04a603ef35ceb06b284c509d8ffda6a8c6403fe687afe5d956425588ebbd62bfc5dd1d7fd9a03071a30c7cd86ac72a1fd67cbbf1ebdac85ee703caf'
  46. '53103bf55b957b657039510527df0df01279dec59cda115a4d6454e4135025d4546167fa30bdc99107f232561c1e096d8328609ab5a876cf7017176f92ad3e0b')
  47. _replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}")
  48. _replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}")
  49. _replacesoldmodules=("${_replacesoldmodules[@]/\%/${pkgbase#linux-libre}}")
  50. case "$CARCH" in
  51. i686|x86_64) KARCH=x86;;
  52. armv7h) KARCH=arm;;
  53. esac
  54. export KBUILD_BUILD_HOST=parabola
  55. export KBUILD_BUILD_USER=$pkgbase
  56. export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
  57. prepare() {
  58. cd $_srcname
  59. if [ "${_srcname##*-}" != "${pkgver%.*}" ]; then
  60. echo "Applying upstream patch..."
  61. patch -Np1 < "../patch-${_srcname##*-}-gnu-${pkgver%.*}-gnu"
  62. fi
  63. echo "Setting version..."
  64. scripts/setlocalversion --save-scmversion
  65. echo "-$pkgrel" > localversion.10-pkgrel
  66. echo "${pkgbase#linux-libre}" > localversion.20-pkgname
  67. local src
  68. for src in "${source[@]}"; do
  69. src="${src%%::*}"
  70. src="${src##*/}"
  71. [[ $src = *.patch ]] || continue
  72. echo "Applying patch $src..."
  73. patch -Np1 < "../$src"
  74. done
  75. echo "Setting config..."
  76. cp ../config.$CARCH .config
  77. make olddefconfig
  78. make -s kernelrelease > version
  79. echo "Prepared $pkgbase version $(<version)"
  80. }
  81. build() {
  82. cd $_srcname
  83. make all
  84. # make htmldocs
  85. }
  86. _package() {
  87. pkgdesc="The $pkgdesc kernel and modules"
  88. depends=(coreutils kmod initramfs)
  89. optdepends=('crda: to set the correct wireless channels of your country'
  90. 'linux-libre-firmware: firmware images needed for some devices')
  91. provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE VHBA-MODULE)
  92. provides+=("${_replacesarchkernel[@]/%/=${pkgver//pck/zen}}" "LINUX-ABI_VERSION=${pkgver%.*}")
  93. conflicts+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  94. replaces+=("${_replacesarchkernel[@]}" "${_replacesoldkernels[@]}" "${_replacesoldmodules[@]}")
  95. cd $_srcname
  96. local kernver="$(<version)"
  97. local modulesdir="$pkgdir/usr/lib/modules/$kernver"
  98. echo "Installing boot image..."
  99. # systemd expects to find the kernel here to allow hibernation
  100. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  101. install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
  102. # Used by mkinitcpio to name the kernel
  103. echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
  104. echo "Installing modules..."
  105. make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
  106. # remove build and source links
  107. rm "$modulesdir"/{source,build}
  108. if [ "$CARCH" = "armv7h" ]; then
  109. echo "Installing device tree binaries..."
  110. make INSTALL_DTBS_PATH="$pkgdir/boot/dtbs/$pkgbase" dtbs_install
  111. # armv7h presets only work with ALL_kver=$kernver
  112. backup=("etc/mkinitcpio.d/$pkgbase.preset")
  113. echo "Installing mkinitcpio preset..."
  114. sed "s|%PKGBASE%|$pkgbase|g;s|%KERNVER%|$kernver|g" ../linux-armv7h.preset \
  115. | install -Dm644 /dev/stdin "$pkgdir/etc/mkinitcpio.d/$pkgbase.preset"
  116. fi
  117. }
  118. _package-headers() {
  119. pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  120. depends=(pahole)
  121. provides=("${_replacesarchkernel[@]/%/-headers=${pkgver//pck/zen}}")
  122. conflicts=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  123. replaces=("${_replacesarchkernel[@]/%/-headers}" "${_replacesoldkernels[@]/%/-headers}")
  124. cd $_srcname
  125. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  126. echo "Installing build files..."
  127. install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
  128. localversion.* version vmlinux
  129. install -Dt "$builddir/kernel" -m644 kernel/Makefile
  130. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile
  131. if [[ $CARCH = i686 ]]; then
  132. install -Dt "$builddir/arch/$KARCH" -m644 arch/$KARCH/Makefile_32.cpu
  133. fi
  134. cp -t "$builddir" -a scripts
  135. # add objtool for external module building and enabled VALIDATION_STACK option
  136. if [[ -e tools/objtool/objtool ]]; then
  137. install -Dt "$builddir/tools/objtool" tools/objtool/objtool
  138. fi
  139. # add xfs and shmem for aufs building
  140. mkdir -p "$builddir"/{fs/xfs,mm}
  141. echo "Installing headers..."
  142. cp -t "$builddir" -a include
  143. cp -t "$builddir/arch/$KARCH" -a arch/$KARCH/include
  144. install -Dt "$builddir/arch/$KARCH/kernel" -m644 arch/$KARCH/kernel/asm-offsets.s
  145. # from linux-armv7
  146. if [ "$CARCH" = "armv7h" ]; then
  147. for i in dove omap2; do
  148. mkdir -p "$builddir/arch/$KARCH/mach-$i"
  149. cp -t "$builddir/arch/$KARCH/mach-$i/" -a arch/$KARCH/mach-$i/include
  150. done
  151. for i in omap orion versatile; do
  152. mkdir -p "$builddir/arch/$KARCH/plat-$i"
  153. cp -t "$builddir/arch/$KARCH/plat-$i/" -a arch/$KARCH/plat-$i/include
  154. done
  155. fi
  156. install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  157. install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
  158. # http://bugs.archlinux.org/task/13146
  159. install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  160. # http://bugs.archlinux.org/task/20402
  161. install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  162. install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  163. install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  164. echo "Installing KConfig files..."
  165. find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
  166. echo "Removing unneeded architectures..."
  167. local arch
  168. for arch in "$builddir"/arch/*/; do
  169. [[ $arch = */$KARCH/ ]] && continue
  170. echo "Removing $(basename "$arch")"
  171. rm -r "$arch"
  172. done
  173. echo "Removing documentation..."
  174. rm -r "$builddir/Documentation"
  175. echo "Removing broken symlinks..."
  176. find -L "$builddir" -type l -printf 'Removing %P\n' -delete
  177. echo "Removing loose objects..."
  178. find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
  179. echo "Stripping build tools..."
  180. local file
  181. while read -rd '' file; do
  182. case "$(file -bi "$file")" in
  183. application/x-sharedlib\;*) # Libraries (.so)
  184. strip -v $STRIP_SHARED "$file" ;;
  185. application/x-archive\;*) # Libraries (.a)
  186. strip -v $STRIP_STATIC "$file" ;;
  187. application/x-executable\;*) # Binaries
  188. strip -v $STRIP_BINARIES "$file" ;;
  189. application/x-pie-executable\;*) # Relocatable binaries
  190. strip -v $STRIP_SHARED "$file" ;;
  191. esac
  192. done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
  193. echo "Stripping vmlinux..."
  194. strip -v $STRIP_STATIC "$builddir/vmlinux"
  195. echo "Adding symlink..."
  196. mkdir -p "$pkgdir/usr/src"
  197. ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
  198. }
  199. _package-docs() {
  200. pkgdesc="Documentation for the $pkgdesc kernel"
  201. provides=("${_replacesarchkernel[@]/%/-docs=${pkgver//pck/zen}}")
  202. conflicts=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  203. replaces=("${_replacesarchkernel[@]/%/-docs}" "${_replacesoldkernels[@]/%/-docs}")
  204. cd $_srcname
  205. local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
  206. echo "Installing documentation..."
  207. local src dst
  208. while read -rd '' src; do
  209. dst="${src#Documentation/}"
  210. dst="$builddir/Documentation/${dst#output/}"
  211. install -Dm644 "$src" "$dst"
  212. done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
  213. echo "Adding symlink..."
  214. mkdir -p "$pkgdir/usr/share/doc"
  215. ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
  216. }
  217. pkgname=("$pkgbase" "$pkgbase-headers") # "$pkgbase-docs"
  218. for _p in "${pkgname[@]}"; do
  219. eval "package_$_p() {
  220. $(declare -f "_package${_p#$pkgbase}")
  221. _package${_p#$pkgbase}
  222. }"
  223. done
  224. # vim:set ts=8 sts=2 sw=2 et: