Advertisement
Guest User

Untitled

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