spacepaste

  1.  
  2. # $Id$
  3. # Maintainer: Tobias Powalowski <tpowa@archlinux.org>
  4. # Maintainer: Thomas Baechler <thomas@archlinux.org>
  5. #pkgbase=linux # Build stock -ARCH kernel
  6. pkgbase=linux-custom # Build kernel with a different name
  7. _srcname=linux-4.16
  8. pkgver=4.16.6
  9. pkgrel=1
  10. arch=('x86_64')
  11. url="https://www.kernel.org/"
  12. license=('GPL2')
  13. makedepends=('xmlto' 'kmod' 'inetutils' 'bc' 'libelf')
  14. options=('!strip')
  15. source=(
  16. https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.{xz,sign}
  17. https://www.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.{xz,sign}
  18. config # the main kernel config file
  19. 60-linux.hook # pacman hook for depmod
  20. 90-linux.hook # pacman hook for initramfs regeneration
  21. linux.preset # standard config files for mkinitcpio ramdisk
  22. 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
  23. 0002-drm-i915-edp-Only-use-the-alternate-fixed-mode-if-it.patch
  24. 0003-Partially-revert-swiotlb-remove-various-exports.patch
  25. 0004-Fix-vboxguest-on-guests-with-more-than-4G-RAM.patch
  26. patch_ca0132.patch
  27. )
  28. validpgpkeys=(
  29. 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
  30. '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
  31. )
  32. sha256sums=('63f6dc8e3c9f3a0273d5d6f4dca38a2413ca3a5f689329d05b750e4c87bb21b9'
  33. 'SKIP'
  34. '634d3fd97e5d9d90262db0a9d62ed0a40043eb691d68bd4a545f907079610b56'
  35. 'SKIP'
  36. '627aa44c65d7297b00a8a7045d606d33b6a0b982c02331a101b94d38d348082a'
  37. 'ae2e95db94ef7176207c690224169594d49445e04249d2499e9d2fbc117a0b21'
  38. '75f99f5239e03238f88d1a834c50043ec32b1dc568f2cc291b07d04718483919'
  39. 'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65'
  40. '0f9cd4d94ad4866925b800ed843faa6485719b67f3f46d406ea1424795f37d31'
  41. '7f7a425358830f2cb81f85e25b6047eca89350994e1deb160295082ccbd470ff'
  42. '9fe2ee26ba324f28a42e7acc3b164344d61796a68b9a8f8ec74cb0dfeb58620e'
  43. '94e8d80886c31dfe628d3537f1c30f8a3f79aea7e542aa77e9c4291dafed1679'
  44. 'SKIP')
  45. _kernelname=${pkgbase#linux}
  46. : ${_kernelname:=-ARCH}
  47. prepare() {
  48. cd ${_srcname}
  49. # add upstream patch
  50. patch -p1 -i ../patch-${pkgver}
  51. # add latest fixes from stable queue, if needed
  52. # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
  53. # disable USER_NS for non-root users by default
  54. patch -Np1 -i ../0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
  55. # https://bugs.archlinux.org/task/56711
  56. patch -Np1 -i ../0002-drm-i915-edp-Only-use-the-alternate-fixed-mode-if-it.patch
  57. # NVIDIA driver compat
  58. patch -Np1 -i ../0003-Partially-revert-swiotlb-remove-various-exports.patch
  59. # https://bugs.archlinux.org/task/58153
  60. patch -Np1 -i ../0004-Fix-vboxguest-on-guests-with-more-than-4G-RAM.patch
  61. patch -Np1 -i ../patch_ca0132.patch
  62. cat ../config - >.config <<END
  63. CONFIG_LOCALVERSION="${_kernelname}"
  64. CONFIG_LOCALVERSION_AUTO=n
  65. END
  66. # set extraversion to pkgrel and empty localversion
  67. sed -e "/^EXTRAVERSION =/s/=.*/= -${pkgrel}/" \
  68. -e "/^EXTRAVERSION =/aLOCALVERSION =" \
  69. -i Makefile
  70. # don't run depmod on 'make install'. We'll do this ourselves in packaging
  71. sed -i '2iexit 0' scripts/depmod.sh
  72. # get kernel version
  73. make prepare
  74. # load configuration
  75. # Configure the kernel. Replace the line below with one of your choice.
  76. #make menuconfig # CLI menu for configuration
  77. #make nconfig # new CLI menu for configuration
  78. #make xconfig # X-based configuration
  79. #make oldconfig # using old config from previous kernel version
  80. # ... or manually edit .config
  81. # rewrite configuration
  82. yes "" | make config >/dev/null
  83. }
  84. build() {
  85. cd ${_srcname}
  86. make bzImage modules
  87. }
  88. _package() {
  89. pkgdesc="The ${pkgbase/linux/Linux} kernel and modules"
  90. [ "${pkgbase}" = "linux" ] && groups=('base')
  91. depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
  92. optdepends=('crda: to set the correct wireless channels of your country')
  93. backup=("etc/mkinitcpio.d/${pkgbase}.preset")
  94. install=linux.install
  95. cd ${_srcname}
  96. # get kernel version
  97. _kernver="$(make kernelrelease)"
  98. _basekernel=${_kernver%%-*}
  99. _basekernel=${_basekernel%.*}
  100. mkdir -p "${pkgdir}"/{boot,usr/lib/modules}
  101. make INSTALL_MOD_PATH="${pkgdir}/usr" modules_install
  102. cp arch/x86/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}"
  103. # make room for external modules
  104. local _extramodules="extramodules-${_basekernel}${_kernelname}"
  105. ln -s "../${_extramodules}" "${pkgdir}/usr/lib/modules/${_kernver}/extramodules"
  106. # add real version for building modules and running depmod from hook
  107. echo "${_kernver}" |
  108. install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_extramodules}/version"
  109. # remove build and source links
  110. rm "${pkgdir}"/usr/lib/modules/${_kernver}/{source,build}
  111. # now we call depmod...
  112. depmod -b "${pkgdir}/usr" -F System.map "${_kernver}"
  113. # add vmlinux
  114. install -Dt "${pkgdir}/usr/lib/modules/${_kernver}/build" -m644 vmlinux
  115. # sed expression for following substitutions
  116. local _subst="
  117. s|%PKGBASE%|${pkgbase}|g
  118. s|%KERNVER%|${_kernver}|g
  119. s|%EXTRAMODULES%|${_extramodules}|g
  120. "
  121. # hack to allow specifying an initially nonexisting install file
  122. sed "${_subst}" "${startdir}/${install}" > "${startdir}/${install}.pkg"
  123. true && install=${install}.pkg
  124. # install mkinitcpio preset file
  125. sed "${_subst}" ../linux.preset |
  126. install -Dm644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  127. # install pacman hooks
  128. sed "${_subst}" ../60-linux.hook |
  129. install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/60-${pkgbase}.hook"
  130. sed "${_subst}" ../90-linux.hook |
  131. install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook"
  132. }
  133. _package-headers() {
  134. pkgdesc="Header files and scripts for building modules for ${pkgbase/linux/Linux} kernel"
  135. cd ${_srcname}
  136. local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build"
  137. install -Dt "${_builddir}" -m644 Makefile .config Module.symvers
  138. install -Dt "${_builddir}/kernel" -m644 kernel/Makefile
  139. mkdir "${_builddir}/.tmp_versions"
  140. cp -t "${_builddir}" -a include scripts
  141. install -Dt "${_builddir}/arch/x86" -m644 arch/x86/Makefile
  142. install -Dt "${_builddir}/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
  143. cp -t "${_builddir}/arch/x86" -a arch/x86/include
  144. install -Dt "${_builddir}/drivers/md" -m644 drivers/md/*.h
  145. install -Dt "${_builddir}/net/mac80211" -m644 net/mac80211/*.h
  146. # http://bugs.archlinux.org/task/13146
  147. install -Dt "${_builddir}/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
  148. # http://bugs.archlinux.org/task/20402
  149. install -Dt "${_builddir}/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  150. install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  151. install -Dt "${_builddir}/drivers/media/tuners" -m644 drivers/media/tuners/*.h
  152. # add xfs and shmem for aufs building
  153. mkdir -p "${_builddir}"/{fs/xfs,mm}
  154. # copy in Kconfig files
  155. find . -name Kconfig\* -exec install -Dm644 {} "${_builddir}/{}" \;
  156. # add objtool for external module building and enabled VALIDATION_STACK option
  157. install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool
  158. # remove unneeded architectures
  159. local _arch
  160. for _arch in "${_builddir}"/arch/*/; do
  161. [[ ${_arch} == */x86/ ]] && continue
  162. rm -r "${_arch}"
  163. done
  164. # remove files already in linux-docs package
  165. rm -r "${_builddir}/Documentation"
  166. # remove now broken symlinks
  167. find -L "${_builddir}" -type l -printf 'Removing %P\n' -delete
  168. # Fix permissions
  169. chmod -R u=rwX,go=rX "${_builddir}"
  170. # strip scripts directory
  171. local _binary _strip
  172. while read -rd '' _binary; do
  173. case "$(file -bi "${_binary}")" in
  174. *application/x-sharedlib*) _strip="${STRIP_SHARED}" ;; # Libraries (.so)
  175. *application/x-archive*) _strip="${STRIP_STATIC}" ;; # Libraries (.a)
  176. *application/x-executable*) _strip="${STRIP_BINARIES}" ;; # Binaries
  177. *) continue ;;
  178. esac
  179. /usr/bin/strip ${_strip} "${_binary}"
  180. done < <(find "${_builddir}/scripts" -type f -perm -u+w -print0 2>/dev/null)
  181. }
  182. _package-docs() {
  183. pkgdesc="Kernel hackers manual - HTML documentation that comes with the ${pkgbase/linux/Linux} kernel"
  184. cd ${_srcname}
  185. local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build"
  186. mkdir -p "${_builddir}"
  187. cp -t "${_builddir}" -a Documentation
  188. # Fix permissions
  189. chmod -R u=rwX,go=rX "${_builddir}"
  190. }
  191. pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs")
  192. for _p in ${pkgname[@]}; do
  193. eval "package_${_p}() {
  194. $(declare -f "_package${_p#${pkgbase}}")
  195. _package${_p#${pkgbase}}
  196. }"
  197. done
  198. # vim:set ts=8 sts=2 sw=2 et:
  199.