Advertisement
marwanpro

PKGBUILD Kernel Linux 4.9 (fixed Xorg)

Jan 22nd, 2017
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 11.28 KB | None | 0 0
  1. # Maintainer: Boohbah <boohbah at gmail.com>
  2. # Contributor: Tobias Powalowski <tpowa@archlinux.org>
  3. # Contributor: Thomas Baechler <thomas@archlinux.org>
  4. # Contributor: Jonathan Chan <jyc@fastmail.fm>
  5. # Contributor: misc <tastky@gmail.com>
  6. # Contributor: NextHendrix <cjones12 at sheffield.ac.uk>
  7.  
  8. pkgbase=linux-tip
  9. _srcname=drm-tip
  10. pkgver=r648211.5ef04beec703
  11. pkgrel=1
  12. arch=('i686' 'x86_64')
  13. url="http://www.kernel.org/"
  14. license=('GPL2')
  15. makedepends=('xmlto' 'docbook-xsl' 'kmod' 'inetutils' 'bc' 'git' 'libelf')
  16. options=('!strip')
  17. source=('git+https://anongit.freedesktop.org/git/drm-tip.git'
  18.         # the main kernel config files
  19.         'config' 'config.x86_64'
  20.         # standard config files for mkinitcpio ramdisk
  21.         "${pkgbase}.preset")
  22. sha256sums=('SKIP'
  23.             '42e99e3f9f09a18d333352dfc01f12380cfdaf83ad14a1ba8fc83d1db9001343'
  24.             'faff71d141ede8cd29713035cd504b96d2edc8c85e413dc19da15762973f6905'
  25.             'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65')
  26.  
  27. _kernelname=${pkgbase#linux}
  28.  
  29. pkgver() {
  30.   cd "${_srcname}"
  31.   printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
  32. }
  33.  
  34. prepare() {
  35.   cd "${_srcname}"
  36.  
  37.   if [ "${CARCH}" = "x86_64" ]; then
  38.     cat "${srcdir}/config.x86_64" > ./.config
  39.   else
  40.     cat "${srcdir}/config" > ./.config
  41.   fi
  42.  
  43.   # set localversion to git commit
  44.   sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"-${pkgver##*.}\"|g" ./.config
  45.   sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
  46.  
  47.   # don't run depmod on 'make install'. We'll do this ourselves in packaging
  48.   sed -i '2iexit 0' scripts/depmod.sh
  49.  
  50.   # load configuration
  51.   # Configure the kernel. Replace the line below with one of your choice.
  52.   #make menuconfig # CLI menu for configuration
  53.   #make nconfig # new CLI menu for configuration
  54.   #make xconfig # X-based configuration
  55.   #make oldconfig # using old config from previous kernel version
  56.   make olddefconfig # old config from previous kernel, defaults for new options
  57.   # ... or manually edit .config
  58.  
  59.   # get kernel version
  60.   make prepare
  61.  
  62.   # rewrite configuration
  63.   yes "" | make config >/dev/null
  64. }
  65.  
  66. build() {
  67.   cd "${_srcname}"
  68.  
  69.   make ${MAKEFLAGS} LOCALVERSION= bzImage modules
  70. }
  71.  
  72. _package() {
  73.   pkgdesc="The Linux kernel and modules (git version)"
  74.   depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
  75.   optdepends=('crda: to set the correct wireless channels of your country')
  76.   provides=('linux')
  77.   backup=("etc/mkinitcpio.d/${pkgbase}.preset")
  78.   install=linux.install
  79.  
  80.   cd "${_srcname}"
  81.  
  82.   KARCH=x86
  83.  
  84.   # get kernel version
  85.   _kernver="$(make LOCALVERSION= kernelrelease)"
  86.   _basekernel=${_kernver%%-*}
  87.   _basekernel=${_basekernel%.*}
  88.  
  89.   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
  90.   make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}" modules_install
  91.   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}"
  92.  
  93.   # set correct depmod command for install
  94.   cp -f "${startdir}/${install}" "${startdir}/${install}.pkg"
  95.   true && install=${install}.pkg
  96.   sed \
  97.     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/" \
  98.     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/" \
  99.     -i "${startdir}/${install}"
  100.  
  101.   # install mkinitcpio preset file for kernel
  102.   install -D -m644 "${srcdir}/${pkgbase}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  103.   sed \
  104.     -e "1s|'linux.*'|'${pkgbase}'|" \
  105.     -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgbase}\"|" \
  106.     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgbase}.img\"|" \
  107.     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgbase}-fallback.img\"|" \
  108.     -i "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  109.  
  110.   # remove build and source links
  111.   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
  112.   # remove the firmware
  113.   rm -rf "${pkgdir}/lib/firmware"
  114.   # make room for external modules
  115.   ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
  116.   # add real version for building modules and running depmod from post_install/upgrade
  117.   mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
  118.   echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
  119.  
  120.   # Now we call depmod...
  121.   depmod -b "${pkgdir}" -F System.map "${_kernver}"
  122.  
  123.   # move module tree /lib -> /usr/lib
  124.   mkdir -p "${pkgdir}/usr"
  125.   mv "${pkgdir}/lib" "${pkgdir}/usr/"
  126.  
  127.   # add vmlinux
  128.   install -D -m644 vmlinux "${pkgdir}/usr/lib/modules/${_kernver}/build/vmlinux"
  129.  
  130.   # add System.map
  131.   install -D -m644 System.map "${pkgdir}/boot/System.map-${_kernver}"
  132. }
  133.  
  134. _package-headers() {
  135.   pkgdesc="Header files and scripts for building modules for Linux kernel (git version)"
  136.   provides=('linux-headers')
  137.  
  138.   install -dm755 "${pkgdir}/usr/lib/modules/${_kernver}"
  139.  
  140.   cd "${_srcname}"
  141.   install -D -m644 Makefile \
  142.     "${pkgdir}/usr/lib/modules/${_kernver}/build/Makefile"
  143.   install -D -m644 kernel/Makefile \
  144.     "${pkgdir}/usr/lib/modules/${_kernver}/build/kernel/Makefile"
  145.   install -D -m644 .config \
  146.     "${pkgdir}/usr/lib/modules/${_kernver}/build/.config"
  147.  
  148.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/include"
  149.  
  150.   for i in acpi asm-generic config crypto drm generated keys linux math-emu \
  151.     media net pcmcia scsi sound trace uapi video xen; do
  152.     cp -a include/${i} "${pkgdir}/usr/lib/modules/${_kernver}/build/include/"
  153.   done
  154.  
  155.   # copy arch includes for external modules
  156.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/x86"
  157.   cp -a arch/x86/include "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/x86/"
  158.  
  159.   # copy files necessary for later builds, like nvidia and vmware
  160.   cp Module.symvers "${pkgdir}/usr/lib/modules/${_kernver}/build"
  161.   cp -a scripts "${pkgdir}/usr/lib/modules/${_kernver}/build"
  162.  
  163.   # fix permissions on scripts dir
  164.   chmod og-w -R "${pkgdir}/usr/lib/modules/${_kernver}/build/scripts"
  165.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/.tmp_versions"
  166.  
  167.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/kernel"
  168.  
  169.   cp arch/${KARCH}/Makefile "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/"
  170.  
  171.   if [ "${CARCH}" = "i686" ]; then
  172.     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/"
  173.   fi
  174.  
  175.   cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/kernel/"
  176.  
  177.   # add docbook makefile
  178.   install -D -m644 Documentation/DocBook/Makefile \
  179.     "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/DocBook/Makefile"
  180.  
  181.   # add dm headers
  182.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/md"
  183.   cp drivers/md/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/md"
  184.  
  185.   # add inotify.h
  186.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/include/linux"
  187.   cp include/linux/inotify.h "${pkgdir}/usr/lib/modules/${_kernver}/build/include/linux/"
  188.  
  189.   # add wireless headers
  190.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/net/mac80211/"
  191.   cp net/mac80211/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/net/mac80211/"
  192.  
  193.   # add dvb headers for external modules
  194.   # in reference to:
  195.   # http://bugs.archlinux.org/task/9912
  196.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/dvb-core"
  197.   cp drivers/media/dvb-core/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/dvb-core/"
  198.   # and...
  199.   # http://bugs.archlinux.org/task/11194
  200.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/include/config/dvb/"
  201.   cp include/config/dvb/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/include/config/dvb/"
  202.  
  203.   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  204.   # in reference to:
  205.   # http://bugs.archlinux.org/task/13146
  206.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/dvb-frontends/"
  207.   cp drivers/media/dvb-frontends/lgdt330x.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/dvb-frontends/"
  208.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/i2c/"
  209.   cp drivers/media/i2c/msp3400-driver.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/i2c/"
  210.  
  211.   # add dvb headers
  212.   # in reference to:
  213.   # http://bugs.archlinux.org/task/20402
  214.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/usb/dvb-usb"
  215.   cp drivers/media/usb/dvb-usb/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/usb/dvb-usb/"
  216.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/dvb-frontends"
  217.   cp drivers/media/dvb-frontends/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/dvb-frontends/"
  218.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/tuners"
  219.   cp drivers/media/tuners/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/media/tuners/"
  220.  
  221.   # add xfs and shmem for aufs building
  222.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/fs/xfs"
  223.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/mm"
  224.   # removed in 3.17 series
  225.   # cp fs/xfs/xfs_sb.h "${pkgdir}/usr/lib/modules/${_kernver}/build/fs/xfs/xfs_sb.h"
  226.  
  227.   # copy in Kconfig files
  228.   for i in $(find . -name "Kconfig*"); do
  229.     mkdir -p "${pkgdir}"/usr/lib/modules/${_kernver}/build/`echo ${i} | sed 's|/Kconfig.*||'`
  230.     cp ${i} "${pkgdir}/usr/lib/modules/${_kernver}/build/${i}"
  231.   done
  232.  
  233.   # Fix file conflict with -doc package
  234.   rm "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/kbuild"/Kconfig.*-*
  235.  
  236.   # Add objtool for CONFIG_STACK_VALIDATION
  237.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/tools"
  238.   cp -a tools/objtool "${pkgdir}/usr/lib/modules/${_kernver}/build/tools"
  239.  
  240.   chown -R root.root "${pkgdir}/usr/lib/modules/${_kernver}/build"
  241.   find "${pkgdir}/usr/lib/modules/${_kernver}/build" -type d -exec chmod 755 {} \;
  242.  
  243.   # strip scripts directory
  244.   find "${pkgdir}/usr/lib/modules/${_kernver}/build/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
  245.     case "$(file -bi "${binary}")" in
  246.       *application/x-sharedlib*) # Libraries (.so)
  247.         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
  248.       *application/x-archive*) # Libraries (.a)
  249.         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
  250.       *application/x-executable*) # Binaries
  251.         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
  252.     esac
  253.   done
  254.  
  255.   # remove unneeded architectures
  256.   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}
  257. }
  258.  
  259. _package-docs() {
  260.   pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel (git version)"
  261.   provides=('linux-docs')
  262.  
  263.   cd "${_srcname}"
  264.  
  265.   mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build"
  266.   cp -al Documentation "${pkgdir}/usr/lib/modules/${_kernver}/build"
  267.   find "${pkgdir}" -type f -exec chmod 444 {} \;
  268.   find "${pkgdir}" -type d -exec chmod 755 {} \;
  269.  
  270.   # remove a file already in linux package
  271.   rm -f "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/DocBook/Makefile"
  272. }
  273.  
  274. pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs")
  275. for _p in ${pkgname[@]}; do
  276.   eval "package_${_p}() {
  277.    $(declare -f "_package${_p#${pkgbase}}")
  278.    _package${_p#${pkgbase}}
  279.  }"
  280. done
  281.  
  282. # vim:set ts=8 sts=2 sw=2 et:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement