# Maintainer: xduugu _pkgext=-git pkgbase=linux$_pkgext pkgname=$pkgbase # required by AUR # comment the following line to build a single package containing the kernel and the headers (( 1 )) && pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs") pkgdesc="The Linux Kernel and modules from Linus' git tree" depends=('coreutils' 'linux-firmware-git' 'mkinitcpio') pkgver=20121225 pkgrel=1 url="http://www.kernel.org/" arch=(i686 x86_64) license=('GPL2') makedepends=('git') options=(!strip) source=(config.{i686,x86_64}) md5sums=('1b7c79c377c52314489c62edfb18287f' 'ab11879c6b02054615ca3ea84a79b7c4') sha256sums=('ddcb6aa5811533adbb82f0bed7092bc4df04984952522d2ac0da6c2509414733' '8a879350dfc29b716c16677cbb9500d367cc216ac2a6be391bf7f317942729c6') _gitroot="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" _gitname="linux.git" # set _gitrev to a git revision (man gitrevisions) like a tag, a commit sha1 # hash or a branch name to build from this tree instead of master # _gitrev="" #################################################################### # KERNEL CONFIG FILES # # This PKGBUILD searches for config files in the current directory # and will use the first one it finds from the following # list as base configuration: # config.local # config.saved.$CARCH # config.$CARCH # #################################################################### ############################################################# # PATCHES # # This package builds the vanilla git kernel by default, # but it is possible to patch the source without modifying # this PKGBUILD. # # Simply create a directory 'patches' in your PKGBUILD # directory and _any_ file (dotfiles excluded) in this # folder will be applied to the kernel source. # # Prefixing the patch file names with dots will obviously # excluded them from the patching process. # ############################################################# ############################# # CONFIGURATION # # Uncomment desired options ############################# ####### # Set to e.g. menuconfig, xconfig or gconfig # # For a full list of supported commands, please have a look # at "Configuration targets" section of `make help`'s output # or the help target in scripts/kconfig/Makefile # http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=scripts/kconfig/Makefile # # If unset or set to an empty or space-only string, the # (manual) kernel configuration step will be skipped. # _config_cmd="${_config_cmd:-xconfig}" ####### # The directory where the kernel should be built # # Can be useful, for example, if you want to compile on a # tmpfs mount, which can speed up the compilation process # _build_dir="${_build_dir:-$srcdir}" ####### # Stop build process after kernel configuration # # This option enables _save_config implicitly. # # _configure_only=1 ####### # Append the date to the localversion # # e.g. -ARCH -> -ARCH-20090422 # # _date_localversion=1 ####### # Set the pkgver to the kernel version # rather than the build date # # _kernel_pkgver=1 ####### # Save the .config file to package directory # as config.saved.$CARCH # # _save_config=1 ####### # Do not compress kernel modules # # _no_modules_compression=1 ####### # Make the kernel build process verbose # # _verbose=1 # internal variables if [[ -n $_gitname && -n $_gitroot ]]; then (( 1 )) && _kernel_src="$_build_dir/$_gitname-build" else (( 1 )) && _kernel_src="$_build_dir/$(find . -maxdepth 1 -type d -name "linux-*" -printf "%f\n" | head -1)" fi ####### # define required functions # single package package() { eval package_$pkgbase-headers eval package_$pkgbase } # split package functions eval "package_$pkgbase() { _generic_package_linux; }" eval "package_$pkgbase-headers() { _generic_package_linux-headers; }" eval "package_$pkgbase-docs() { _generic_package_linux-docs; }" ############################## # where the magic happens... ############################## build() { if [[ -n $_gitname && -n $_gitroot ]]; then ################################# # Get the latest kernel sources ################################# msg "Fetching sources..." cd "$startdir" if [[ -d $_gitname ]]; then msg2 "Updating sources..." cd "$_gitname" git fetch || true cd "$OLDPWD" else msg2 "Cloning the project..." warning "The initial clone will download approximately 500 mb" git clone --mirror "$_gitroot" "$_gitname" fi msg "Creating build branch..." rm -rf "$_kernel_src" git clone "$_gitname" "$_kernel_src" # reset to specified git revision cd "$_kernel_src" [[ -n $_gitrev ]] && git reset --hard "$_gitrev" fi cd "$_kernel_src" ################# # Apply patches ################# msg "Applying patches..." local i patches for i in "${source[@]}"; do i=${i##*/} [[ $i =~ .*\.patch$ ]] && patches=("${patches[@]}" "$srcdir/$i") [[ ${i%.*} =~ .*\.patch$ ]] && patches=("${patches[@]}" "$srcdir/${i%.*}") done shopt -s nullglob for i in "${patches[@]}" "$startdir/patches/"*; do msg2 "Applying ${i##*/}..." patch -Np1 -i "$i" || (error "Applying ${i##*/} failed" && return 1) done shopt -u nullglob ################# # CONFIGURATION ################# ######################### # Loading configuration ######################### msg "Loading configuration..." for i in local "saved.$CARCH" "$CARCH"; do if [[ -e $startdir/config.$i ]]; then msg2 "Using kernel config file config.$i..." cp -f "$startdir/config.$i" .config break fi done [[ ! -e .config ]] && warning "No suitable kernel config file was found. You'll have to configure the kernel from scratch." ########################### # Start the configuration ########################### msg "Updating configuration..." yes "" | make config > /dev/null if [[ -n ${_config_cmd// /} ]]; then msg2 "Running make $_config_cmd..." zcat /proc/config.gz > /home/steve/Desktop/config make $_config_cmd else warning "Unknown config command: $_config_cmd" fi ############################################## # Save the config file the package directory ############################################## if [[ -n $_save_config || -n $_configure_only ]]; then msg "Saving configuration..." msg2 "Saving $_kernel_src/.config as $startdir/config.saved.$CARCH" cp .config "$startdir/config.saved.$CARCH" fi ####################################### # Stop after configuration if desired ####################################### if [[ -n $_configure_only ]]; then rm -rf "$_kernel_src" "$srcdir" "$pkgdir" return 1 fi if [[ -f /home/steve/Desktop/config ]]; then rm /home/steve/Desktop/config fi ############################### # Append date to localversion ############################### if [[ -n $_date_localversion ]]; then local _localversion="$(sed -rn 's/^CONFIG_LOCALVERSION="([^"]*)"$/\1/p' .config)" [[ -n $_localversion ]] && msg2 "CONFIG_LOCALVERSION is set to: $_localversion" # since this is a git package, the $pkgver is equal to $(date +%Y%m%d) msg2 "Appending $pkgver to CONFIG_LOCALVERSION..." sed -ri "s/^(CONFIG_LOCALVERSION=).*$/\1\"$_localversion-$pkgver\"/" .config fi #################################### # Append pkgrel to kernel version #################################### [[ -z $_gitname || -z $_gitroot ]] && sed -ri "s/^(EXTRAVERSION =).*$/\1 -$pkgrel/" Makefile #################################### # don't run depmod on 'make install' #################################### sed -i '2iexit 0' scripts/depmod.sh git update-index --assume-unchanged scripts/depmod.sh ################# # BUILD PROCESS ################# ################################ # Build the kernel and modules ################################ msg "Building kernel and modules..." make $MAKEFLAGS V="$_verbose" bzImage modules ################################### # Copy files from build directory #################################### if [[ $_build_dir != $srcdir ]]; then msg "Saving $_kernel_src to $srcdir/${_kernel_src##*/}..." mv "$_kernel_src" "$srcdir" rm -rf "$_kernel_src" fi } _generic_package_initialization() { cd "$srcdir/${_kernel_src##*/}" _karch="x86" ###################### # Get kernel version ###################### _kernver=$(make kernelrelease) _basekernver=${_kernver%%-*} ############################################################ # Use kernel version instead of the current date as pkgver ############################################################ if [[ -n $_kernel_pkgver ]]; then pkgver=${_kernver//-/_} msg "Setting pkgver to kernel version: $pkgver" fi } _generic_package_linux() { pkgdesc="The Linux Kernel and modules from Linus' git tree" backup=(etc/mkinitcpio.d/$pkgname.preset) install=$pkgname.install changelog=$pkgname.changelog # set required variables _generic_package_initialization ############################################################# # Provide linux # (probably someone wants to use this kernel exclusively?) ############################################################# provides=("${provides[@]}" "linux=${_kernver//-/_}") ################ # INSTALLATION ################ ##################### # Install the image ##################### msg "Installing kernel image..." install -Dm644 arch/$_karch/boot/bzImage "$pkgdir/boot/vmlinuz-$pkgname" ########################## # Install kernel modules ########################## msg "Installing kernel modules..." # force -j1 to work around make 3.82 bug make -j1 INSTALL_MOD_PATH="$pkgdir/usr" modules_install [[ -z $_no_modules_compression ]] && find "$pkgdir" -name "*.ko" -exec gzip -9 {} + ######################################################### # Set up extramodules directory (for external modules) ######################################################### local extramodules="$pkgdir/usr/lib/modules/extramodules-$(cut -d. -f1,2 <<<$_basekernver)" local modversion=$(grep '^CONFIG_LOCALVERSION=' .config | cut -d'"' -f2) [[ -n $modversion ]] && extramodules+=$modversion install -dm755 "${extramodules}${_pkgext}" echo $_kernver > "${extramodules}${_pkgext}/version" ln -s "../${extramodules##*/}${_pkgext}" "$pkgdir/usr/lib/modules/$_kernver/extramodules" ################################## # Create important symlinks ################################## msg "Creating important symlinks..." # Create generic modules symlink if [[ $_kernver != ${_basekernver}${_pkgext} ]]; then cd "$pkgdir/usr/lib/modules" ln -s "$_kernver" "${_basekernver}${_pkgext}" cd "$OLDPWD" fi # remove header symlinks cd "$pkgdir/usr/lib/modules/$_kernver" rm -rf source build cd "$OLDPWD" ############################ # Install mkinitcpio files ############################ install -d "$pkgdir/etc/mkinitcpio.d" msg "Generating $pkgname.preset..." cat > "$pkgdir/etc/mkinitcpio.d/$pkgname.preset" <