PKGBUILD 10 KB

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