Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

PKGBUILD

By: a guest on Nov 16th, 2011  |  syntax: None  |  size: 12.34 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Maintainer: Ray Rashif <schiv@archlinux.org>
  2. # Contributor: timbosa <tinny_tim@dodo.com.au>
  3. # Contributor: Tobias Powalowski <tpowa@archlinux.org>
  4. # Contributor: Thomas Baechler <thomas@archlinux.org>
  5.  
  6. pkgname=linux-rt
  7. _kernelname=${pkgname#linux}
  8. _basekernel=3.0
  9. _rtpatch=rt25
  10. pkgver=${_basekernel}.9_$_rtpatch
  11. _pkgver=${_basekernel}.9
  12. pkgrel=1
  13. #-========user config options========-
  14. #legend: yes(enable building proprietary nvidia driver against full rt preemption), no(disable).default is set to "no".
  15. __enable_nvidia_driver_compile="no"
  16. #legend: no(NO), x(xconfig), m(menuconfig), n(nconfig), o(oldconfig-using old config from previous kernel version)
  17. __enable_user_kernel_config="no"
  18. #legend: yes(gzip modules),no(don't gzip modules).gzip -9 all modules to save 100MB of space
  19. __enable_gzip_of_modules="yes"
  20. #-========end of user config========-
  21. arch=('i686' 'x86_64')
  22. url="http://rt.wiki.kernel.org/"
  23. license=('GPL2')
  24. pkgdesc="The Linux Kernel and modules (with realtime preemption)"
  25. options=(!strip)
  26. backup=(etc/mkinitcpio.d/${pkgname}.preset)
  27. depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
  28. optdepends=('crda: to set the correct wireless channels of your country')
  29. provides=('kernel26rt')
  30. conflicts=('kernel26rt')
  31. replaces=('kernel26rt')
  32. install=${pkgname}.install
  33. source=(#"ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-${_basekernel}.tar.bz2"
  34.         "http://ftp.jaist.ac.jp/pub/Linux/kernel.org/linux/kernel/v3.x/linux-${_basekernel}.tar.bz2"
  35.         #"ftp://ftp.kernel.org/pub/linux/kernel/v3.0/patch-${_pkgver}.bz2"
  36.                 "ftp://ftp.kernel.org/pub/linux/kernel/v3.0/patch-${_pkgver}.gz"
  37.         #"ftp://ftp.kernel.org/pub/linux/kernel/projects/rt/patch-${_pkgver}-${_rtpatch}.patch.bz2"
  38.                 "http://tglx.de/~tglx/rt/patch-${_pkgver}-${_rtpatch}.patch.gz"
  39.         # the main kernel config files
  40.         'config' 'config.x86_64'
  41.         # standard config files for mkinitcpio ramdisk
  42.         "${pkgname}.preset"
  43.         'fix-i915.patch'
  44.         'change-default-console-loglevel.patch')
  45.  
  46. build() {
  47.   cd "${srcdir}/linux-${_basekernel}"
  48.  
  49.   patch -p1 -i "${srcdir}/patch-${_pkgver}"
  50.  
  51.   # add realtime patch
  52.   patch -p1 -i "${srcdir}/patch-${_pkgver}-$_rtpatch.patch"
  53.  
  54.   if [ $__enable_nvidia_driver_compile = "yes" ]; then
  55.     msg "enable building proprietary nvidia driver against full rt preemption"
  56.     msg "WARNING: GPL-INCOMPATIBLE"
  57.    # enable building proprietary nvidia driver against full rt preemption
  58.    # WARNING: GPL-INCOMPATIBLE
  59.    sed -i \
  60.           's/EXPORT_SYMBOL_GPL(migrate_enable);/EXPORT_SYMBOL(migrate_enable);/' \
  61.           kernel/sched.c
  62.  
  63.    sed -i \
  64.           's/EXPORT_SYMBOL_GPL(migrate_disable);/EXPORT_SYMBOL(migrate_disable);/' \
  65.           kernel/sched.c
  66.  
  67.    sed -i \
  68.           's/EXPORT_SYMBOL_GPL(__rt_mutex_init);/EXPORT_SYMBOL(__rt_mutex_init);/' \
  69.           kernel/rtmutex.c
  70.   fi
  71.   # add latest fixes from stable queue, if needed
  72.   # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
  73.  
  74.   # fix #19234 i1915 display size
  75.   patch -Np1 -i "${srcdir}/fix-i915.patch"
  76.  
  77.   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
  78.   # remove this when a Kconfig knob is made available by upstream
  79.   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
  80.   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
  81.  
  82.   if [ "${CARCH}" = "x86_64" ]; then
  83.     cat "${srcdir}/config.x86_64" > ./.config
  84.   else
  85.     cat "${srcdir}/config" > ./.config
  86.   fi
  87.  
  88.   if [ "${_kernelname}" != "" ]; then
  89.     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  90.   fi
  91.  
  92.   # remove the sublevel from Makefile
  93.   # this ensures our kernel version is always 3.X-ARCH
  94.   # this way, minor kernel updates will not break external modules
  95.   # we need to change this soon, see FS#16702
  96.   sed -ri 's|^(SUBLEVEL =).*|\1|' Makefile
  97.  
  98.   # get kernel version
  99.   rm localversion-rt
  100.   make prepare
  101.  
  102.   # load configuration
  103.   # Configure the kernel.
  104.   if [ $__enable_user_kernel_config = "m" ]; then
  105.     msg "Running make xconfig"
  106.     make menuconfig
  107.   fi
  108.  
  109.   if [ $__enable_user_kernel_config = "n" ]; then
  110.     msg "Running make xconfig"
  111.     make nconfig
  112.   fi
  113.  
  114.   if [ $__enable_user_kernel_config = "x" ]; then
  115.     msg "Running make xconfig"
  116.     make xconfig
  117.   fi
  118.  
  119.   if [ $__enable_user_kernel_config = "o" ]; then
  120.     msg "Running make xconfig"
  121.     make oldconfig
  122.   fi
  123.  
  124.   ####################
  125.   # stop here
  126.   # this is useful to configure the kernel
  127.   #msg "Stopping build"
  128.   #return 1
  129.   ####################
  130.  
  131.   yes "" | make config
  132.  
  133.   # build!
  134.   make ${MAKEFLAGS} bzImage modules
  135. }
  136.  
  137. package() {
  138.   cd "${srcdir}/linux-${_basekernel}"
  139.  
  140.   KARCH=x86
  141.  
  142.   # get kernel version
  143.   _kernver="$(make kernelrelease)"
  144.  
  145.   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
  146.   make INSTALL_MOD_PATH="${pkgdir}" modules_install
  147.   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
  148.  
  149.   # add vmlinux
  150.   install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
  151.  
  152.   # install fallback mkinitcpio.conf file and preset file for kernel
  153.   install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
  154.  
  155.   # set correct depmod command for install
  156.   sed \
  157.     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
  158.     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
  159.     -i "${startdir}/${pkgname}.install"
  160.   sed \
  161.         -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \
  162.     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \
  163.     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \
  164.     -i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset"
  165.  
  166.   # remove build and source links
  167.   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
  168.   # remove the firmware
  169.   rm -rf "${pkgdir}/lib/firmware"
  170.   # gzip -9 all modules to safe 100MB of space
  171.   if [ $__enable_gzip_of_modules = "yes" ]; then
  172.     # gzip -9 all modules to save 100MB of space
  173.     msg "Compressing modules..."
  174.     find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
  175.   fi
  176.   ## -- headers --##
  177.   mkdir -p "${pkgdir}/lib/modules/${_kernver}"
  178.  
  179.   cd "${pkgdir}/lib/modules/${_kernver}"
  180.   ln -sf ../../../usr/src/linux-${_kernver} build
  181.  
  182.   cd "${srcdir}/linux-${_basekernel}"
  183.   install -D -m644 Makefile \
  184.     "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
  185.   install -D -m644 kernel/Makefile \
  186.     "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
  187.   install -D -m644 .config \
  188.     "${pkgdir}/usr/src/linux-${_kernver}/.config"
  189.  
  190.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
  191.  
  192.   for i in acpi asm-generic config crypto drm generated linux math-emu \
  193.     media net pcmcia scsi sound trace video xen; do
  194.     cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
  195.   done
  196.  
  197.   # copy arch includes for external modules
  198.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
  199.   cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
  200.  
  201.   # copy files necessary for later builds, like nvidia and vmware
  202.   cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
  203.   cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
  204.  
  205.   # fix permissions on scripts dir
  206.   chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
  207.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
  208.  
  209.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
  210.  
  211.   cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  212.  
  213.   if [ "${CARCH}" = "i686" ]; then
  214.     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  215.   fi
  216.  
  217.   cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
  218.  
  219.   # add headers for lirc package
  220.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
  221.  
  222.   cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
  223.  
  224.   for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
  225.     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
  226.     cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
  227.   done
  228.  
  229.   # add docbook makefile
  230.   install -D -m644 Documentation/DocBook/Makefile \
  231.     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
  232.  
  233.   # add dm headers
  234.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  235.   cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  236.  
  237.   # add inotify.h
  238.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
  239.   cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
  240.  
  241.   # add wireless headers
  242.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  243.   cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  244.  
  245.   # add dvb headers for external modules
  246.   # in reference to:
  247.   # http://bugs.archlinux.org/task/9912
  248.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
  249.   cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
  250.   # and...
  251.   # http://bugs.archlinux.org/task/11194
  252.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  253.   cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  254.  
  255.   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  256.   # in reference to:
  257.   # http://bugs.archlinux.org/task/13146
  258.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  259.   cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  260.   cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  261.  
  262.   # add dvb headers
  263.   # in reference to:
  264.   # http://bugs.archlinux.org/task/20402
  265.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
  266.   cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
  267.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
  268.   cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  269.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
  270.   cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
  271.  
  272.   # add xfs and shmem for aufs building
  273.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
  274.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
  275.   cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
  276.  
  277.   # copy in Kconfig files
  278.   for i in `find . -name "Kconfig*"`; do
  279.     mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
  280.     cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
  281.   done
  282.  
  283.   chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
  284.   find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
  285.  
  286.   # strip scripts directory
  287.   find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
  288.     case "$(file -bi "${binary}")" in
  289.       *application/x-sharedlib*) # Libraries (.so)
  290.         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
  291.       *application/x-archive*) # Libraries (.a)
  292.         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
  293.       *application/x-executable*) # Binaries
  294.         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
  295.     esac
  296.   done
  297.  
  298.   # remove unneeded architectures
  299.   rm -rf "${pkgdir}"/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}
  300.  
  301.   ## -- docs --##
  302.   rm -r "${pkgdir}/usr/src/linux-${_kernver}/Documentation"
  303.   mv Documentation "${pkgdir}/usr/src/linux-${_kernver}"
  304.   find "${pkgdir}" -type f -exec chmod 444 {} \;
  305.   find "${pkgdir}" -type d -exec chmod 755 {} \;
  306.  
  307.   # remove a file already in linux package
  308.   rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
  309. }
  310.  
  311. # vim:set ts=2 sw=2 et:
  312. md5sums=('398e95866794def22b12dfbc15ce89c0'
  313.          'f8fec492f37fcc41ca7a431e935695ae'
  314.          '013393a57708ea4809047b29ac882bc1'
  315.          '8bed8efe88e4fa1781d1f307f35f9b26'
  316.          'a542f23e4f270967b3e8a871e69d0a61'
  317.          'eb14dcfd80c00852ef81ded6e826826a'
  318.          '263725f20c0b9eb9c353040792d644e5'
  319.          '9d3c56a4b999c8bfbd4018089a62f662')
  320.  
  321.  
  322.  
  323.  
  324.