Advertisement
Guest User

PKGBUILD - linux-lts

a guest
Apr 6th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.59 KB | None | 0 0
  1. # Maintainer: Andreas Radke <andyrtr@archlinux.org>
  2.  
  3. #pkgbase=linux-lts
  4. pkgbase=linux-lts-aura
  5. _srcname=linux-4.19
  6. pkgver=4.19.32
  7. pkgrel=1
  8. arch=('x86_64')
  9. url="https://www.kernel.org/"
  10. license=('GPL2')
  11. makedepends=('xmlto' 'kmod' 'inetutils' 'bc' 'libelf')
  12. options=('!strip')
  13. source=(https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.{xz,sign}
  14. https://www.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.xz
  15. 'config' # the main kernel config file
  16. '60-linux.hook' # pacman hook for depmod
  17. '90-linux.hook' # pacman hook for initramfs regeneration
  18. 'linux-lts.preset' # standard config files for mkinitcpio ramdisk
  19. 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
  20. 0002-Enable-overriding-of-arbitrary-min-brightness.patch)
  21. validpgpkeys=('ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds <torvalds@linux-foundation.org>
  22. '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman (Linux kernel stable release signing key) <greg@kroah.com>
  23. )
  24. # https://www.kernel.org/pub/linux/kernel/v4.x/sha256sums.asc
  25. sha256sums=('0c68f5655528aed4f99dae71a5b259edc93239fa899e2df79c055275c21749a1'
  26. 'SKIP'
  27. '85a7e12b38575199d2ed889b7cf108b7740f20f1fe4d967f1c338df1682b4259'
  28. '2dbe737dd5d186ca0b3b1753ad3d7a4a722b3eb03ec224dc24b49dd491c18cf1'
  29. 'ae2e95db94ef7176207c690224169594d49445e04249d2499e9d2fbc117a0b21'
  30. '75f99f5239e03238f88d1a834c50043ec32b1dc568f2cc291b07d04718483919'
  31. 'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65'
  32. '36b1118c8dedadc4851150ddd4eb07b1c58ac5bbf3022cc2501a27c2b476da98'
  33. 'f960ae7e4dfa6de28f65626770fe441eaab8f2caaa88e122bdaf6dbdc605bc56')
  34.  
  35. _kernelname=${pkgbase#linux}
  36.  
  37. prepare() {
  38. cd ${_srcname}
  39.  
  40. # add upstream patch
  41. patch -p1 -i ../patch-${pkgver}
  42. chmod +x tools/objtool/sync-check.sh # GNU patch doesn't support git-style file mode
  43.  
  44. # security patches
  45.  
  46. # add latest fixes from stable queue, if needed
  47. # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
  48.  
  49. # disable USER_NS for non-root users by default
  50. patch -Np1 -i ../0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
  51. patch -Np1 -i ../0002-Enable-overriding-of-arbitrary-min-brightness.patch
  52.  
  53. cp -Tf ../config .config
  54.  
  55. if [ "${_kernelname}" != "" ]; then
  56. sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  57. sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
  58. fi
  59.  
  60. # set extraversion to pkgrel
  61. sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
  62.  
  63. # don't run depmod on 'make install'. We'll do this ourselves in packaging
  64. sed -i '2iexit 0' scripts/depmod.sh
  65.  
  66. # get kernel version
  67. make prepare
  68.  
  69. # load configuration
  70. # Configure the kernel. Replace the line below with one of your choice.
  71. #make menuconfig # CLI menu for configuration
  72. #make nconfig # new CLI menu for configuration
  73. #make xconfig # X-based configuration
  74. #make oldconfig # using old config from previous kernel version
  75. # ... or manually edit .config
  76.  
  77. # rewrite configuration
  78. yes "" | make config >/dev/null
  79. }
  80.  
  81. build() {
  82. cd ${_srcname}
  83.  
  84. make ${MAKEFLAGS} LOCALVERSION= bzImage modules
  85. }
  86.  
  87. _package() {
  88. pkgdesc="The ${pkgbase/linux/Linux} kernel and modules"
  89. [ "${pkgbase}" = "linux" ] && groups=('base')
  90. depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
  91. optdepends=('crda: to set the correct wireless channels of your country')
  92. backup=("etc/mkinitcpio.d/${pkgbase}.preset")
  93. install=linux-lts.install
  94.  
  95. cd ${_srcname}
  96.  
  97. # get kernel version
  98. _kernver="$(make LOCALVERSION= kernelrelease)"
  99. _basekernel=${_kernver%%-*}
  100. _basekernel=${_basekernel%.*}
  101.  
  102. mkdir -p "${pkgdir}"/{boot,usr/lib/modules}
  103. make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}/usr" modules_install
  104. cp arch/x86/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}"
  105.  
  106. # systemd expects to find the kernel here to allow hibernation
  107. # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  108. ln -sr "${pkgdir}/boot/vmlinuz-${pkgbase}" "${pkgdir}/usr/lib/modules/${_kernver}/vmlinuz"
  109.  
  110. # make room for external modules
  111. local _extramodules="extramodules-${_basekernel}${_kernelname:--lts}"
  112. ln -s "../${_extramodules}" "${pkgdir}/usr/lib/modules/${_kernver}/extramodules"
  113.  
  114. # add real version for building modules and running depmod from hook
  115. echo "${_kernver}" |
  116. install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_extramodules}/version"
  117.  
  118. # remove build and source links
  119. rm "${pkgdir}"/usr/lib/modules/${_kernver}/{source,build}
  120.  
  121. # now we call depmod...
  122. depmod -b "${pkgdir}/usr" -F System.map "${_kernver}"
  123.  
  124. # add vmlinux
  125. install -Dt "${pkgdir}/usr/lib/modules/${_kernver}/build" -m644 vmlinux
  126.  
  127. # sed expression for following substitutions
  128. local _subst="
  129. s|%PKGBASE%|${pkgbase}|g
  130. s|%KERNVER%|${_kernver}|g
  131. s|%EXTRAMODULES%|${_extramodules}|g
  132. "
  133.  
  134. # hack to allow specifying an initially nonexisting install file
  135. sed "${_subst}" "${startdir}/${install}" > "${startdir}/${install}.pkg"
  136. true && install=${install}.pkg
  137.  
  138. # install mkinitcpio preset file
  139. sed "${_subst}" ../linux-lts.preset |
  140. install -Dm644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  141.  
  142. # install pacman hooks
  143. sed "${_subst}" ../60-linux.hook |
  144. install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/60-${pkgbase}.hook"
  145. sed "${_subst}" ../90-linux.hook |
  146. install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook"
  147. }
  148.  
  149. _package-headers() {
  150. pkgdesc="Header files and scripts for building modules for ${pkgbase/linux/Linux} kernel"
  151.  
  152. cd ${_srcname}
  153. local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build"
  154.  
  155. install -Dt "${_builddir}" -m644 Makefile .config Module.symvers
  156. install -Dt "${_builddir}/kernel" -m644 kernel/Makefile
  157.  
  158. mkdir "${_builddir}/.tmp_versions"
  159.  
  160. cp -t "${_builddir}" -a include scripts
  161.  
  162. install -Dt "${_builddir}/arch/x86" -m644 arch/x86/Makefile
  163. install -Dt "${_builddir}/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
  164.  
  165. cp -t "${_builddir}/arch/x86" -a arch/x86/include
  166.  
  167. install -Dt "${_builddir}/drivers/md" -m644 drivers/md/*.h
  168. install -Dt "${_builddir}/net/mac80211" -m644 net/mac80211/*.h
  169.  
  170. # http://bugs.archlinux.org/task/13146
  171. install -Dt "${_builddir}/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  172.  
  173. # http://bugs.archlinux.org/task/20402
  174. install -Dt "${_builddir}/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  175. install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  176. install -Dt "${_builddir}/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  177.  
  178. # add xfs and shmem for aufs building
  179. mkdir -p "${_builddir}"/{fs/xfs,mm}
  180.  
  181. # copy in Kconfig files
  182. find . -name Kconfig\* -exec install -Dm644 {} "${_builddir}/{}" \;
  183.  
  184. # add objtool for external module building and enabled VALIDATION_STACK option
  185. install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool
  186.  
  187. # remove unneeded architectures
  188. local _arch
  189. for _arch in "${_builddir}"/arch/*/; do
  190. [[ ${_arch} == */x86/ ]] && continue
  191. rm -r "${_arch}"
  192. done
  193.  
  194. # remove files already in linux-docs package
  195. rm -r "${_builddir}/Documentation"
  196.  
  197. # remove now broken symlinks
  198. find -L "${_builddir}" -type l -printf 'Removing %P\n' -delete
  199.  
  200. # Fix permissions
  201. chmod -R u=rwX,go=rX "${_builddir}"
  202.  
  203. # strip scripts directory
  204. local _binary _strip
  205. while read -rd '' _binary; do
  206. case "$(file -bi "${_binary}")" in
  207. *application/x-sharedlib*) _strip="${STRIP_SHARED}" ;; # Libraries (.so)
  208. *application/x-archive*) _strip="${STRIP_STATIC}" ;; # Libraries (.a)
  209. *application/x-executable*) _strip="${STRIP_BINARIES}" ;; # Binaries
  210. *) continue ;;
  211. esac
  212. /usr/bin/strip ${_strip} "${_binary}"
  213. done < <(find "${_builddir}/scripts" -type f -perm -u+w -print0 2>/dev/null)
  214. }
  215.  
  216. _package-docs() {
  217. pkgdesc="Kernel hackers manual - HTML documentation that comes with the ${pkgbase/linux/Linux} kernel"
  218.  
  219. cd ${_srcname}
  220. local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build"
  221.  
  222. mkdir -p "${_builddir}"
  223. cp -t "${_builddir}" -a Documentation
  224.  
  225. # Fix permissions
  226. chmod -R u=rwX,go=rX "${_builddir}"
  227. }
  228.  
  229. pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs")
  230. for _p in ${pkgname[@]}; do
  231. eval "package_${_p}() {
  232. $(declare -f "_package${_p#${pkgbase}}")
  233. _package${_p#${pkgbase}}
  234. }"
  235. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement