1 # Maintainer: andrewthomas
3 # Originally-uploaded-by: Mathias Burén <mathias.buren@gmail.com>
5 pkgname=kernel26$_pkgext
8 # comment the following line to build a single package containing the kernel and the headers
9 (( 1 )) && pkgname=("kernel26${_pkgext}" "kernel26${_pkgext}-headers" "kernel26${_pkgext}-docs")
10 pkgdesc="The 2.6.39 Ubuntu Kernel and modules including Ubuntu Supplied Third-Party Device Drivers (NDISWRAPPER, RTL8192SE, ureadahead & more)"
14 url="http://kernel.ubuntu.com/git-repos/ubuntu/ubuntu-oneiric.git/"
17 depends=('coreutils' 'linux-firmware-git' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.6.8-2')
18 makedepends=('git' 'xmlto' 'docbook-xsl')
19 backup=(etc/mkinitcpio.d/$pkgname.preset)
20 install=$pkgname.install
21 changelog=$pkgname.changelog
22 source=(config.{i686,x86_64})
23 md5sums=('5a6e6217a168beb0368e7ff2a871dd03'
24 'fc098c6e7095116860ceb817713b465e')
25 sha256sums=('aca858bd894883c9196dd188174bdf983978226c33db7cb29fcb38c13d593644'
26 '92a58b7c2a83028d0c93cde23947bac32bef98ef6f90f46cfac144ed7cb872f8')
27 _gitroot="git://kernel.ubuntu.com/ubuntu/ubuntu-oneiric.git"
28 _gitname="ubuntu-oneiric"
31 ####################################################################
34 # This PKGBUILD searches for config files in the current directory
35 # and will use the first one it finds from the following
36 # list as base configuration:
41 ####################################################################
44 #############################################################
47 # This package builds the vanilla git kernel by default,
48 # but it is possible to patch the source without modifying
51 # Simply create a directory 'patches' in your PKGBUILD
52 # directory and _any_ file (dotfiles excluded) in this
53 # folder will be applied to the kernel source.
55 # Prefixing the patch file names with dots will obviously
56 # excluded them from the patching process.
58 #############################################################
61 #############################
64 # Uncomment desired options
65 #############################
69 # Set to e.g. menuconfig, xconfig or gconfig
71 # For a full list of supported commands, please have a look
72 # at "Configuration targets" section of `make help`'s output
73 # 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 )
75 # If unset or set to an empty or space-only string, the
76 # (manual) kernel configuration step will be skipped.
78 _config_cmd="${_config_cmd:-menuconfig}"
82 # The directory where the kernel should be built
84 # Can be useful, for example, if you want to compile on a
85 # tmpfs mount, which can speed up the compilation process
87 _build_dir="${_build_dir:-$srcdir}"
91 # Stop build process after kernel configuration
93 # This option enables _save_config implicitly.
99 # Append the date to the localversion
101 # e.g. -ARCH -> -ARCH-20090422
103 # _date_localversion=1
107 # Set the pkgver to the kernel version
108 # rather than the build date
114 # Save the .config file to package directory
115 # as config.saved.$CARCH
121 # Do not compress kernel modules
123 # _no_modules_compression=1
127 # Make the kernel build process verbose
132 if [[ -n $_gitname && -n $_gitroot ]]; then
133 (( 1 )) && _kernel_src="$_build_dir/$_gitname-build"
135 (( 1 )) && _kernel_src="$_build_dir/$(find . -maxdepth 1 -type d -name "linux-*" -printf "%f\n" | head -1)"
139 # define required functions
143 eval package_kernel26${_pkgext}-headers
144 eval package_kernel26${_pkgext}
147 # split package functions
148 eval "package_kernel26${_pkgext}() { _generic_package_kernel; }"
149 eval "package_kernel26${_pkgext}-headers() { _generic_package_kernel-headers; }"
150 eval "package_kernel26${_pkgext}-docs() { _generic_package_kernel-docs; }"
153 ##############################
154 # where the magic happens...
155 ##############################
158 #################################
159 # Get the latest kernel sources
160 #################################
161 msg "Fetching sources..."
164 if [[ -d $_gitname ]]; then
165 msg2 "Updating sources..."
170 msg2 "Cloning the project..."
171 warning "The initial clone will download approximately 375 mb"
172 git clone --mirror "$_gitroot" "$_gitname"
175 msg "Creating build branch..."
176 rm -rf "$_kernel_src"
177 git clone "$_gitname" "$_kernel_src"
185 if [[ -d $startdir/patches && -n $(echo "$startdir/patches/"*) ]]; then
186 msg "Applying patches..."
188 for i in "$startdir/patches/"*; do
189 msg2 "Applying ${i##*/}..."
190 patch -Np1 -i "$i" || (error "Applying ${i##*/} failed" && return 1)
200 #########################
201 # Loading configuration
202 #########################
203 msg "Loading configuration..."
204 for i in local "saved.$CARCH" "$CARCH"; do
205 if [[ -e $startdir/config.$i ]]; then
206 msg2 "Using kernel config file config.$i..."
207 cp -f "$startdir/config.$i" .config
212 [[ ! -e .config ]] &&
213 warning "No suitable kernel config file was found. You'll have to configure the kernel from scratch."
216 ###########################
217 # Start the configuration
218 ###########################
219 msg "Updating configuration..."
220 yes "" | make config > /dev/null
223 sed -ri "s@s(bin/lsmod)@\1@" scripts/kconfig/streamline_config.pl
225 if [[ -n ${_config_cmd// /} ]]; then
226 msg2 "Running make $_config_cmd..."
229 warning "Unknown config command: $_config_cmd"
233 ##############################################
234 # Save the config file the package directory
235 ##############################################
236 if [[ -n $_save_config || -n $_configure_only ]]; then
237 msg "Saving configuration..."
238 msg2 "Saving $_kernel_src/.config as $startdir/config.saved.$CARCH"
239 cp .config "$startdir/config.saved.$CARCH"
243 #######################################
244 # Stop after configuration if desired
245 #######################################
246 if [[ -n $_configure_only ]]; then
247 rm -rf "$_kernel_src" "$srcdir" "$pkgdir"
252 ###############################
253 # Append date to localversion
254 ###############################
255 if [[ -n $_date_localversion ]]; then
256 local _localversion="$(sed -rn 's/^CONFIG_LOCALVERSION="([^"]*)"$/\1/p' .config)"
257 [[ -n $_localversion ]] && msg2 "CONFIG_LOCALVERSION is set to: $_localversion"
259 # since this is a git package, the $pkgver is equal to $(date +%Y%m%d)
260 msg2 "Appending $pkgver to CONFIG_LOCALVERSION..."
261 sed -ri "s/^(CONFIG_LOCALVERSION=).*$/\1\"$_localversion-$pkgver\"/" .config
269 ################################
270 # Build the kernel and modules
271 ################################
272 msg "Building kernel and modules..."
273 make $MAKEFLAGS V="$_verbose" bzImage modules
280 ###################################
281 # Copy files from build directory
282 ####################################
283 if (( ! CLEANUP )) && [[ $_build_dir != $srcdir ]]; then
284 msg "Saving $_kernel_src to $srcdir/${_kernel_src##*/}..."
285 mv "$_kernel_src" "$srcdir"
286 rm -rf "$_kernel_src"
291 _generic_package_initialization() {
296 ######################
298 ######################
299 _kernver=$(make kernelrelease)
300 _basekernel=${_kernver%%-*}
303 ############################################################
304 # Use kernel version instead of the current date as pkgver
305 ############################################################
306 if [[ -n $_kernel_pkgver ]]; then
307 pkgver=${_kernver//-/_}
308 msg "Setting pkgver to kernel version: $pkgver"
312 _generic_package_kernel() {
313 pkgdesc="The Ubuntu Kernel and modules from oneiric git tree"
314 depends=('coreutils' 'linux-firmware-git' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.6.8-2')
315 backup=(etc/mkinitcpio.d/$pkgname.preset)
316 install=$pkgname.install
317 changelog=$pkgname.changelog
319 # set required variables
320 _generic_package_initialization
323 #############################################################
325 # (probably someone wants to use this kernel exclusively?)
326 #############################################################
327 provides=("${provides[@]}" "kernel26=${_kernver//-/_}")
334 #####################
336 #####################
337 msg "Installing kernel image..."
338 install -Dm644 System.map "$pkgdir/boot/System.map26$_pkgext"
339 install -Dm644 arch/$_karch/boot/bzImage "$pkgdir/boot/vmlinuz26$_pkgext"
342 ##########################
343 # Install kernel modules
344 ##########################
345 msg "Installing kernel modules..."
346 make INSTALL_MOD_PATH="$pkgdir" modules_install
347 [[ -z $_no_modules_compression ]] && find "$pkgdir" -name "*.ko" -exec gzip -9 {} +
350 ##################################
351 # Create important symlinks
352 ##################################
353 msg "Creating important symlinks..."
355 # Create generic modules symlink
356 if [[ $_kernver != ${_basekernel}${_pkgext} ]]; then
357 cd "$pkgdir/lib/modules"
358 ln -s "$_kernver" "${_basekernel}${_pkgext}"
362 # remove header symlinks
363 cd "$pkgdir/lib/modules/$_kernver"
368 ############################
369 # Install mkinitcpio files
370 ############################
371 install -d "$pkgdir/etc/mkinitcpio.d"
373 msg "Generating $pkgname.preset..."
374 cat > "$pkgdir/etc/mkinitcpio.d/$pkgname.preset" <<EOF
375 # mkinitcpio preset file for $pkgname
377 ########################################
378 # DO NEVER EDIT THIS LINE:
379 source /etc/mkinitcpio.d/$pkgname.kver
380 ########################################
384 default_config="/etc/mkinitcpio.conf"
385 default_image="/boot/$pkgname.img"
388 msg "Generating $pkgname.kver..."
389 echo -e "# DO NOT EDIT THIS FILE\nALL_kver='$_kernver'" \
390 > "$pkgdir/etc/mkinitcpio.d/$pkgname.kver"
393 #######################
394 # Update install file
395 #######################
396 msg "Updating install file..."
397 sed -ri "s/^(pkgname=).*$/\1$pkgname/" "$startdir/$pkgname.install"
398 sed -ri "s/^(kernver=).*$/\1$_kernver/" "$startdir/$pkgname.install"
401 #######################
402 # Remove the firmware
403 #######################
404 rm -rf "$pkgdir/lib/firmware"
409 _generic_package_kernel-headers() {
410 pkgdesc="Header files and scripts for building modules for ${pkgname[0]}"
411 depends=("${pkgname[0]}")
413 # set required variables
414 _generic_package_initialization
416 #############################################################
418 # (probably someone wants to use this kernel exclusively?)
419 #############################################################
420 provides=("${provides[@]}" "kernel26-headers=${_kernver//-/_}")
423 ##############################
424 # Install fake kernel source
425 ##############################
426 install -Dm644 Module.symvers "$pkgdir/usr/src/linux-$_kernver/Module.symvers"
427 install -Dm644 Makefile "$pkgdir/usr/src/linux-$_kernver/Makefile"
428 install -Dm644 kernel/Makefile "$pkgdir/usr/src/linux-$_kernver/kernel/Makefile"
429 install -Dm644 .config "$pkgdir/usr/src/linux-$_kernver/.config"
430 install -Dm644 .config "$pkgdir/lib/modules/$_kernver/.config"
433 #######################################################
434 # Install scripts directory and fix permissions on it
435 #######################################################
436 cp -a scripts "$pkgdir/usr/src/linux-$_kernver"
439 ##########################
440 # Install header files
441 ##########################
442 msg "Installing header files..."
444 for i in net/ipv4/netfilter/ipt_CLUSTERIP.c \
445 $(find include/ net/mac80211/ drivers/{md,media/video/} -iname "*.h") \
446 $(find include/config/ -type f) \
447 $(find . -name "Kconfig*")
449 mkdir -p "$pkgdir/usr/src/linux-$_kernver/${i%/*}"
450 cp -af "$i" "$pkgdir/usr/src/linux-$_kernver/$i"
453 # required by virtualbox and probably others
454 ln -s "../generated/autoconf.h" "$pkgdir/usr/src/linux-$_kernver/include/linux/"
457 ########################################
458 # Install architecture dependent files
459 ########################################
460 msg "Installing architecture files..."
461 mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel"
462 cp -a arch/$_karch/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel/"
464 cp -a arch/$_karch/Makefile* "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
465 cp -a arch/$_karch/configs "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
467 # copy arch includes for external modules and fix the nVidia issue
468 mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch"
469 cp -a "arch/$_karch/include" "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
471 # create a necessary symlink to the arch folder
472 cd "$pkgdir/usr/src/linux-$_kernver/arch"
474 if [[ $CARCH = "x86_64" ]]; then
483 ################################
484 # Remove unneeded architecures
485 ################################
486 msg "Removing unneeded architectures..."
487 for i in "$pkgdir/usr/src/linux-$_kernver/arch/"*; do
488 [[ ${i##*/} =~ ($_karch|Kconfig) ]] || rm -rf "$i"
492 ############################
493 # Remove .gitignore files
494 ############################
495 msg "Removing .gitignore files from kernel source..."
496 find "$pkgdir/usr/src/linux-$_kernver/" -name ".gitignore" -delete
499 ##################################
500 # Create important symlinks
501 ##################################
502 msg "Creating important symlinks..."
504 # the build symlink needs to be relative
505 cd "$pkgdir/lib/modules/$_kernver"
507 ln -s "/usr/src/linux-$_kernver" build
510 if [[ $_kernver != ${_basekernel}${_pkgext} ]]; then
512 ln -s "linux-$_kernver" "linux-${_basekernel}${_pkgext}"
517 _generic_package_kernel-docs() {
518 pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel."
519 depends=("${pkgname[0]}")
521 # set required variables
522 _generic_package_initialization
524 mkdir -p "$pkgdir/usr/src/linux-$_kernver"
525 cp -a Documentation "$pkgdir/usr/src/linux-$_kernver/"
528 # vim: set fenc=utf-8 ts=2 sw=2 noet: