Guest User

PKGBUILD linux-mailine with microcode fix

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