Advertisement
Guest User

Untitled

a guest
Aug 30th, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 16.22 KB | None | 0 0
  1. # Maintainer: graysky <graysky AT archlinux DOT us>
  2. # Contributor: Tobias Powalowski <tpowa@archlinux.org>
  3. # Contributor: Thomas Baechler <thomas@archlinux.org>
  4. ###########################################################################################################
  5. #                                          Patch and Build Options
  6. ###########################################################################################################
  7. #
  8. ## Note all kernels get the ck patch set with BFS so there is no option to enable/disable it!
  9. #
  10. _usearchlogo="y"  # use the blue Arch logo rather than default tux logo when booting
  11. _makenconfig="n"    # select additional kernel options prior to a build via nconfig
  12. _localmodcfg="n"    # compile ONLY probed modules - see notes below!
  13. _localyescfg="n"    # convert all modules to core - see notes below!
  14. _use_current="n"    # use the current kernel's .config file - see notes below!
  15. _BFQ_enable_="n"    # enable BFQ as the default I/O scheduler
  16. ###########################################################################################################
  17. #                                        More Details and References
  18. ###########################################################################################################
  19. ## LOCALMODCONFIG OPTION
  20. # As of mainline 2.6.32, running with this option will only build the modules that you currently have
  21. # probed in your system VASTLY reducing the number of modules build.
  22. #
  23. # WARNING - make CERTAIN that all modules are modprobed BEFORE you begin making the pkg!
  24. # Read, https://bbs.archlinux.org/viewtopic.php?pid=830221#p830221
  25. # To keep track of which modules are needed for your specific system/hardware, give my module_db script
  26. # a try: http://aur.archlinux.org/packages.php?ID=41689
  27. #
  28. # Note that if you use my script, this PKGBUILD will auto run the reload_data base for you to probe
  29. # all the modules you have logged!
  30. #
  31. ## LOCALYESCONFIG OPTION
  32. # This adds the option localyesconfig to make. This is similar to localmodconfig, but after it removes
  33. # unnecessary modules it runs "sed -i s/=m/=y/" on the .config file. It then runs "make silentoldconfig"
  34. # to fix any holes that were created by the conversion of modules to core.
  35. ## USE CURRENT KERNEL'S .CONFIG
  36. # Enabling this option will use the .config of the RUNNING kernel rather than the ARCH defaults.
  37. # Useful when the package gets updated and you already went through the trouble of customizing your
  38. # config options.  NOT recommended when a new kernel is released, but again, convenient for package bumps.
  39. ## BFQ
  40. # Read, http://algo.ing.unimo.it/people/paolo/disk_sched/
  41. #
  42. ###########################################################################################################
  43. pkgname=linux-ck
  44. true && pkgname=(linux-ck linux-ck-headers)
  45. _kernelname=-ck
  46. _basekernel=3.0
  47. pkgver=${_basekernel}.3
  48. pkgrel=4
  49. arch=('i686' 'x86_64')
  50. url="https://wiki.archlinux.org/index.php/linux-ck"
  51. license=('GPL2')
  52. #makedepends=('xmlto' 'docbook-xsl')
  53. options=('!strip')
  54. _ckpatchversion=1
  55. _ckpatchname="patch-${_basekernel}.0-ck${_ckpatchversion}"
  56. _bfqpath="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/3.0.0"
  57. source=("ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-${_basekernel}.tar.bz2"
  58. "ftp://ftp.kernel.org/pub/linux/kernel/v3.0/patch-${pkgver}.gz"
  59. # the main kernel config files
  60. 'config' 'config.x86_64'
  61. 'linux-ck.install' 'linux-ck.preset' # standard config files for mkinitcpio ramdisk
  62. 'fix-i915.patch'
  63. 'change-default-console-loglevel.patch'
  64. http://www.kernel.org/pub/linux/kernel/people/ck/patches/${_basekernel}/${_basekernel}.0-ck${_ckpatchversion}/${_ckpatchname}.bz2 # ck_patchset
  65. #${_bfqpath}/{0001 0002 0003} # bfq patchset
  66. logo_linux_mono.pbm # optional Arch logo for boot
  67. logo_linux_{clut224,vga16}.ppm) # optional Arch logo for boot
  68.  
  69. build() {
  70.     cd "${srcdir}/linux-${_basekernel}"
  71.  
  72.     patch -p1 -i "${srcdir}/patch-${pkgver}"
  73.  
  74.     # add latest fixes from stable queue, if needed
  75.     # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
  76.  
  77.     # fix #19234 i1915 display size
  78.     patch -Np1 -i "${srcdir}/fix-i915.patch"
  79.  
  80.     # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
  81.     # remove this when a Kconfig knob is made available by upstream
  82.     # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
  83.     patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
  84.  
  85.     ### Patch source with ck patchset with BFS
  86.     # Fix double name in EXTRAVERSION
  87.     sed -i -re "s/^(.EXTRAVERSION).*$/\1 = /" ${srcdir}/${_ckpatchname}
  88.     msg "Patching source with the ck1 patch set using bfs v0.406"
  89.     patch -Np1 -i ${srcdir}/${_ckpatchname}
  90.  
  91.     ### Optionally enable BFQ IO Scheduler as default
  92.     #   msg "Patching source with BFQ patches"
  93.     #   for p in $(ls ${srcdir}/000*.patch); do
  94.     #       patch -Np1 -i $p
  95.     #   done
  96.  
  97.     ### Clean tree and copy ARCH config over
  98.     msg "Running make mrproper to clean source tree"
  99.     make mrproper
  100.  
  101.     if [ "$CARCH" = "x86_64" ]; then
  102.         cat ../config.x86_64 >./.config
  103.     else
  104.         cat ../config >./.config
  105.     fi
  106.  
  107.     ### Optionally use the blue Arch logo at kernel load
  108.     if [ $_usearchlogo = "y" ]; then
  109.         install -m644 ${srcdir}/logo_linux_clut224.ppm drivers/video/logo/
  110.         install -m644 ${srcdir}/logo_linux_mono.pbm drivers/video/logo/
  111.         install -m644 ${srcdir}/logo_linux_vga16.ppm drivers/video/logo/
  112.         sed -i -e 's/# CONFIG_LOGO is not set/CONFIG_LOGO=y\nCONFIG_LOGO_LINUX_MONO=y\nCONFIG_LOGO_LINUX_VGA16=y\nCONFIG_LOGO_LINUX_CLUT224=y/' ./.config
  113.     fi
  114.  
  115.     ### Optionally use running kernel's config
  116.     # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
  117.     if [ $_use_current = "y" ]; then
  118.         if [[ -s /proc/config.gz ]]; then
  119.             msg "Extracting config from /proc/config.gz..."
  120.             modprobe configs
  121.             zcat /proc/config.gz > ./.config
  122.         else
  123.             warning "You kernel was not compiled with IKCONFIG_PROC!"
  124.             warning "You cannot read the current config!"
  125.             warning "Aborting!"
  126.             exit
  127.         fi
  128.     fi
  129.  
  130.     if [ "${_kernelname}" != "" ]; then
  131.         sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  132.     fi
  133.  
  134.     ### Optionally enable BFQ as the default io scheduler
  135.     if [ $_BFQ_enable_ = "y" ]; then
  136.         sed -i -e s'/CONFIG_CFQ_GROUP_IOSCHED=y/CONFIG_CFQ_GROUP_IOSCHED=y\nCONFIG_IOSCHED_BFQ=y\nCONFIG_CGROUP_BFQIO=y/' \
  137.             -i -e s'/CONFIG_DEFAULT_CFQ=y/# CONFIG_DEFAULT_CFQ is not set\nCONFIG_DEFAULT_BFQ=y/' \
  138.             -i -e '/CONFIG_DEFAULT_IOSCHED/ s,cfq,bfq,' ./.config
  139.     fi
  140.  
  141.     # remove the sublevel from Makefile
  142.     # this ensures our kernel version is always 3.X-ARCH
  143.     # this way, minor kernel updates will not break external modules
  144.     # we need to change this soon, see FS#16702
  145.     sed -ri 's|^(SUBLEVEL =).*|\1|' Makefile
  146.  
  147.     # get kernel version
  148.     msg "Running make prepare for you to enable patched options of your choosing"
  149.     make prepare
  150.  
  151.     ### Optionally load needed modules for the make localmodconfig
  152.     # See http://aur.archlinux.org/packages.php?ID=41689
  153.     if [ $_localmodcfg = "y" ]; then
  154.         msg "If you have modprobe_db installed, running reload_database now"
  155.         if [ -e /usr/bin/reload_database ]; then
  156.             /usr/bin/reload_database
  157.         fi
  158.         msg "Running Steven Rostedt's make localmodconfig now"
  159.         make localmodconfig
  160.     fi
  161.  
  162.     if [ $_localyescfg = "y" ]; then
  163.         msg "Running make localyesconfig"
  164.         make localyesconfig
  165.     fi
  166.  
  167.     if [ $_makenconfig = "y" ]; then
  168.         msg "Running make nconfig"
  169.         make nconfig
  170.     fi
  171.  
  172.     msg "Running make bzImage and modules"
  173.     make ${MAKEFLAGS} KCFLAGS="-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2" KCPPFLAGS="-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2" bzImage modules
  174. }
  175.  
  176. package_linux-ck() {
  177. _Kpkgdesc='The Linux Kernel and modules with Brain Fuck Scheduler v0.406 and all the goodies in the ck1 patch set.'
  178. pkgdesc="${_Kpkgdesc}"
  179. depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
  180. optdepends=('crda: to set the correct wireless channels of your country' 'lirc-ck: Linux Infrared Remote Control kernel modules for linux-ck' 'nvidia-ck: nVidia drivers for linux-ck' 'nvidia-beta-ck: nVidia beta drivers for linux-ck' 'modprobed_db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig')
  181. provides=("${pkgname}=${pkgver}")
  182. conflicts=('kernel26-ck')
  183. replaces=('kernel26-ck')
  184. backup=("etc/mkinitcpio.d/linux-ck.preset")
  185. install=linux-ck.install
  186. #groups=('ck-generic')
  187.  
  188. cd "${srcdir}/linux-${_basekernel}"
  189. KARCH=x86
  190.  
  191. # get kernel version
  192. _kernver="$(make kernelrelease)"
  193.  
  194. mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
  195. make INSTALL_MOD_PATH="${pkgdir}" modules_install
  196. cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-linux-ck"
  197.  
  198. # add vmlinux
  199. install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
  200.  
  201. # install fallback mkinitcpio.conf file and preset file for kernel
  202. install -D -m644 "${srcdir}/linux-ck.preset" "${pkgdir}/etc/mkinitcpio.d/linux-ck.preset"
  203.  
  204. # set correct depmod command for install
  205. sed \
  206.     -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
  207.     -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
  208.     -i "${startdir}/linux-ck.install"
  209. sed \
  210.     -e "s|default_image=.*|default_image=\"/boot/initramfs-linux-ck.img\"|g" \
  211.     -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-linux-ck-fallback.img\"|g" \
  212.     -i "${pkgdir}/etc/mkinitcpio.d/linux-ck.preset"
  213.  
  214. # remove build and source links
  215. rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
  216. # add compat symlink for the kernel image
  217. ln -sf vmlinuz-linux-ck "${pkgdir}/boot/vmlinuz26${_kernelname}"
  218. # remove the firmware
  219. rm -rf "${pkgdir}/lib/firmware"
  220. # gzip -9 all modules to save 100MB of space
  221. find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
  222. }
  223.  
  224. package_linux-ck-headers() {
  225. _Hpkgdesc='Header files and scripts to build modules for linux-ck.'
  226. pkgdesc="${_Hpkgdesc}"
  227. provides=("${pkgname}=${pkgver}")
  228. conflicts=('kernel26-ck-headers')
  229. replaces=('kernel26-ck-headers')
  230. #groups=('ck-generic')
  231.  
  232. mkdir -p "${pkgdir}/lib/modules/${_kernver}"
  233.  
  234. cd "${pkgdir}/lib/modules/${_kernver}"
  235. ln -sf ../../../usr/src/linux-${_kernver} build
  236.  
  237. cd "${srcdir}/linux-${_basekernel}"
  238. install -D -m644 Makefile \
  239.     "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
  240. install -D -m644 kernel/Makefile \
  241.     "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
  242. install -D -m644 .config \
  243.     "${pkgdir}/usr/src/linux-${_kernver}/.config"
  244.  
  245. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
  246.  
  247. for i in acpi asm-generic config crypto drm generated linux math-emu \
  248.     media net pcmcia scsi sound trace video xen; do
  249. cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
  250. done
  251.  
  252. # copy arch includes for external modules
  253. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
  254. cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
  255.  
  256. # copy files necessary for later builds, like nvidia and vmware
  257. cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
  258. cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
  259.  
  260. # fix permissions on scripts dir
  261. chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
  262. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"
  263.  
  264. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"
  265.  
  266. cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  267.  
  268. if [ "${CARCH}" = "i686" ]; then
  269.     cp arch/${KARCH}/Makefile_32.cpu "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"
  270. fi
  271.  
  272. cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"
  273.  
  274. # add headers for lirc package
  275. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video"
  276.  
  277. cp drivers/media/video/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/"
  278.  
  279. for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
  280.     mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
  281.     cp -a drivers/media/video/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/${i}"
  282. done
  283.  
  284. # add docbook makefile
  285. install -D -m644 Documentation/DocBook/Makefile \
  286.     "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
  287.  
  288. # add dm headers
  289. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  290. cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  291.  
  292. # add inotify.h
  293. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
  294. cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"
  295.  
  296. # add wireless headers
  297. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  298. cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  299.  
  300. # add dvb headers for external modules
  301. # in reference to:
  302. # http://bugs.archlinux.org/task/9912
  303. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
  304. cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
  305. # and...
  306. # http://bugs.archlinux.org/task/11194
  307. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  308. for i in $(ls ./include/config/dvb/*.h); do
  309.     [[ -e "$i" ]] && cp $i "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  310. done
  311.  
  312. # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  313. # in reference to:
  314. # http://bugs.archlinux.org/task/13146
  315. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  316. cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  317. cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  318.  
  319. # add dvb headers
  320. # in reference to:
  321. # http://bugs.archlinux.org/task/20402
  322. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
  323. cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
  324. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
  325. cp drivers/media/dvb/frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
  326. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners"
  327. cp drivers/media/common/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/"
  328.  
  329. # add xfs and shmem for aufs building
  330. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
  331. mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
  332. cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
  333.  
  334. # copy in Kconfig files
  335. for i in `find . -name "Kconfig*"`; do
  336.     mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
  337.     cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
  338. done
  339.  
  340. chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
  341. find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;
  342.  
  343. # strip scripts directory
  344. find "${pkgdir}/usr/src/linux-${_kernver}/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
  345. case "$(file -bi "${binary}")" in
  346.     *application/x-sharedlib*) # Libraries (.so)
  347.         /usr/bin/strip ${STRIP_SHARED} "${binary}";;
  348.     *application/x-archive*) # Libraries (.a)
  349.         /usr/bin/strip ${STRIP_STATIC} "${binary}";;
  350.     *application/x-executable*) # Binaries
  351.         /usr/bin/strip ${STRIP_BINARIES} "${binary}";;
  352. esac
  353. done
  354.  
  355. # remove unneeded architectures
  356. 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}
  357. }
  358. # Global pkgdesc and depends are here so that they will be picked up by AUR
  359. pkgdesc='The Linux Kernel and modules with Brain Fuck Scheduler v0.406 and all the goodies in the ck1 patch set.'
  360. sha256sums=('64b0228b54ce39b0b2df086109a7b737cde58e3df4f779506ddcaccee90356a0'
  361. 'ffc606851dba5c1fe9a6590492f16f39798297c6beb28b5baa1b476018f4b244'
  362. '9ca531cfc309fed1c01a297b7e08db844c01509a8ffbfc83fd91086858dcd95f'
  363. 'ff686ca6ce4ca152991e34fda7d1408eafeee70d3db392cca129fccb3d817069'
  364. '2a8bdb10801a1205c90d0f77b227a5e026317156fd0961c14b69aadb9dbb808f'
  365. 'c2cf8cc2600502de348f3dc3aae9a3bde5486759db15cb8a93df7aa35bd6e7da'
  366. '9ccadbe3eb30bb283af3eb869c3a4bdb764628854811cc616a2e02e9ef398705'
  367. 'b9d79ca33b0b51ff4f6976b7cd6dbb0b624ebf4fbf440222217f8ffc50445de4'
  368. '34ca007d90df006e70b7de31e6db969c63d3c7f6e141463cff036b89b7d22ee0'
  369. '1e5bea8de1c2cc24498fb9a4fdbb313f36f38f671f2bfc46ccf7acbd7958a4b9'
  370. '111feb3ac4a8a80b6aae616c5dff8cd62e2b9c8719b390dfa72b45101592fadc'
  371. '5147681ae1ef8ca99d458f3a074058267876647b7287b702f5bcf07e795d7e43')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement