Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

linux-lqx new kmod pkgbuild

By: a guest on Jul 8th, 2012  |  syntax: None  |  size: 12.22 KB  |  views: 43  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Maintainer: shivik <>
  2. # Contributor: Michael Duell <mail@akurei.me> PGP-Key: 6EE23EBE
  3.  
  4. ###########################################################################################################
  5. #                                          Patch and Build Options
  6. ###########################################################################################################
  7. _custom="no"    # "m":  custom config via menuconfig
  8.                 # "n":  custom config via nconfig
  9.                 # "x":  custom config via xconfig
  10.                 # "no": nothing
  11.  
  12. _config="pkg"   # "local":  make localmod config - compile only probed modules
  13.                 # "nomod":  don't use modules(make localyesconfig)
  14.                 # "old":    make with old config (/proc/config.gz)
  15.                 # "pkg":    use this package's config
  16.  
  17. pkgdesc='Linux Kernel and modules with Liquorix patches'
  18. _basekernel=3.4
  19. _minor=4
  20. pkgver=${_basekernel}.${_minor}
  21. pkgrel=2
  22. _kernelname=-lqx
  23. pkgname=linux${_kernelname}
  24. _lqxpatchname="${pkgver}-${pkgrel}.patch"
  25. arch=('i686' 'x86_64')
  26. license=('GPL2')
  27. groups=('base')
  28. url="http://liquorix.net/"
  29. if [ "$_custom" = "x" ]; then
  30.    makedepends=('qt')
  31. fi
  32. options=(!strip)
  33. install='linux-lqx.install'
  34. #http://liquorix.net/sources/${_basekernel}/config.i386
  35. #http://liquorix.net/sources/${_basekernel}/config.amd64
  36. source=(ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.xz
  37. http://liquorix.net/sources/${_lqxpatchname}.gz
  38. http://liquorix.net/sources/${_basekernel}/config.i386
  39. http://liquorix.net/sources/${_basekernel}/config.amd64
  40. linux-lqx.preset)
  41.  
  42. sha512sums=('1c49b336750c9c2b49d21e54126f22a800367296be0d57e6df28b1532cbeba7fc3bdf4cfe27d9810576e76c2db2e9c2493f0804451c915137cb78d7aa61f236c'
  43.             '23ed94b243023a5b0dbce9eef164bf489db71d04849fc4ac85316a47f4aef3f16fefa98501edc9c7941d74a794650da4817d33804296ed4879d3e5b97bf4c555'
  44.             '0e717c71cac56bb7db35adbb30eb31638a44f1d41c24af0bac0928d6e9ffb23684288930fd58ef0696d9dc23a9111ec996c45dd72a71a0e2e7fc8f8bfe7b22d0'
  45.             'dfa224e0d4263e60b1d094dcebd59a4cea61e231108a7e480cd3d9e2d180d8ea82c108e76c872fd289766ce53409bd06d6db1f7338b51187af0e4ec99c80aba8'
  46.             'fe4dcd7b5ec06ec3ec4aa631531469f58f6a7111e2d33affa98a1b8a8d230c5fa7e25ffdf770fe5ce61f249b0ec0ecd69df2858c4029acee0efaadff957858fe')
  47.  
  48. build() {
  49.   KARCH=x86
  50.   #sed -i -re "s/^(.EXTRAVERSION).*$/\1 = /" "${_lqxpatchname}"
  51.   #sed -i -re "s/^(.SUBLEVEL).*$/\1 = /" "${_lqxpatchname}"
  52.   cd ${srcdir}/linux-${_basekernel}
  53.  
  54.   # Add Liquorix patches
  55.   patch -Np1 -i ${srcdir}/$_lqxpatchname
  56.    
  57.   # Trying oldcfg if possible and if selected
  58.   if [ "$_config" = "old" ]; then
  59.     if [ -e /proc/config.gz ]; then
  60.       zcat /proc/config.gz > ./.config
  61.     else
  62.       echo "WARNING: There's no /proc/config.gz... You cannot use the old config. Aborting..."
  63.       exit 1
  64.     fi        
  65.   else
  66.     if [ "$CARCH" = "x86_64" ]; then
  67.       cat ../config.amd64 >./.config
  68.     else
  69.       cat ../config.i386 >./.config
  70.     fi
  71.   fi
  72.  
  73.   if [ "${_kernelname}" != "" ]; then
  74.     sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  75.   fi
  76.  
  77.   # set extraversion to pkgrel
  78.   sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
  79.   # don't run depmod on 'make install'. We'll do this ourselves in packaging
  80.   sed -i '2iexit 0' scripts/depmod.sh
  81.   # set sublevel to kernel minor version
  82.   sed -ri "s|^(SUBLEVEL =).*|\1 ${_minor}|" Makefile
  83.  
  84.   msg "Running make prepare"
  85.   make prepare
  86.  
  87. ### Optionally load needed modules for the make localmodconfig
  88.  # See http://aur.archlinux.org/packages.php?ID=41689
  89.  if [ $_config = "local" ]; then
  90.   msg "If you have modprobe_db installed, running it in recall mode now"
  91.   if [ -e /usr/bin/modprobed_db ]; then
  92.     [[ ! -x /usr/bin/sudo ]] && echo "Cannot call modprobe with sudo. Install via pacman -S sudo and configure to work with this user." && exit 1
  93.     sudo /usr/bin/modprobed_db recall
  94.  fi
  95.   msg "Running Steven Rostedt's make localmodconfig now"
  96.   make localmodconfig
  97.  else
  98.   yes "" | make config
  99.  fi
  100.  
  101.  if [ $_config = "nomod" ]; then
  102.   msg "Running localYESconfig now"
  103.   make localyesconfig
  104.  else
  105.   yes "" | make config
  106.  fi
  107.  
  108.   if [ $_custom = "m" ]; then
  109.     msg "Running make menuconfig"
  110.     make menuconfig
  111.   fi
  112.  
  113.   if [ $_custom = "n" ]; then
  114.     msg "Running make nconfig"
  115.     make nconfig
  116.   fi
  117.  
  118.   if [ $_custom = "x" ]; then
  119.     msg "Running make xconfig"
  120.     make xconfig
  121.   fi
  122.  
  123.   # build!
  124.   make ${MAKEFLAGS} bzImage modules
  125.  
  126. }
  127.  
  128. package_linux-lqx() {
  129. pkgdesc="Linux kernel and modules with Liquorix patches"
  130. depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.8')
  131. optdepends=('crda: to set the correct wireless channels of your country' 'nvidia-lqx: nVidia drivers for linux-lqx')
  132. provides=('linux-headers' "linux=$pkgver") # for when you have no other kernel
  133. #provides=("linux-lqx=${pkgver}")
  134. conflicts=('kernel26-lqx')
  135. replaces=('kernel26-lqx')
  136. backup=("etc/mkinitcpio.d/linux-lqx.preset")
  137. install=linux-lqx.install
  138.  
  139. cd "${srcdir}/linux-${_basekernel}"
  140.  
  141. KARCH=x86
  142.  
  143. # get kernel version
  144. _kernver="$(make kernelrelease)"
  145.  
  146. mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
  147. make INSTALL_MOD_PATH="${pkgdir}" modules_install
  148. cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-linux-lqx"
  149.  
  150. # add vmlinux
  151. install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
  152.  
  153. # install fallback mkinitcpio.conf file and preset file for kernel
  154. install -D -m644 "${srcdir}/linux-lqx.preset" "${pkgdir}/etc/mkinitcpio.d/linux-lqx.preset"
  155.  
  156. # set correct depmod command for install
  157. sed \
  158.         -e  "s/KERNEL_NAME=.*/KERNEL_NAME=-lqx/g" \
  159.         -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
  160.         -i "${startdir}/linux-lqx.install"
  161. sed \
  162.         -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-linux-lqx\"|g" \
  163.         -e "s|default_image=.*|default_image=\"/boot/initramfs-linux-lqx.img\"|g" \
  164.         -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-linux-lqx-fallback.img\"|g" \
  165.         -i "${pkgdir}/etc/mkinitcpio.d/linux-lqx.preset"
  166.  
  167. # remove build and source links
  168. rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
  169. # remove the firmware
  170. rm -rf "${pkgdir}/lib/firmware"
  171. # gzip -9 all modules to save 100MB of space
  172. find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
  173. # make room for external modules
  174. ln -s "../extramodules-${_basekernel}${_kernelname:lqx}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
  175. # add real version for building modules and running depmod from post_install/upgrade
  176. mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:lqx}"
  177. echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:lqx}/version"
  178.  
  179. # move module tree /lib -> /usr/lib
  180. mv "$pkgdir/lib" "$pkgdir/usr"
  181.  
  182. # Now we call depmod...
  183. depmod -b "$pkgdir" -F System.map "$_kernver"
  184.  
  185. ##mkdir -p "${pkgdir}/lib/modules/${_kernver}"
  186. install -dm755 "${pkgdir}/usr/lib/modules/${_kernver}"
  187.  
  188. ##cd "${pkgdir}/lib/modules/${_kernver}"
  189. ##ln -sf ../../../usr/src/linux-${_kernver} build
  190. cd "${pkgdir}/usr/lib/modules/${_kernver}"
  191. ln -sf ../../../src/linux-${_kernver} build
  192.  
  193.  
  194. cd "${srcdir}/linux-${_basekernel}"
  195. install -D -m644 Makefile \
  196.         "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
  197. install -D -m644 kernel/Makefile \
  198.         "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
  199. install -D -m644 .config \
  200.         "${pkgdir}/usr/src/linux-${_kernver}/.config"
  201.  
  202. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
  203.  
  204. for i in acpi asm-generic config crypto drm generated linux math-emu \
  205.         media net pcmcia scsi sound trace video xen; do
  206. cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
  207.         done
  208.  
  209.         # copy arch includes for external modules
  210.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
  211.         cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
  212.  
  213.         # copy files necessary for later builds, like nvidia and vmware
  214.         cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
  215.         cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
  216.  
  217.         # fix permissions on scripts dir
  218.         chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
  219.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
  220.  
  221.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
  222.  
  223.         cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  224.  
  225.         if [ "${CARCH}" = "i686" ]; then
  226.                 cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  227.         fi
  228.  
  229.         cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
  230.  
  231.         # add headers for lirc package
  232.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
  233.  
  234.         cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
  235.  
  236.         for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
  237.                 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
  238.                 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
  239.         done
  240.  
  241.         # add docbook makefile
  242.         install -D -m644 Documentation/DocBook/Makefile \
  243.                 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
  244.  
  245.         # add dm headers
  246.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  247.         cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  248.  
  249.         # add inotify.h
  250.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
  251.         cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
  252.  
  253.         # add wireless headers
  254.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  255.         cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  256.  
  257.         # add dvb headers for external modules
  258.         # in reference to:
  259.         # http://bugs.archlinux.org/task/9912
  260.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
  261.         cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
  262.         # and...
  263.         # http://bugs.archlinux.org/task/11194
  264.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  265.         [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  266.  
  267.         # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  268.         # in reference to:
  269.         # http://bugs.archlinux.org/task/13146
  270.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  271.         cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  272.         cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  273.  
  274.         # add dvb headers
  275.         # in reference to:
  276.         # http://bugs.archlinux.org/task/20402
  277.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
  278.         cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
  279.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
  280.         cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  281.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
  282.         cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
  283.  
  284.         # add xfs and shmem for aufs building
  285.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
  286.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
  287.         cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
  288.  
  289.         # copy in Kconfig files
  290.         for i in `find . -name "Kconfig*"`; do
  291.                 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
  292.                 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
  293.         done
  294.  
  295.         chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
  296.         find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
  297.  
  298.         # strip scripts directory
  299.         find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
  300.         case "$(file -bi "${binary}")" in
  301.                 *application/x-sharedlib*) # Libraries (.so)
  302.                         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
  303.                 *application/x-archive*) # Libraries (.a)
  304.                         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
  305.                 *application/x-executable*) # Binaries
  306.                         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
  307.         esac
  308. done
  309.  
  310. # remove unneeded architectures
  311. 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}
  312. }