Advertisement
Thaodan

PKGBUILD - linux-pf

Mar 18th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 27.32 KB | None | 0 0
  1. # Maintainer: Christos Nouskas <nous at archlinux dot us>
  2. # PKGBUILD assembled from kernel26
  3. # Some lines from  kernel26-bfs and kernel26-ck
  4. # Credits to respective maintainers
  5. _major=3
  6. _minor=8
  7. #_patchlevel=0
  8. #_subversion=1
  9. _basekernel=${_major}.${_minor}
  10. _srcname=linux-${_major}.${_minor}
  11. pkgbase=linux-pf
  12. _pfrel=1
  13. _kernelname=-pf
  14. _pfpatchhome="http://pf.natalenko.name/sources/${_basekernel}/"
  15. _pfpatchname="patch-${_basekernel}.${_pfrel}${_kernelname}"
  16.  
  17. ### PATCH AND BUILD OPTIONS
  18. # taken from graysky linux-ck see: https://aur.archlinux.org/packages/linux-ck
  19. # Set these variables to ANYTHING (yes or no or 1 or 0 or "I like icecream") to enable them
  20. #
  21.  
  22. _NUMA_off=yes       # Disable NUMA in kernel config
  23.  
  24. ### DOCS
  25. # Starting with the 3.6.6-3 release, this package ships with the kernel-3x-gcc47-x.patch.
  26. # This allows users an expanded scope of CPU specific options.
  27. # Consult the following resources to understand which option is right for you application:
  28. #
  29. # http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
  30. # http://en.gentoo-wiki.com/wiki/Safe_Cflags/AMD
  31. # http://www.linuxforge.net/docs/linux/linux-gcc.php
  32. # http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html
  33.  
  34. # DETAILS FOR using 'make localmodconfig'
  35. # As of mainline 2.6.32, running with this option will only build the modules that you currently have
  36. # probed in your system VASTLY reducing the number of modules built and the build time to do it.
  37. #
  38. # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
  39. #
  40. # To keep track of which modules are needed for your specific system/hardware, give my module_db script
  41. # a try: http://aur.archlinux.org/packages.php?ID=41689  Note that if you use my script, this PKGBUILD
  42. # will auto run the 'sudo modprobed_db reload' for you to probe all the modules you have logged!
  43. #
  44. # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed_db
  45.  
  46. # DETAILS FOR running kernel's config
  47. # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
  48. # Useful when the package gets updated and you already went through the trouble of customizing your
  49. # config options.  NOT recommended when a new kernel is released, but again, convenient for package bumps.
  50.  
  51. # DRTAILS FOR _NUMA_off=yes
  52. # Since 99.9% of users do not have multiple CPUs but do have multiple cores in one CPU
  53. # see, https://bugs.archlinux.org/task/31187
  54.  
  55. pkgname=('linux-pf')
  56. true && pkgname=('linux-pf' 'linux-pf-headers')
  57. pkgver=${_basekernel}.${_pfrel}
  58. pkgrel=2
  59. arch=('i686' 'x86_64')
  60. url="http://pf.natalenko.name/"
  61. license=('GPL2')
  62. options=('!strip')
  63. makedepends=('git' 'xmlto' 'docbook-xsl' 'xz')
  64. source=("ftp://www.kernel.org/pub/linux/kernel/v${_major}.x/linux-${_basekernel}.tar.xz"
  65.     'config' 'config.x86_64'        # the main kernel config files
  66.     'linux-pf.preset'           # standard config files for mkinitcpio ramdisk
  67.     'logo_linux_clut224.ppm.bz2'        #
  68.     'logo_linux_mono.pbm.bz2'       # the Arch Linux boot logos
  69.     'logo_linux_vga16.ppm.bz2'      #
  70.     'change-default-console-loglevel.patch'
  71.     'http://repo-ck.com/source/gcc_patch/kernel-38-gcc47-1.patch.gz'
  72.     "${_pfpatchhome}${_pfpatchname}.bz2"    # the -pf patchset
  73.  )
  74.  
  75. _aufs3git="git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git"
  76. _aufs3name=aufs3
  77. # '
  78.  
  79. build() {
  80.   cd "${srcdir}/linux-${_basekernel}"
  81.   # This is for me, to test the PKGBUILD
  82. if [[ $NOEXTRACT = "0" ]]; then
  83.  
  84.      # Arch linux logo
  85.      msg "Replacing penguins with arches"
  86.      bzip2 -dk ${startdir}/logo_linux_*.bz2
  87.      mv -f ${startdir}/logo_linux_*.p?m drivers/video/logo/
  88.      msg "Applying pf-kernel patch"
  89.      patch -Np1 < ${srcdir}/${_pfpatchname}
  90.      msg "Fetching and applying aufs3 patches"
  91.      git clone ${_aufs3git} ${_aufs3name}
  92.      cd ${_aufs3name}
  93.      git checkout origin/aufs${_basekernel} || _aufs3checkout=KRAKRA
  94.      if [[ ${_aufs3checkout} = "KRAKRA" ]]; then
  95.     echo
  96.         msg "AUFS3 not yet ported to version ${_basekernel}!"
  97.         msg "Skipping related patches."
  98.     echo
  99.     cd ..
  100.      else
  101. #        mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
  102. #        mv include/linux/Kbuild "${pkgdir}/usr/src/linux-${_kernver}/include/"
  103.     rm include/uapi/linux/Kbuild
  104.     cd ..
  105.     cp -a ${_aufs3name}/{Documentation,fs,include} ${srcdir}/linux-${_basekernel}/
  106.     msg "Patching aufs3"
  107.     for _patch in ${_aufs3name}/*.patch; do
  108.         patch -Np1 < ${_patch} || _aufs3fail=KRAKRA
  109.         done
  110.         if [[ ${_aufs3fail} = "KRAKRA" ]]; then
  111.         echo
  112.             msg "Not all aufs3 patches applied correctly. Ignore this if you won't use AUFS."
  113.             msg "Otherwise, press CTRL-C now and fix manually"
  114.             echo
  115.         fi
  116.     fi
  117.  
  118.   # Interactive governor patch
  119.   # broken for now
  120.   #   msg "Interactice CPU governor patch"
  121.   #   mv ${srcdir}/gist*/gistfile1.diff ${srcdir}
  122.   #   patch -Np1 < ${srcdir}/gistfile1.diff
  123.  
  124.   # linux-ARCH patches
  125.  
  126.   # add latest fixes from stable queue, if needed
  127.   # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
  128.  
  129.  
  130.   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
  131.   # remove this when a Kconfig knob is made available by upstream
  132.   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
  133.   patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
  134.  
  135.  
  136.  
  137.   # end linux-ARCH patches
  138.  
  139.  
  140.  
  141.  
  142.   # added gcc 4.7.1 support for Kconfig and menuconfig
  143.   zcat "${srcdir}/kernel-38-gcc47-1.patch.gz" | patch -Np1
  144.    if [ "$CARCH" = "x86_64" ]; then
  145.     cat "${startdir}/config.x86_64" >| .config
  146.    else
  147.     cat "${startdir}/config" >| .config
  148.    fi
  149. fi
  150.  
  151. #----------------------------------------
  152. if [[ "$_BATCH" != "y" ]]; then     # for batch building
  153.   echo
  154.   echo "======================================================="
  155.   msg "You might be prompted below for some config options"
  156.   echo "======================================================="
  157.   echo
  158.   msg "Hit <Y> to use your running kernel's config"
  159.   echo "    (needs IKCONFIG and IKCONFIG_PROC)"
  160.   msg "Hit <L> to run 'make localmodconfig'"
  161.   msg "Hit <N> (or just <ENTER>) to build an all-inclusive kernel like stock -ARCH"
  162.   echo "    (warning: it can take a looong time)"
  163.   echo
  164.   read answer
  165.   shopt -s nocasematch
  166.   if [[ "$answer" = "y" ]]; then
  167.      if [[ -s /proc/config.gz ]]; then
  168.     msg "Extracting config from /proc/config.gz..."
  169.     zcat /proc/config.gz >| ./.config
  170.      else
  171.     msg "running 'sudo modprobe configs'"
  172.     sudo modprobe configs
  173.         if [[ -s /proc/config.gz ]]; then
  174.         msg "Extracting config from /proc/config.gz..."
  175.         zcat /proc/config.gz >| ./.config
  176.     else
  177.         msg "You kernel was not compiled with IKCONFIG_PROC."
  178.         msg "Attempting to run /usr/bin/modprobed_db recall from modprobe_db..."
  179.         if [ -e /usr/bin/modprobed_db ]; then
  180.         sudo /usr/bin/modprobed_db recall
  181.         else
  182.         msg "modprobed_db not installed, running make localmodconfig instead..."
  183.         make localmodconfig
  184.         fi
  185.         fi
  186.      fi
  187.   elif [[ "$answer" = "l" ]]; then
  188.      # Copied from kernel26-ck's PKGBUILD
  189.      msg "Attempting to run /usr/bin/reload_database with sudo from modprobe_db..."
  190.      if [ -e /usr/bin/modprobed_db ]; then
  191.     sudo /usr/bin/modprobed_db recall
  192.      fi
  193.      msg "Running 'make localmodconfig'..."
  194.      make localmodconfig
  195.   else
  196.      msg "Using stock ARCH kernel .config (with BFS, BFQ and TuxOnIce enabled)."
  197.   fi
  198.  
  199.   # Make some good use of MAKEFLAGS
  200.   # MAKEFLAGS=`grep -v '#' /etc/makepkg.conf | grep MAKEFLAGS= | sed s/MAKEFLAGS=// | sed s/\"//g`
  201.  
  202.   # make prepare
  203.  
  204.   # Options for additional configuration
  205.   echo
  206.   msg "Kernel configuration options before build:"
  207.   echo "    <M> make menuconfig (console menu)"
  208.   echo "    <N> make nconfig (newer alternative to menuconfig)"
  209.   echo "    <G> make gconfig (needs gtk)"
  210.   echo "    <X> make xconfig (needs qt)"
  211.   echo "    <O> make oldconfig"
  212.   echo "    <L> make localyesconfig"
  213.   echo "    <ENTER> to skip configuration and use stock -ARCH defaults"
  214.   read answer
  215.   case "$answer" in
  216.    m) make menuconfig
  217.       ;;
  218.    g) make gconfig
  219.       ;;
  220.    x) make xconfig
  221.       ;;
  222.    n) make nconfig
  223.       ;;
  224.    o) make oldconfig
  225.       ;;
  226.    l) make localyesconfig
  227.       ;;
  228.    default)
  229.       ;;
  230.   esac
  231.   cp -v .config ${startdir}/config.local
  232.   CPU=`egrep "MK8=y|MCORE2=y|MPSC=y|MATOM=y|MPENTIUMII=y|MPENTIUMIII=y|MPENTIUMM=y|MPENTIUM4=y|MK7=y|CONFIG_GENERIC_CPU=y|M686=y|MBARCELONA=y|MBOBCAT=y|MBULLDOZER=y|MPILEDRIVER=y|MCOREI7=y|MCOREI7AVX=y|MCOREAVXI=y|MCOREAVX2=y" ./.config`
  233.   CPU=`sed -e "s/CONFIG_M\(.*\)=y/\1/" <<<$CPU`
  234.   CPU=`sed -e "s/CONFIG_GENERIC_CPU=y/GENERIC/" <<<$CPU`
  235.   CPU=`sed -e "s/^686$/GENERIC/" <<<$CPU`
  236.   cp -f .config ${startdir}/config.$CPU-$CARCH
  237.  
  238.   # Give option to rename package according to CPU
  239.   echo
  240.   if [[ "$CPU" = "GENERIC" ]]; then
  241.     msg "Hit <P>     :  to include the patchlevel number in kernver"
  242.     msg "               (i.e. linux-pf-${_basekernel}.${_pfrel})"
  243.     msg "Hit <ENTER> :  to remove the patchlevel number from kernver (default)"
  244.     msg "               (i.e. linux-pf-${_basekernel})"
  245.     read answer
  246.     shopt -s nocasematch
  247.     if [[ "$answer" = "p" ]]; then
  248.        export _SUBLEVEL=y
  249.     fi
  250.   else
  251.     lcpu=`tr '[:upper:]' '[:lower:]' <<< $CPU`
  252.     lcpu=`sed -e "s/entium//" <<<$lcpu`    
  253.     echo "=============================================================="
  254.     msg "An non-generic CPU was selected for this kernel."
  255.     echo
  256.     msg "Hit <G>     :  to create a generic package named linux-pf"
  257.     msg "Hit <ENTER> :  to create a package named after the selected CPU"
  258.     msg "               (linux-pf-${lcpu} - recommended default)"
  259.     echo
  260.     msg "This option affects ONLY the package name. Whether or not the"
  261.     msg "kernel is optimized was determined at the previous config step."
  262.     echo "=============================================================="
  263.     read answer
  264.     shopt -s nocasematch
  265.     if [[ "$answer" != "g" ]]; then
  266.        export _PKGOPT=y
  267.     fi
  268.     msg "Hit <P>     :  to include the patchlevel number in kernver"
  269.     if [[ ${_PKGOPT} != "y" ]]; then
  270.        msg "               (i.e. linux-pf-${_basekernel}.${_pfrel})"
  271.     else
  272.        msg "               (i.e. linux-pf-${lcpu}-${_basekernel}.${_pfrel})"
  273.     fi
  274.     msg "Hit <ENTER> :  to remove the patchlevel number from kernver (default)"
  275.     if [[ ${_PKGOPT} != "y" ]]; then
  276.        msg "               (i.e. linux-pf-${_basekernel})"
  277.     else
  278.        msg "               (i.e. linux-pf-${lcpu}-${_basekernel})"
  279.     fi
  280.     read answer
  281.     shopt -s nocasematch
  282.     if [[ "$answer" = "p" ]]; then
  283.        export _SUBLEVEL=y
  284.     fi
  285.   fi
  286. fi  # batch check ends here
  287. export CPU
  288. #----------------------------------------
  289.  
  290.   # Strip config of uneeded localversion
  291.   if [ "${_kernelname}" != "" ]; then
  292.      sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"\"|g" ./.config
  293.   fi
  294.  
  295.   # Set EXTRAVERSION to -pf
  296.   sed -i "s/EXTRAVERSION = -${_pfrel}/EXTRAVERSION = ${_kernelname}/" Makefile
  297.   _arch=$CARCH
  298.  
  299.   # Remove the sublevel from Makefile
  300.   # This ensures our kernel version is always 3.X-pf
  301.   # This way, minor kernel updates will not break external modules
  302.   if [ "${_SUBLEVEL}" != "y" ]; then
  303.      sed -ri 's|^(SUBLEVEL =).*|\1|' Makefile
  304.   fi
  305.  
  306.   # disable NUMA since 99.9% of users do not have multiple CPUs but do have multiple cores in one CPU
  307.   # see, https://bugs.archlinux.org/task/31187
  308.   if [ -n "$_NUMA_off" ]; then
  309.     if [ "${CARCH}" = "x86_64" ]; then
  310.      sed -i -e 's/CONFIG_NUMA=y/# CONFIG_NUMA is not set/' \
  311.       -i -e '/CONFIG_AMD_NUMA=y/d' \
  312.       -i -e '/CONFIG_X86_64_ACPI_NUMA=y/d' \
  313.       -i -e '/CONFIG_NODES_SPAN_OTHER_NODES=y/d' \
  314.       -i -e '/# CONFIG_NUMA_EMU is not set/d' \
  315.       -i -e '/CONFIG_NODES_SHIFT=6/d' \
  316.       -i -e '/CONFIG_NEED_MULTIPLE_NODES=y/d' \
  317.       -i -e '/CONFIG_USE_PERCPU_NUMA_NODE_ID=y/d' \
  318.       -i -e '/CONFIG_ACPI_NUMA=y/d' ./.config
  319.     fi
  320.   fi
  321.  
  322.   # Don't run depmod on 'make install'. We'll do this ourselves in packaging
  323.   sed -i '2iexit 0' scripts/depmod.sh
  324.  
  325.   # If the following is set, stop right there. We only need the headers for
  326.   # dependent drivers' compiling (nvidia, virtualbox etc)
  327.   [[ ${_NOBUILD} ]] && exit 0
  328.  
  329.   # get kernel version
  330.   make prepare
  331.  
  332.   # rewrite configuration
  333.   yes "" | make config >/dev/null
  334.  
  335.  
  336.   # Build
  337.   # Want extreme and non-sensical optimization? Uncomment the following line!
  338.   # export KCFLAGS="-march=native -Ofast"
  339.   make ${MAKEFLAGS} LOCALVERSION= bzImage modules
  340. }
  341.  
  342. package_linux-pf() {
  343.  _pkgdesc="Linux kernel and modules with the pf-kernel patch [-ck patchset (BFS included), TuxOnIce, BFQ] and aufs3."
  344.  pkgdesc=${_pkgdesc}
  345.  groups=('base')
  346.  backup=(etc/mkinitcpio.d/${pkgbase}.preset)
  347.  depends=('coreutils' 'linux-firmware' 'kmod>=9-2' 'mkinitcpio>=0.7')
  348.  optdepends=('linux-docs: Kernel hackers manual - HTML documentation that comes with the Linux kernel.'
  349.         'crda: to set the correct wireless channels of your country'
  350.         'pm-utils: utilities and scripts for suspend and hibernate power management'
  351.         'tuxonice-userui: TuxOnIce userspace user interface'
  352.         'hibernate-script: set of scripts for managing TuxOnIce, hibernation and suspend to RAM'
  353.         'nvidia-pf: NVIDIA drivers for linux-pf'
  354.         'nvidia-beta-all: NVIDIA drivers for all installed kernels'
  355.         'modprobed_db: Keeps track of EVERY kernel module that has ever been probed. Useful for make localmodconfig.')
  356.  #provides=(${pkgbase}=${_basekernel} 'aufs3')  # for $pkgname-optimized
  357.  provides=(${pkgbase}=${_basekernel} 'aufs3')
  358.  # below 'provides' is for when you have no other kernel (which is a bad idea anyway)
  359.  # provides=(${pkgbase}=${_basekernel} 'linux=${pkgver}' 'aufs3')
  360.  # If generic build, then conflict with all optimized ones
  361.  conflicts=('linux-pf-core2' 'linux-pf-k8' 'linux-pf-psc' 'linux-pf-atom'
  362.         'linux-pf-k7' 'linux-pf-p3' 'linux-pf-pm' 'linux-pf-p4'
  363.         'linux-pf-headers-core2' 'linux-pf-headers-k8' 'linux-pf-headers-psc'
  364.         'linux-pf-headers-atom' 'linux-pf-headers-k7' 'linux-pf-headers-p3'
  365.         'linux-pf-headers-pm' 'linux-pf-headers-p4'
  366.         'kernel26-pf-core2' 'kernel26-pf-k8' 'kernel26-pf-psc' 'kernel26-pf-atom'
  367.         'kernel26-pf-k7' 'kernel26-pf-p3' 'kernel26-pf-pm' 'kernel26-pf-p4'
  368.         'linux-pf-bobcat' 'linux-pf-barcelona' 'linux-pf-bulldozer'
  369.         'linux-pf-pilediver' 'linux-pf-nehalem' 'linux-pf-ivybridge' 'linux-pf-sandybridge' 'linux-pf-haswell'
  370.         'linux-pf-headers-bobcat' 'linux-pf-headers-barcelona' 'linux-pf-headers-bulldozer'
  371.         'linux-pf-headers-pilediver' 'linux-pf-headers-nehalem' 'linux-pf-headers-ivybridge' 'linux-pf-headers-sandybridge' 'linux-pf-headers-haswell' )
  372.  replaces=('kernel26-pf' 'aufs3')
  373.  backup=("etc/mkinitcpio.d/${pkgbase}.preset")
  374.  install='linux-pf.install'
  375.  
  376.  #'
  377.   cd "${srcdir}/linux-${_basekernel}"
  378.  
  379.   # Remove undeeded aufs3 git tree
  380.   rm -fr aufs3 2>/dev/null
  381.  
  382.   # work around the AUR parser
  383.   # This allows building cpu-optimized packages with according package names.
  384.   # Useful for repo maintainers.
  385.   headers="headers"
  386.   pkgnameopt="${pkgbase}"       # this MUST be outside the following 'if'
  387.   if [[ "$_PKGOPT" = "y" ]]; then   # package naming according to optimization
  388.     case $CPU in
  389.      CORE2)
  390.          pkgname="${pkgbase}-core2"
  391.          pkgdesc="${_pkgdesc} Intel Core2 optimized."
  392.          ;;
  393.      K8)
  394.          pkgname="${pkgbase}-k8"
  395.          pkgdesc="${_pkgdesc} AMD K8 optimized."
  396.          ;;
  397.      BARCELONA)
  398.          pkgname="${pkgbase}-barcelona"
  399.          pkgdesc="${_pkgdesc} AMD Barcelona optimized."
  400.      ;;
  401.      BOBCAT)
  402.      pkgname="${pkgbase}-bobcat"
  403.      pkgdesc="${_pkgdesc} AMD Bobcat optimized"
  404.      ;;
  405.      BULLDOZER)
  406.      pkgname"${pkgbase}-bulldozer"
  407.      pkgdesc="${_pkgdesc} AMD Bulldozer optimized"
  408.      ;;
  409.      PILEDRIVER)
  410.      pkgname"${pkgbase}-piledriver"
  411.      pkgdesc="${_pkgdesc} AMD Piledriver optimized"
  412.      ;;
  413.      PSC)
  414.          pkgname="${pkgbase}-psc"
  415.          pkgdesc="${_pkgdesc} Intel Pentium4/D/Xeon optimized."
  416.          ;;
  417.      ATOM)
  418.          pkgname="${pkgbase}-atom"
  419.          pkgdesc="${_pkgdesc} Intel Atom optimized."
  420.          ;;
  421.      K7)
  422.          pkgname="${pkgbase}-k7"
  423.          pkgdesc="${_pkgdesc} AMD K7 optimized."
  424.          ;;
  425.      PENTIUMII)
  426.          pkgname="${pkgbase}-p2"
  427.          pkgdesc="${_pkgdesc} Intel Pentium2 optimized."
  428.          ;;
  429.      PENTIUMIII)
  430.          pkgname="${pkgbase}-p3"
  431.          pkgdesc="${_pkgdesc} Intel Pentium3 optimized."
  432.          ;;
  433.      PENTIUMM)
  434.          pkgname="${pkgbase}-pm"
  435.          pkgdesc="${_pkgdesc} Intel Pentium-M optimized."
  436.          ;;
  437.      PENTIUM4)
  438.          pkgname="${pkgbase}-p4"
  439.          pkgdesc="${_pkgdesc} Intel Pentium4 optimized."
  440.          ;;
  441.      COREI7)
  442.      pkgname="${pkgbase}-nehalem "
  443.          pkgdesc="${_pkgdesc} Intel Core Nehalem optimized."
  444.      ;;
  445.      COREI7AVX)
  446.          pkgname="${pkgbase}-sandybridge"
  447.          pkgdesc="${_pkgdesc} Intel 2nd Gen Core processors including Sandy Bridge."
  448.      ;;
  449.      COREAVXI)
  450.          pkgname="${pkgbase}-ivybridge"
  451.          pkgdesc="${_pkgdesc} Intel 3rd Gen Core processors including Ivy Bridge."
  452.      ;;
  453.      COREAVX2)
  454.          pkgname="${pkgbase}-haswell"
  455.          pkgdesc="${_pkgdesc} Intel AVX-2 processors including Haswell."
  456.      ;;
  457.      default)
  458.   # Note to me: DO NOT EVER REMOVE THIS. It's for the AUR PKGBUILD parser.
  459.          pkgname="${pkgbase}"
  460.          pkgdesc="Linux kernel and modules with the pf-kernel patch [-ck patchset (BFS included), TuxOnIce, BFQ] and aufs3"
  461.          ;;
  462.     esac
  463.  
  464.  
  465.   # If optimized build, conflict with generic and other optimized ones
  466.  
  467.   if [[ "$pkgname" != "$pkgbase" ]]; then
  468.     pkgnameopt="${pkgname}"     # this MUST be inside this if-fi
  469.     pkgname="${pkgbase}"
  470.     echo pkgname $pkgname
  471.     cpuopt=`sed -e "s/linux-pf-//" <<<$pkgnameopt`      # get suffix
  472.     cpuoptdesc=`sed -e "s/${_pkgdesc}//" <<<$pkgdesc`   # get description
  473.     conflicts=(${conflicts[@]/linux-pf-${cpuopt}/})     # remove current
  474.     conflicts=(${conflicts[@]/linux-pf-headers-${cpuopt}/}) # remove current's headers
  475.     export cpuopt cpuoptdesc
  476.   fi
  477.  
  478.   # second batch check ends here
  479.  fi
  480.  
  481.  # Pass conflicts array to linux-pf-headers() BEFORE adding generic linux-pf or headers will conflict
  482.  export _conflicts=${conflicts[@]}
  483.  conflicts=('linux-pf' 'kernel26-pf' ${conflicts[@]})   # add generic packages
  484.  
  485.   echo
  486.   echo "    ========================================"
  487.   msg  "The packages will be named ${pkgnameopt} and"
  488.   if [[ "$cpuopt" ]]; then
  489.        msg  "and ${pkgbase}-${headers}-${cpuopt}"
  490.   else
  491.        msg  "and ${pkgbase}-${headers}"
  492.   fi
  493.   msg  "${pkgdesc}"
  494.   echo "    ========================================"
  495.   echo
  496.  
  497.  ### package_linux-pf
  498.  
  499.   cd "${srcdir}/linux-${_basekernel}"
  500.  
  501.   KARCH=x86
  502.  
  503.   echo # get kernel version
  504.    _kernver="$(make LOCALVERSION= kernelrelease)"
  505.  
  506.  
  507.   ### c/p from linux-ARCH
  508.  
  509.   mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
  510.   make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}" modules_install
  511.   cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}"
  512.  
  513.   # add vmlinux
  514.   install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
  515.  
  516.   # install fallback mkinitcpio.conf file and preset file for kernel
  517.   install -D -m644 "${srcdir}/linux-pf.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  518.  
  519.   # set correct depmod command for install
  520.   sed \
  521.     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/" \
  522.     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/" \
  523.     -i "${startdir}/linux-pf.install"
  524.   sed \
  525.     -e "1s|'linux.*'|'${pkgbase}'|" \
  526.     -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgbase}\"|" \
  527.     -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgbase}.img\"|" \
  528.     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgbase}-fallback.img\"|" \
  529.     -i "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
  530.  
  531.   # remove build and source links
  532.   rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
  533.   # remove the firmware
  534.   rm -rf "${pkgdir}/lib/firmware"
  535.   # gzip -9 all modules to save 100MB of space
  536.   find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
  537.   # make room for external modules
  538.   ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
  539.   # add real version for building modules and running depmod from post_install/upgrade
  540.   mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
  541.   echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
  542.  
  543.   # Now we call depmod...
  544.   depmod -b "$pkgdir" -F System.map "$_kernver"
  545.  
  546.   # move module tree /lib -> /usr/lib
  547.   mv "$pkgdir/lib" "$pkgdir/usr"
  548.  
  549. # end c/p
  550.  
  551.   ###
  552.   # Trick the AUR parser to accept split PKGBUILD
  553.   true && pkgname="${pkgnameopt}"
  554. }
  555.  
  556. ### package_linux-pf-headers
  557. package_linux-pf-headers() {
  558.   pkgdesc="Header files and scripts for building modules for linux-pf kernel."
  559.  depends=('linux-pf')
  560.   IFS=' ' read -a conflicts <<<${_conflicts}
  561.   [[ ${cpuopt} ]] && pkgname=${pkgname}-${cpuopt} && depends=${depends}-${cpuopt}
  562.   [[ ${cpuoptdesc} ]] && pkgdesc=${pkgdesc}${cpuoptdesc}
  563.   provides=('linux-pf-headers')
  564.   cd "${srcdir}/linux-${_basekernel}"
  565. # c/p from linux-ARCH
  566.  
  567.   install -dm755 "${pkgdir}/usr/lib/modules/${_kernver}"
  568.  
  569.   cd "${pkgdir}/usr/lib/modules/${_kernver}"
  570.   ln -sf ../../../src/linux-${_kernver} build
  571.  
  572.  
  573.   cd "${srcdir}/${_srcname}"
  574.   install -D -m644 Makefile \
  575.     "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
  576.   install -D -m644 kernel/Makefile \
  577.     "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
  578.   install -D -m644 .config \
  579.     "${pkgdir}/usr/src/linux-${_kernver}/.config"
  580.  
  581.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
  582.  
  583.   for i in acpi asm-generic config crypto drm generated keys linux math-emu \
  584.     media net pcmcia scsi sound trace uapi video xen; do
  585.     cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
  586.   done
  587.  
  588.   # copy arch includes for external modules
  589.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
  590.   cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
  591.  
  592.   # copy files necessary for later builds, like nvidia and vmware
  593.   cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
  594.   cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
  595.  
  596.   # fix permissions on scripts dir
  597.   chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
  598.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
  599.  
  600.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
  601.  
  602.   cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  603.  
  604.   if [ "${CARCH}" = "i686" ]; then
  605.     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  606.   fi
  607.  
  608.   cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
  609.  
  610.   # add headers for lirc package
  611.   # pci
  612.   for i in bt8xx cx88 saa7134; do
  613.     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/pci/${i}"
  614.     cp -a drivers/media/pci/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/pci/${i}"
  615.   done
  616.   # usb
  617.   for i in cpia2 em28xx pwc sn9c102; do
  618.     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/usb/${i}"
  619.     cp -a drivers/media/usb/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/usb/${i}"
  620.   done
  621.   # i2c
  622.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c"
  623.   cp drivers/media/i2c/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c/"
  624.   for i in cx25840; do
  625.     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c/${i}"
  626.     cp -a drivers/media/i2c/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c/${i}"
  627.   done
  628.  
  629.   # add docbook makefile
  630.   install -D -m644 Documentation/DocBook/Makefile \
  631.     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
  632.  
  633.   # add dm headers
  634.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  635.   cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  636.  
  637.   # add inotify.h
  638.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
  639.   cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
  640.  
  641.   # add wireless headers
  642.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  643.   cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  644.  
  645.   # add dvb headers for external modules
  646.   # in reference to:
  647.   # http://bugs.archlinux.org/task/9912
  648.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-core"
  649.   cp drivers/media/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-core/"
  650.   # and...
  651.   # http://bugs.archlinux.org/task/11194
  652.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  653.   cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  654.  
  655.   # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  656.   # in reference to:
  657.   # http://bugs.archlinux.org/task/13146
  658.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-frontends/"
  659.   cp drivers/media/dvb-frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-frontends/"
  660.   cp drivers/media/i2c/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c/"
  661.  
  662.   # add dvb headers
  663.   # in reference to:
  664.   # http://bugs.archlinux.org/task/20402
  665.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/usb/dvb-usb"
  666.   cp drivers/media/usb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/usb/dvb-usb/"
  667.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-frontends"
  668.   cp drivers/media/dvb-frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-frontends/"
  669.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/tuners"
  670.   cp drivers/media/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/tuners/"
  671.  
  672.  
  673.   # add xfs and shmem for aufs building
  674.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
  675.   mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
  676.   cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
  677.  
  678.   # copy in Kconfig files
  679.   for i in `find . -name "Kconfig*"`; do
  680.     mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
  681.     cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
  682.   done
  683.  
  684.   chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
  685.   find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
  686.  
  687.   # strip scripts directory
  688.   find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
  689.     case "$(file -bi "${binary}")" in
  690.       *application/x-sharedlib*) # Libraries (.so)
  691.         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
  692.       *application/x-archive*) # Libraries (.a)
  693.         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
  694.       *application/x-executable*) # Binaries
  695.         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
  696.     esac
  697.   done
  698.  
  699.   # remove unneeded architectures
  700.   rm -rf "${pkgdir}"/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,c6x,cris,frv,h8300,hexagon,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,openrisc,parisc,powerpc,ppc,s390,score,sh,sh64,sparc,sparc64,tile,unicore32,um,v850,xtensa}
  701. # end c/p
  702.  
  703.   # Add version.h for dumb binary blob installers which aren't
  704.   cd "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
  705.   [[ -e version.h ]] || ln -s ../generated/uapi/linux/version.h
  706.  
  707. }
  708.  
  709. # Work around the AUR parser
  710. pkgdesc="Linux kernel and modules with the pf-kernel patch [-ck patchset (BFS included), TuxOnIce, BFQ] and aufs3"
  711.  
  712. # makepkg -g >>PKGBUILD
  713. sha256sums=('e070d1bdfbded5676a4f374721c63565f1c969466c5a3e214004a136b583184b'
  714.             'e965c73b7a93da116edeff54c9758ee7dbda50ad0683ead2ff7b55ac7cb263af'
  715.             '6cbd2c25982c6bea19ea9915252a6282ab4eff8ee27757bf221672209eb5fa27'
  716.             '82d660caa11db0cd34fd550a049d7296b4a9dcd28f2a50c81418066d6e598864'
  717.             '03ed4eb4a35d42ae6beaaa5e6fdbada4244ed6c343944bba6462defaa6fed0bf'
  718.             '51ea665cfec42d9f9c7796af2b060b7edbdeb367e42811f8c02667ad729f6b19'
  719.             '9e1e81d80afac6f316e53947e1b081017090081cd30e6c4c473420b77af4b52b'
  720.             '56bd99e54429a25a144f2d221718b67f516344ffd518fd7dcdd752206ec5be69'
  721.             '4b8b51a298768048735914e747affe39f58d47d20833cd90fdc002559c719c6a'
  722.             'b4a0e24b110ab6d73b020d4399c5afb63c4961624d28e624604435aaef805fac')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement