Advertisement
Guest User

just_latest_rt_kernel_for_arch_linux

a guest
Feb 11th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.06 KB | None | 0 0
  1. # $Id: PKGBUILD 223919 2014-10-06 14:51:49Z tpowa $
  2. # Maintainer: Joakim Hernberg <jbh@alchemy.lu>
  3. # Contributor: Ray Rashif <schiv@archlinux.org>
  4. # Contributor: timbosa <tinny_tim@dodo.com.au>
  5. # Contributor: Tobias Powalowski <tpowa@archlinux.org>
  6. # Contributor: Thomas Baechler <thomas@archlinux.org>
  7. # Editor: You Neverknow <You_neverknow@noadress.noh>
  8. #pkgbase=linux # Build stock -ARCH kernel
  9. pkgbase=linux-rt # Build kernel with a different name
  10. _srcname=linux-4.9
  11. _pkgver=4.9.9
  12. _rtpatchver=rt6
  13. pkgver=${_pkgver}_${_rtpatchver}
  14. pkgrel=1
  15. arch=('i686' 'x86_64')
  16. url="https://www.kernel.org/"
  17. license=('GPL2')
  18. makedepends=('xmlto' 'docbook-xsl' 'kmod' 'inetutils' 'bc' 'libelf')
  19. options=('!strip')
  20. source=("https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.xz"
  21. "https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.sign"
  22. "https://www.kernel.org/pub/linux/kernel/v4.x/patch-${_pkgver}.xz"
  23. "https://www.kernel.org/pub/linux/kernel/v4.x/patch-${_pkgver}.sign"
  24. "https://www.kernel.org/pub/linux/kernel/projects/rt/4.9/older/patch-${_pkgver}-${_rtpatchver}.patch.xz"
  25. "https://www.kernel.org/pub/linux/kernel/projects/rt/4.9/older/patch-${_pkgver}-${_rtpatchver}.patch.sign"
  26. # the main kernel config files
  27. 'config' 'config.x86_64'
  28. # pacman hook for initramfs regeneration
  29. # '99-linux.hook'
  30. # standard config files for mkinitcpio ramdisk
  31. "${pkgbase}.preset"
  32. 'change-default-console-loglevel.patch'
  33. '0001-x86-fpu-Fix-invalid-FPU-ptrace-state-after-execve.patch')
  34.  
  35. sha256sums=('029098dcffab74875e086ae970e3828456838da6e0ba22ce3f64ef764f3d7f1a'
  36. 'SKIP'
  37. 'ec97e3bf8585865d409a804316b276a6b4e4939286de9757f99bfb41cf112078'
  38. 'SKIP'
  39. '405eb3b607e3e483732fcb4f7cca5330e7ace8a0c0b1db238536a77401d52ae6'
  40. 'SKIP'
  41. '88f1d3dc3e1570a4f0aae3733b5c4b666c68462c3a03550133762e5d22457fd9'
  42. 'fdc33cb2d09a9192046656285262fbca2bcab0b0cd09023da95890f87c0c8a72'
  43. '834bd254b56ab71d73f59b3221f056c72f559553c04718e350ab2a3e2991afe0'
  44. 'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65'
  45. '1256b241cd477b265a3c2d64bdc19ffe3c9bbcee82ea3994c590c2c76e767d99'
  46. '85f7612edfa129210343d6a4fe4ba2a4ac3542d98b7e28c8896738e7e6541c06'
  47. '3e955e0f1aae96bb6c1507236adc952640c9bd0a134b9995ab92106a33dc02d9')
  48.  
  49. validpgpkeys=('ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
  50. '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
  51. '64254695FFF0AA4466CC19E67B96E8162A8CF5D1' # Sebastian Andrzej Siewior
  52. '5ED9A48FC54C0A22D1D0804CEBC26CDB5A56DE73' # Steven Rostedt
  53. 'E644E2F1D45FA0B2EAA02F33109F098506FF0B14' # Thomas Gleixner
  54. )
  55.  
  56. _kernelname=${pkgbase#linux}
  57.  
  58. prepare() {
  59. cd "${srcdir}/${_srcname}"
  60.  
  61. # add upstream patch
  62. msg "applying patch-${_pkgver}"
  63. patch -p1 -i "${srcdir}/patch-${_pkgver}"
  64.  
  65. # add realtime patch
  66. msg "applying patch-${_pkgver}-${_rtpatchver}.patch"
  67. patch -p1 -i "${srcdir}/patch-${_pkgver}-${_rtpatchver}.patch"
  68.  
  69. # add latest fixes from stable queue, if needed
  70. # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
  71.  
  72. # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
  73. # remove this when a Kconfig knob is made available by upstream
  74. # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
  75. msg "change-default-console-loglevel.patch"
  76. patch -p1 -i "${srcdir}/change-default-console-loglevel.patch"
  77.  
  78. msg "All patches have successfully been applied"
  79.  
  80. if [ "${CARCH}" = "x86_64" ]; then
  81. cat "${srcdir}/config.x86_64" > ./.config
  82. else
  83. cat "${srcdir}/config" > ./.config
  84. fi
  85.  
  86. if [ "${_kernelname}" != "" ]; then
  87. sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"-${pkgrel}${_kernelname}\"|g" ./.config
  88. sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
  89. fi
  90.  
  91. # set extraversion to pkgrel
  92. # sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
  93.  
  94. # don't run depmod on 'make install'. We'll do this ourselves in packaging
  95. sed -i '2iexit 0' scripts/depmod.sh
  96.  
  97. # get kernel version
  98. make prepare
  99.  
  100. # load configuration
  101. # Configure the kernel. Replace the line below with one of your choice.
  102. #make menuconfig # CLI menu for configuration
  103. #make nconfig # new CLI menu for configuration
  104. #make xconfig # X-based configuration
  105. #make oldconfig # using old config from previous kernel version
  106. # ... or manually edit .config
  107.  
  108. # rewrite configuration
  109. yes "" | make config >/dev/null
  110. }
  111.  
  112. build() {
  113. cd "${srcdir}/${_srcname}"
  114.  
  115. make ${MAKEFLAGS} LOCALVERSION= bzImage modules
  116. }
  117.  
  118. _package() {
  119. pkgdesc="The ${pkgbase/linux/Linux} kernel and modules"
  120. [ "${pkgbase}" = "linux" ] && groups=('base')
  121. depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
  122. optdepends=('crda: to set the correct wireless channels of your country')
  123. backup=("etc/mkinitcpio.d/${pkgbase}.preset")
  124. install="${pkgbase}.install"
  125.  
  126. cd "${srcdir}/${_srcname}"
  127.  
  128. KARCH=x86
  129.  
  130. # get kernel version
  131. _kernver="$(make LOCALVERSION= kernelrelease)"
  132. _basekernel=${_kernver%%-*}
  133. _basekernel=${_basekernel%.*}
  134.  
  135. mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
  136. make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}" modules_install
  137. cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}"
  138.  
  139. # set correct depmod command for install
  140. sed -e "s|%PKGBASE%|${pkgbase}|g;s|%KERNVER%|${_kernver}|g" \
  141. "${startdir}/${install}" > "${startdir}/${install}.pkg"
  142. true && install=${install}.pkg
  143.  
  144. # install mkinitcpio preset file for kernel
  145. sed "s|%PKGBASE%|${pkgbase}|g" "${srcdir}/${pkgbase}.preset" |
  146. install -D -m644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  147.  
  148. # install pacman hook for initramfs regeneration
  149. # sed "s|%PKGBASE%|${pkgbase}|g" "${srcdir}/99-linux.hook" |
  150. # install -D -m644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/99-${pkgbase}.hook"
  151.  
  152. # remove build and source links
  153. rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
  154. # remove the firmware
  155. rm -rf "${pkgdir}/lib/firmware"
  156. # make room for external modules
  157. ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
  158. # add real version for building modules and running depmod from post_install/upgrade
  159. mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
  160. echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
  161.  
  162. # Now we call depmod...
  163. depmod -b "${pkgdir}" -F System.map "${_kernver}"
  164.  
  165. # move module tree /lib -> /usr/lib
  166. mkdir -p "${pkgdir}/usr"
  167. mv "${pkgdir}/lib" "${pkgdir}/usr/"
  168.  
  169. # add vmlinux
  170. install -D -m644 vmlinux "${pkgdir}/usr/lib/modules/${_kernver}/build/vmlinux"
  171. }
  172.  
  173. _package-headers() {
  174. pkgdesc="Header files and scripts for building modules for ${pkgbase/linux/Linux} kernel"
  175.  
  176. install -dm755 "${pkgdir}/usr/lib/modules/${_kernver}"
  177.  
  178. cd "${srcdir}/${_srcname}"
  179. install -D -m644 Makefile \
  180. "${pkgdir}/usr/lib/modules/${_kernver}/build/Makefile"
  181. install -D -m644 kernel/Makefile \
  182. "${pkgdir}/usr/lib/modules/${_kernver}/build/kernel/Makefile"
  183. install -D -m644 .config \
  184. "${pkgdir}/usr/lib/modules/${_kernver}/build/.config"
  185.  
  186. mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/include"
  187.  
  188. for i in acpi asm-generic config crypto drm generated keys linux math-emu \
  189. media net pcmcia scsi soc sound trace uapi video xen; do
  190. cp -a include/${i} "${pkgdir}/usr/lib/modules/${_kernver}/build/include/"
  191. done
  192.  
  193. # copy arch includes for external modules
  194. mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/x86"
  195. cp -a arch/x86/include "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/x86/"
  196.  
  197. # copy files necessary for later builds, like nvidia and vmware
  198. cp Module.symvers "${pkgdir}/usr/lib/modules/${_kernver}/build"
  199. cp -a scripts "${pkgdir}/usr/lib/modules/${_kernver}/build"
  200.  
  201. # fix permissions on scripts dir
  202. chmod og-w -R "${pkgdir}/usr/lib/modules/${_kernver}/build/scripts"
  203. mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/.tmp_versions"
  204.  
  205. mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/kernel"
  206.  
  207. cp arch/${KARCH}/Makefile "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/"
  208.  
  209. if [ "${CARCH}" = "i686" ]; then
  210. cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/"
  211. fi
  212.  
  213. cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/kernel/"
  214.  
  215. # add docbook makefile
  216. # install -D -m644 Documentation/DocBook/Makefile \
  217. # "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/DocBook/Makefile"
  218.  
  219. # add dm headers
  220. mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/md"
  221. cp drivers/md/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/md"
  222.  
  223. # add inotify.h
  224. mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/include/linux"
  225. cp include/linux/inotify.h "${pkgdir}/usr/lib/modules/${_kernver}/build/include/linux/"
  226.  
  227. # add xfs and shmem for aufs building
  228. # mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/fs/xfs"
  229. # mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/mm"
  230. # removed in 3.17 series
  231. # cp fs/xfs/xfs_sb.h "${pkgdir}/usr/lib/modules/${_kernver}/build/fs/xfs/xfs_sb.h"
  232.  
  233. # copy in Kconfig files
  234. for i in $(find . -name "Kconfig*"); do
  235. mkdir -p "${pkgdir}"/usr/lib/modules/${_kernver}/build/`echo ${i} | sed 's|/Kconfig.*||'`
  236. cp ${i} "${pkgdir}/usr/lib/modules/${_kernver}/build/${i}"
  237. done
  238.  
  239. # add objtool for external module building and enabled VALIDATION_STACK option
  240. if [ -f tools/objtool/objtool ]; then
  241. mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/tools/objtool"
  242. cp -a tools/objtool/objtool ${pkgdir}/usr/lib/modules/${_kernver}/build/tools/objtool/
  243. fi
  244.  
  245. chown -R root.root "${pkgdir}/usr/lib/modules/${_kernver}/build"
  246. find "${pkgdir}/usr/lib/modules/${_kernver}/build" -type d -exec chmod 755 {} \;
  247.  
  248. # strip scripts directory
  249. find "${pkgdir}/usr/lib/modules/${_kernver}/build/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
  250. case "$(file -bi "${binary}")" in
  251. *application/x-sharedlib*) # Libraries (.so)
  252. /usr/bin/strip ${STRIP_SHARED} "${binary}";;
  253. *application/x-archive*) # Libraries (.a)
  254. /usr/bin/strip ${STRIP_STATIC} "${binary}";;
  255. *application/x-executable*) # Binaries
  256. /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
  257. esac
  258. done
  259.  
  260. # remove unneeded architectures
  261. rm -rf "${pkgdir}"/usr/lib/modules/${_kernver}/build/arch/{alpha,arc,arm,arm26,arm64,avr32,blackfin,c6x,cris,frv,h8300,hexagon,ia64,m32r,m68k,m68knommu,metag,mips,microblaze,mn10300,openrisc,parisc,powerpc,ppc,s390,score,sh,sh64,sparc,sparc64,tile,unicore32,um,v850,xtensa}
  262.  
  263. # remove a files already in linux-docs package
  264. rm -f "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/kbuild/Kconfig.recursion-issue-01"
  265. rm -f "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/kbuild/Kconfig.recursion-issue-02"
  266. rm -f "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/kbuild/Kconfig.select-break"
  267. }
  268.  
  269. _package-docs() {
  270. pkgdesc="Kernel hackers manual - HTML documentation that comes with the ${pkgbase/linux/Linux} kernel"
  271.  
  272. cd "${srcdir}/${_srcname}"
  273.  
  274. mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build"
  275. cp -al Documentation "${pkgdir}/usr/lib/modules/${_kernver}/build"
  276. find "${pkgdir}" -type f -exec chmod 444 {} \;
  277. find "${pkgdir}" -type d -exec chmod 755 {} \;
  278.  
  279. # remove a file already in linux package
  280. rm -f "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/DocBook/Makefile"
  281. }
  282.  
  283. pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs")
  284. for _p in ${pkgname[@]}; do
  285. eval "package_${_p}() {
  286. $(declare -f "_package${_p#${pkgbase}}")
  287. _package${_p#${pkgbase}}
  288. }"
  289. done
  290.  
  291. # vim:set ts=8 sts=2 sw=2 et:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement