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

linux-uksm-3.6.3.PKGBUILD

By: ImNtReal on Oct 15th, 2012  |  syntax: Bash  |  size: 14.00 KB  |  hits: 46  |  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: Figo.zhang <figo1802@gmail.com>
  2. # Maintainer: Lawliet <yanzilme@gmail.com>
  3.  
  4. ### PATCH AND BUILD OPTIONS
  5. _makenconfig="n"        # tweak kernel options prior to a build via nconfig
  6. _makemenuconfig="n"     # make menuconfig before compilation starts
  7. _localmodcfg="n"        # compile ONLY probed modules
  8. _use_current="n"        # use the current kernel's .config file
  9. MAKEFLAGS=""            # add your custom make flag here, such as -j 4
  10.  
  11. ### DOCS
  12. # DETAILS FOR _localmodcfg="y"
  13. # As of mainline 2.6.32, running with this option will only build the modules that you currently have
  14. # probed in your system VASTLY reducing the number of modules built and the build time to do it.
  15. #
  16. # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
  17. #
  18. # To keep track of which modules are needed for your specific system/hardware, give my module_db script
  19. # a try: http://aur.archlinux.org/packages.php?ID=41689  Note that if you use my script, this PKGBUILD
  20. # will auto run the 'sudo modprobed_db reload' for you to probe all the modules you have logged!
  21. #
  22. # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed_db
  23.  
  24. # DETAILS FOR _use_current="y"
  25. # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
  26. # Useful when the package gets updated and you already went through the trouble of customizing your
  27. # config options.  NOT recommended when a new kernel is released, but again, convenient for package bumps.
  28.  
  29. # DETAILS FOR _BFQ_enable="y"
  30. # Alternative I/O scheduler by Paolo.  For more, see: http://algo.ing.unimo.it/people/paolo/disk_sched/
  31.  
  32. pkgname=linux-uksm
  33. true && pkgname=(linux-uksm linux-uksm-headers)
  34. _kernelname=-uksm
  35. _srcname=linux-3.6
  36. pkgver=3.6.2
  37. pkgrel=1
  38. arch=('i686' 'x86_64')
  39. url="http://kerneldedup.org/"
  40. license=('GPL2')
  41. options=('!strip')
  42. _uksmname="v3.6"
  43. _uksmvernel="0.1.2.0"
  44. source=(
  45.         "http://www.kernel.org/pub/linux/kernel/v3.x/${_srcname}.tar.xz"
  46.         "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
  47.         "http://kerneldedup.org/download/uksm/${_uksmvernel}/uksm-${_uksmvernel}-for-${_uksmname}.patch"
  48.         'linux-uksm.preset'
  49.         'change-default-console-loglevel.patch'
  50.         "config"
  51.         "config.x86_64"
  52.         )
  53.  
  54. sha256sums=(
  55.             '4ab9a6ef1c1735713f9f659d67f92efa7c1dfbffb2a2ad544005b30f9791784f'
  56.             'fa68a9c8a9885304d96851c3fd1c977437f655073492e3e94c9dc7f20286fd1b'
  57.             '1c5f89ae5c022ffca75b604beac5cdf9c1e617e3c5ccd7f2606aed8e5d612745'
  58.             '28a956ae3f2a080f7fed0d043b3d2351494feda2128c4cd5ff64964c5c008032'
  59.             'b9d79ca33b0b51ff4f6976b7cd6dbb0b624ebf4fbf440222217f8ffc50445de4'
  60.             '6d75e17ade3bffca206298e9d859d49644f10d97b16a8b52dc029e7916eee807'
  61.             'e28f07f27259798dfb4ad8e84b6ded7d3f38e820ef571c629b328e64d82a3b2d'
  62.             )
  63.            
  64. build() {
  65.         cd "${srcdir}/${_srcname}"
  66.  
  67.         ### add upstream patch
  68.         msg "Patching kernel patch"
  69.         patch -p1 -i "${srcdir}/patch-${pkgver}"
  70.  
  71.         ### set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
  72.         # remove this when a Kconfig knob is made available by upstream
  73.         # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
  74.         msg "Patching set DEFAULT_CONSOLE_LOGLEVEL to 4"
  75.         patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
  76.        
  77.         ### Patch source with UKSM
  78.         msg "Patching with UKSM"
  79.         patch -Np1 -i "${srcdir}/uksm-${_uksmvernel}-for-${_uksmname}.patch"
  80.  
  81.         ### Clean tree and copy ARCH config over
  82.         msg "Running make mrproper to clean source tree"
  83.         make mrproper
  84.  
  85.         if [ "${CARCH}" = "x86_64" ]; then
  86.                 cat "${srcdir}/config.x86_64" > ./.config
  87.         else
  88.                 cat "${srcdir}/config" > ./.config
  89.         fi
  90.  
  91.         ### Optionally use running kernel's config
  92.         # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
  93.         if [ $_use_current = "y" ]; then
  94.                 if [[ -s /proc/config.gz ]]; then
  95.                         msg "Extracting config from /proc/config.gz..."
  96.                         # modprobe configs
  97.                         zcat /proc/config.gz > ./.config
  98.                 else
  99.                         warning "You kernel was not compiled with IKCONFIG_PROC!"
  100.                         warning "You cannot read the current config!"
  101.                         warning "Aborting!"
  102.                         exit
  103.                 fi
  104.         fi
  105.  
  106.         if [ "${_kernelname}" != "" ]; then
  107.                 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  108.                 sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
  109.         fi
  110.  
  111.         ### BFQ to be compiled in but not enabled
  112.         sed -i -e s'/CONFIG_CFQ_GROUP_IOSCHED=y/CONFIG_CFQ_GROUP_IOSCHED=y\nCONFIG_IOSCHED_BFQ=y\nCONFIG_CGROUP_BFQIO=y/' \
  113.                 -i -e s'/CONFIG_DEFAULT_CFQ=y/CONFIG_DEFAULT_CFQ=y\n# CONFIG_DEFAULT_BFQ is not set/' ./.config
  114.  
  115.         # set extraversion to pkgrel
  116.         sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
  117.  
  118.         # don't run depmod on 'make install'. We'll do this ourselves in packaging
  119.         sed -i '2iexit 0' scripts/depmod.sh
  120.  
  121.         # get kernel version
  122.         msg "Running make prepare for you to enable patched options of your choosing"
  123.         make prepare
  124.  
  125.         ### Optionally load needed modules for the make localmodconfig
  126.         # See http://aur.archlinux.org/packages.php?ID=41689
  127.         if [ $_localmodcfg = "y" ]; then
  128.                 msg "If you have modprobe_db installed, running it in recall mode now"
  129.                 if [ -e /usr/bin/modprobed_db ]; then
  130.                         [[ ! -x /usr/bin/sudo ]] && echo "Cannot call modprobe with sudo.  Install via pacman -S sudo and configure to work with this user." && exit 1
  131.                         sudo /usr/bin/modprobed_db recall
  132.                 fi
  133.                 msg "Running Steven Rostedt's make localmodconfig now"
  134.                 make localmodconfig
  135.         fi
  136.  
  137.         if [ $_makenconfig = "y" ]; then
  138.                 msg "Running make nconfig"
  139.                 make nconfig
  140.         fi
  141.  
  142.         if [ $_makemenuconfig = "y" ]; then
  143.                 msg "Running make menuconfig"
  144.                 make menuconfig
  145.         fi
  146.  
  147.         msg "Running make bzImage and modules"
  148.         make ${MAKEFLAGS} LOCALVERSION= bzImage modules
  149. }
  150.  
  151. package_linux-uksm() {
  152. _Kpkgdesc='Linux Kernel and modules with the ck1 patchset featuring the Brain Fuck Scheduler v0.424.'
  153. pkgdesc="${_Kpkgdesc}"
  154. depends=('coreutils' 'linux-firmware' 'mkinitcpio>=0.7')
  155. optdepends=('crda: to set the correct wireless channels of your country' 'nvidia-uksm: nVidia drivers for linux-uksm' 'modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig')
  156. provides=("linux-uksm=${pkgver}")
  157. conflicts=('kernel26-uksm')
  158. replaces=('kernel26-uksm')
  159. backup=("etc/mkinitcpio.d/linux-uksm.preset")
  160. install=linux-uksm.install
  161. #groups=('ck-generic')
  162.  
  163. cd "${srcdir}/${_srcname}"
  164.  
  165. KARCH=x86
  166.  
  167. # get kernel version
  168. _kernver="$(make LOCALVERSION= kernelrelease)"
  169. _basekernel=${_kernver%%-*}
  170. _basekernel=${_basekernel%.*}
  171.  
  172. mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
  173. make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}" modules_install
  174. cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-linux-uksm"
  175.  
  176. # add vmlinux
  177. install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
  178.  
  179. # install fallback mkinitcpio.conf file and preset file for kernel
  180. install -D -m644 "${srcdir}/linux-uksm.preset" "${pkgdir}/etc/mkinitcpio.d/linux-uksm.preset"
  181.  
  182. # set correct depmod command for install
  183. sed \
  184.         -e  "s/KERNEL_NAME=.*/KERNEL_NAME=-uksm/g" \
  185.         -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
  186.         -i "${startdir}/linux-uksm.install"
  187. sed \
  188.         -e "1s|'linux.*'|'linux-uksm'|" \
  189.         -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-linux-uksm\"|" \
  190.         -e "s|default_image=.*|default_image=\"/boot/initramfs-linux-uksm.img\"|" \
  191.         -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-linux-uksm-fallback.img\"|" \
  192.         -i "${pkgdir}/etc/mkinitcpio.d/linux-uksm.preset"
  193.  
  194. # remove build and source links
  195. rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
  196. # remove the firmware
  197. rm -rf "${pkgdir}/lib/firmware"
  198. # gzip -9 all modules to save 100MB of space
  199. find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
  200. # make room for external modules
  201. ln -s "../extramodules-${_basekernel}${_kernelname:ck}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
  202. # add real version for building modules and running depmod from post_install/upgrade
  203. mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}"
  204. echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:ck}/version"
  205.  
  206. # Now we call depmod...
  207. depmod -b "$pkgdir" -F System.map "$_kernver"
  208.  
  209. # move module tree /lib -> /usr/lib
  210. mv "$pkgdir/lib" "$pkgdir/usr"
  211. }
  212. package_linux-uksm-headers() {
  213. _Hpkgdesc='Header files and scripts to build modules for linux-uksm.'
  214. pkgdesc="${_Hpkgdesc}"
  215. provides=("linux-uksm-headers=${pkgver}")
  216. conflicts=('kernel26-uksm-headers')
  217. replaces=('kernel26-uksm-headers')
  218.  
  219. install -dm755 "${pkgdir}/usr/lib/modules/${_kernver}"
  220.  
  221. cd "${pkgdir}/usr/lib/modules/${_kernver}"
  222. ln -sf ../../../src/linux-${_kernver} build
  223.  
  224. cd "${srcdir}/${_srcname}"
  225. install -D -m644 Makefile \
  226.         "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
  227. install -D -m644 kernel/Makefile \
  228.         "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
  229. install -D -m644 .config \
  230.         "${pkgdir}/usr/src/linux-${_kernver}/.config"
  231.  
  232. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
  233.  
  234. for i in acpi asm-generic config crypto drm generated linux math-emu \
  235.         media net pcmcia scsi sound trace video xen; do
  236. cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
  237.         done
  238.  
  239.         # copy arch includes for external modules
  240.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
  241.         cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
  242.  
  243.         # copy files necessary for later builds, like nvidia and vmware
  244.         cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
  245.         cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
  246.  
  247.         # fix permissions on scripts dir
  248.         chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
  249.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
  250.  
  251.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
  252.  
  253.         cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  254.  
  255.         if [ "${CARCH}" = "i686" ]; then
  256.                 cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  257.         fi
  258.  
  259.         cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
  260.  
  261.         # add headers for lirc package
  262.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
  263.  
  264.         cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
  265.  
  266.         for i in bt8xx cpia2 cx25840 cx88 em28xx pwc saa7134 sn9c102; do
  267.                 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
  268.                 cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
  269.         done
  270.  
  271.         # add docbook makefile
  272.         install -D -m644 Documentation/DocBook/Makefile \
  273.                 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
  274.  
  275.         # add dm headers
  276.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  277.         cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  278.  
  279.         # add inotify.h
  280.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
  281.         cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
  282.  
  283.         # add wireless headers
  284.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  285.         cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  286.  
  287.         # add dvb headers for external modules
  288.         # in reference to:
  289.         # http://bugs.archlinux.org/task/9912
  290.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
  291.         cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
  292.         # and...
  293.         # http://bugs.archlinux.org/task/11194
  294.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  295.         [[ -e include/config/dvb/ ]] && cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  296.  
  297.         # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  298.         # in reference to:
  299.         # http://bugs.archlinux.org/task/13146
  300.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  301.         cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  302.         cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  303.  
  304.         # add dvb headers
  305.         # in reference to:
  306.         # http://bugs.archlinux.org/task/20402
  307.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
  308.         cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
  309.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
  310.         cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  311.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
  312.         cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
  313.  
  314.         # add xfs and shmem for aufs building
  315.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
  316.         mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
  317.         cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
  318.  
  319.         # copy in Kconfig files
  320.         for i in `find . -name "Kconfig*"`; do
  321.                 mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
  322.                 cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
  323.         done
  324.  
  325.         chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
  326.         find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
  327.  
  328.         # strip scripts directory
  329.         find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
  330.         case "$(file -bi "${binary}")" in
  331.                 *application/x-sharedlib*) # Libraries (.so)
  332.                         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
  333.                 *application/x-archive*) # Libraries (.a)
  334.                         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
  335.                 *application/x-executable*) # Binaries
  336.                         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
  337.         esac
  338. done
  339.  
  340. # remove unneeded architectures
  341. 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}
  342. }
  343. # Global pkgdesc and depends are here so that they will be picked up by AUR
  344. pkgdesc='Linux kernel and modules with the UKSM patch.'