1 # Maintainer: Sascha Biermanns <email via http://privacybox.de/saschakb.msg>
3 # based on the linux-git packagebuild
5 pkgbase=linux-next$_pkgext
9 # comment the following line to build a single package containing the kernel and the headers
10 (( 1 )) && pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
11 pkgdesc="The Linux Kernel and modules from Linus' next git tree. Download with yaourt -G and build with makepkg, to use the advantage of GIT."
12 depends=('coreutils' 'linux-firmware-git' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.6.8')
16 url="http://www.kernel.org/"
20 source=(config.{i686,x86_64} \
21 logo_linux_{clut224.ppm,mono.pbm,vga16.ppm})
22 md5sums=('b719d1bd943cfd5d997f3c6d17948216'
23 '28374378684d3ac4522e0709ca471da7'
24 '6a5a1925501fe20fafd04fdb3cb4f6ed'
25 'e8c333eaeac43f5c6a1d7b2f47af12e2'
26 'c120adbd9c0daa0136237a83adeabd1e')
27 sha256sums=('2c38a2226367a87bc0721b8088f123b0694cd4658e3e54d05fba9f3300f18211'
28 '741e67d8f0cedab0647e94637d289c572e967904ad15b0ab0694352a346e2336'
29 '4274579ccf42a9acc03283edffea2dda2c4a48e3fd734bbaeada4c16dff9d156'
30 '1e5bea8de1c2cc24498fb9a4fdbb313f36f38f671f2bfc46ccf7acbd7958a4b9'
31 'f9c7c1275313890fc12f6bab92e2c0794b5041e223d868eb0e34cd99baee3d7a')
33 _gitroot="git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git"
34 _gitname="linux-2.6.git"
37 ####################################################################
40 # This PKGBUILD searches for config files in the current directory
41 # and will use the first one it finds from the following
42 # list as base configuration:
47 ####################################################################
50 #############################################################
53 # This package builds the vanilla git kernel by default,
54 # but it is possible to patch the source without modifying
57 # Simply create a directory 'patches' in your PKGBUILD
58 # directory and _any_ file (dotfiles excluded) in this
59 # folder will be applied to the kernel source.
61 # Prefixing the patch file names with dots will obviously
62 # excluded them from the patching process.
64 #############################################################
67 #############################
70 # Uncomment desired options
71 #############################
75 # Set to e.g. menuconfig, xconfig or gconfig
77 # For a full list of supported commands, please have a look
78 # at "Configuration targets" section of `make help`'s output
79 # or the help target in scripts/kconfig/Makefile ( http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=scripts/kconfig/Makefile )
81 # If unset or set to an empty or space-only string, the
82 # (manual) kernel configuration step will be skipped.
84 _config_cmd="${_config_cmd:-menuconfig}"
88 # The directory where the kernel should be built
90 # Can be useful, for example, if you want to compile on a
91 # tmpfs mount, which can speed up the compilation process
93 _build_dir="${_build_dir:-$srcdir}"
97 # Stop build process after kernel configuration
99 # This option enables _save_config implicitly.
105 # Append the date to the localversion
107 # e.g. -ARCH -> -ARCH-20090422
109 # _date_localversion=1
113 # Set the pkgver to the kernel version
114 # rather than the build date
120 # Save the .config file to package directory
121 # as config.saved.$CARCH
127 # Do not compress kernel modules
129 # _no_modules_compression=1
133 # Make the kernel build process verbose
139 if [[ -n $_gitname && -n $_gitroot ]]; then
140 (( 1 )) && _kernel_src="$_build_dir/$_gitname-build"
142 (( 1 )) && _kernel_src="$_build_dir/$(find . -maxdepth 1 -type d -name "linux-*" -printf "%f\n" | head -1)"
146 # define required functions
150 eval package_$pkgbase-headers
151 eval package_$pkgbase
154 # split package functions
155 eval "package_$pkgbase() { _generic_package_linux; }"
156 eval "package_$pkgbase-headers() { _generic_package_linux-headers; }"
157 eval "package_$pkgbase-docs() { _generic_package_linux-docs; }"
160 ##############################
161 # where the magic happens...
162 ##############################
164 if [[ -n $_gitname && -n $_gitroot ]]; then
165 #################################
166 # Get the latest kernel sources
167 #################################
168 msg "Fetching sources..."
171 if [[ -d $_gitname ]]; then
172 msg2 "Updating sources..."
177 msg2 "Cloning the project..."
178 warning "The initial clone will download approximately 450 mb"
179 git clone --mirror "$_gitroot" "$_gitname"
182 msg "Creating build branch..."
183 rm -rf "$_kernel_src"
184 git clone "$_gitname" "$_kernel_src"
190 ####################################
191 # Add Arch Linux logo to the source
192 ####################################
193 msg "Adding Arch Linux logo..."
194 cp "$srcdir/logo_linux_clut224.ppm" drivers/video/logo/
195 cp "$srcdir/logo_linux_mono.pbm" drivers/video/logo/
196 cp "$srcdir/logo_linux_vga16.ppm" drivers/video/logo/
202 msg "Applying patches..."
204 for i in "${source[@]}"; do
206 [[ $i =~ .*\.patch$ ]] && patches=("${patches[@]}" "$srcdir/$i")
207 [[ ${i%.*} =~ .*\.patch$ ]] && patches=("${patches[@]}" "$srcdir/${i%.*}")
211 for i in "${patches[@]}" "$startdir/patches/"*; do
212 msg2 "Applying ${i##*/}..."
213 patch -Np1 -i "$i" || (error "Applying ${i##*/} failed" && return 1)
222 #########################
223 # Loading configuration
224 #########################
225 msg "Loading configuration..."
226 for i in local "saved.$CARCH" "$CARCH"; do
227 if [[ -e $startdir/config.$i ]]; then
228 msg2 "Using kernel config file config.$i..."
229 cp -f "$startdir/config.$i" .config
234 [[ ! -e .config ]] &&
235 warning "No suitable kernel config file was found. You'll have to configure the kernel from scratch."
238 ###########################
239 # Start the configuration
240 ###########################
241 msg "Updating configuration..."
242 # cloning yet used config
243 yes "" | make oldconfig > /dev/null
246 sed -ri "s@s(bin/lsmod)@\1@" scripts/kconfig/streamline_config.pl
248 if [[ -n ${_config_cmd// /} ]]; then
249 msg2 "Running make $_config_cmd..."
252 warning "Unknown config command: $_config_cmd"
256 ##############################################
257 # Save the config file the package directory
258 ##############################################
259 if [[ -n $_save_config || -n $_configure_only ]]; then
260 msg "Saving configuration..."
261 msg2 "Saving $_kernel_src/.config as $startdir/config.saved.$CARCH"
262 cp .config "$startdir/config.saved.$CARCH"
266 #######################################
267 # Stop after configuration if desired
268 #######################################
269 if [[ -n $_configure_only ]]; then
270 rm -rf "$_kernel_src" "$srcdir" "$pkgdir"
275 ###############################
276 # Append date to localversion
277 ###############################
278 if [[ -n $_date_localversion ]]; then
279 local _localversion="$(sed -rn 's/^CONFIG_LOCALVERSION="([^"]*)"$/\1/p' .config)"
280 [[ -n $_localversion ]] && msg2 "CONFIG_LOCALVERSION is set to: $_localversion"
282 # since this is a git package, the $pkgver is equal to $(date +%Y%m%d)
283 msg2 "Appending $pkgver to CONFIG_LOCALVERSION..."
284 sed -ri "s/^(CONFIG_LOCALVERSION=).*$/\1\"$_localversion-$pkgver\"/" .config
292 ################################
293 # Build the kernel and modules
294 ################################
295 msg "Building kernel and modules..."
296 make $MAKEFLAGS V="$_verbose" bzImage modules
303 ###################################
304 # Copy files from build directory
305 ####################################
306 if (( ! CLEANUP )) && [[ $_build_dir != $srcdir ]]; then
307 msg "Saving $_kernel_src to $srcdir/${_kernel_src##*/}..."
308 mv "$_kernel_src" "$srcdir"
309 rm -rf "$_kernel_src"
314 _generic_package_initialization() {
319 ######################
321 ######################
322 _kernver=$(make kernelrelease)
323 _basekernel=${_kernver%%-*}
326 ############################################################
327 # Use kernel version instead of the current date as pkgver
328 ############################################################
329 if [[ -n $_kernel_pkgver ]]; then
330 pkgver=${_kernver//-/_}
331 msg "Setting pkgver to kernel version: $pkgver"
335 _generic_package_linux() {
336 pkgdesc="The Linux Kernel and modules from Linus' git tree"
337 depends=('coreutils' 'linux-firmware-git' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.6.8')
338 backup=(etc/mkinitcpio.d/$pkgname.preset)
339 install=$pkgname.install
340 changelog=$pkgname.changelog
342 # set required variables
343 _generic_package_initialization
346 #############################################################
347 # Provide linux (and kernel3 for backwards compatibility)
348 # (probably someone wants to use this kernel exclusively?)
349 #############################################################
350 provides=("${provides[@]}" {linux,kernel3}="${_kernver//-/_}")
357 #####################
359 #####################
360 msg "Installing kernel image..."
361 install -Dm644 System.map "$pkgdir/boot/System.map$_pkgext"
362 install -Dm644 arch/$_karch/boot/bzImage "$pkgdir/boot/vmlinuz$_pkgext"
365 ##########################
366 # Install kernel modules
367 ##########################
368 msg "Installing kernel modules..."
369 # force -j1 to work around make 3.82 bug
370 make -j1 INSTALL_MOD_PATH="$pkgdir" modules_install
371 [[ -z $_no_modules_compression ]] && find "$pkgdir" -name "*.ko" -exec gzip -9 {} +
374 ##################################
375 # Create important symlinks
376 ##################################
377 msg "Creating important symlinks..."
379 # Create generic modules symlink
380 if [[ $_kernver != ${_basekernel}${_pkgext} ]]; then
381 cd "$pkgdir/lib/modules"
382 ln -s "$_kernver" "${_basekernel}${_pkgext}"
386 # remove header symlinks
387 cd "$pkgdir/lib/modules/$_kernver"
392 ############################
393 # Install mkinitcpio files
394 ############################
395 install -d "$pkgdir/etc/mkinitcpio.d"
397 msg "Generating $pkgname.preset..."
398 cat > "$pkgdir/etc/mkinitcpio.d/$pkgname.preset" <<EOF
399 # mkinitcpio preset file for $pkgname
401 ########################################
402 # DO NEVER EDIT THIS LINE:
403 source /etc/mkinitcpio.d/$pkgname.kver
404 ########################################
408 default_config="/etc/mkinitcpio.conf"
409 default_image="/boot/$pkgname.img"
412 msg "Generating $pkgname.kver..."
413 echo -e "# DO NOT EDIT THIS FILE\nALL_kver='$_kernver'" \
414 > "$pkgdir/etc/mkinitcpio.d/$pkgname.kver"
417 #######################
418 # Update install file
419 #######################
420 msg "Updating install file..."
421 sed -ri "s/^(pkgname=).*$/\1$pkgname/" "$startdir/$pkgname.install"
422 sed -ri "s/^(kernver=).*$/\1$_kernver/" "$startdir/$pkgname.install"
425 #######################
426 # Remove the firmware
427 #######################
428 rm -rf "$pkgdir/lib/firmware"
433 _generic_package_linux-headers() {
434 pkgdesc="Header files and scripts for building modules for $pkgbase"
437 # set required variables
438 _generic_package_initialization
440 #############################################################
441 # Provide linux-headers (and kernel3 for backwards compatibility)
442 # (probably someone wants to use this kernel exclusively?)
443 #############################################################
444 provides=("${provides[@]}" {linux,kernel3}"-headers=${_kernver//-/_}")
447 ##############################
448 # Install fake kernel source
449 ##############################
450 install -Dm644 Module.symvers "$pkgdir/usr/src/linux-$_kernver/Module.symvers"
451 install -Dm644 Makefile "$pkgdir/usr/src/linux-$_kernver/Makefile"
452 install -Dm644 kernel/Makefile "$pkgdir/usr/src/linux-$_kernver/kernel/Makefile"
453 install -Dm644 .config "$pkgdir/usr/src/linux-$_kernver/.config"
454 install -Dm644 .config "$pkgdir/lib/modules/$_kernver/.config"
457 #######################################################
458 # Install scripts directory and fix permissions on it
459 #######################################################
460 cp -a scripts "$pkgdir/usr/src/linux-$_kernver"
463 ##########################
464 # Install header files
465 ##########################
466 msg "Installing header files..."
468 for i in net/ipv4/netfilter/ipt_CLUSTERIP.c \
469 $(find include/ net/mac80211/ drivers/{md,media/video/} -iname "*.h") \
470 $(find include/config/ -type f) \
471 $(find . -name "Kconfig*")
473 mkdir -p "$pkgdir/usr/src/linux-$_kernver/${i%/*}"
474 cp -af "$i" "$pkgdir/usr/src/linux-$_kernver/$i"
477 # required by virtualbox and probably others
478 ln -s "../generated/autoconf.h" "$pkgdir/usr/src/linux-$_kernver/include/linux/"
481 ########################################
482 # Install architecture dependent files
483 ########################################
484 msg "Installing architecture files..."
485 mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel"
486 cp -a arch/$_karch/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel/"
488 cp -a arch/$_karch/Makefile* "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
489 cp -a arch/$_karch/configs "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
491 # copy arch includes for external modules and fix the nVidia issue
492 mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch"
493 cp -a "arch/$_karch/include" "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
495 # create a necessary symlink to the arch folder
496 cd "$pkgdir/usr/src/linux-$_kernver/arch"
498 if [[ $CARCH = "x86_64" ]]; then
507 ################################
508 # Remove unneeded architecures
509 ################################
510 msg "Removing unneeded architectures..."
511 for i in "$pkgdir/usr/src/linux-$_kernver/arch/"*; do
512 [[ ${i##*/} =~ ($_karch|Kconfig) ]] || rm -rf "$i"
516 ############################
517 # Remove .gitignore files
518 ############################
519 msg "Removing .gitignore files from kernel source..."
520 find "$pkgdir/usr/src/linux-$_kernver/" -name ".gitignore" -delete
523 ##################################
524 # Create important symlinks
525 ##################################
526 msg "Creating important symlinks..."
528 # the build symlink needs to be relative
529 cd "$pkgdir/lib/modules/$_kernver"
531 ln -s "/usr/src/linux-$_kernver" build
534 if [[ $_kernver != ${_basekernel}${_pkgext} ]]; then
536 ln -s "linux-$_kernver" "linux-${_basekernel}${_pkgext}"
541 _generic_package_linux-docs() {
542 pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel."
545 # set required variables
546 _generic_package_initialization
548 mkdir -p "$pkgdir/usr/src/linux-$_kernver"
549 cp -a Documentation "$pkgdir/usr/src/linux-$_kernver/"
552 # vim: set fenc=utf-8 ts=2 sw=2 noet: