User talk:Falconindy

From ArchWiki
Revision as of 19:30, 21 February 2010 by Falconindy (Talk | contribs) (Created page with 'Category:Kernel (English) Category:HOWTOs (English) {{i18n|Custom Kernel Compilation with ABS}} === Introduction === There are many ways to build the kernel in Arch; th…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Introduction

There are many ways to build the kernel in Arch; this is just one example. For other possibilities, see Kernel Compilation. Some Arch users prefer the traditional way, however using ABS is helpful for automating certain tasks. As with anything in Arch, the choice is yours! Neither way is inherently better than the other.

This how-to has been updated to provide a definitive PKGBUILD for the creation of custom kernel packages. It allows you to maintain multiple custom kernels with a unique naming scheme under pacman version control. It is ideal for almost any custom kernel build and can be easily adapted to fit many requirements. The PKGBUILD automatically accounts for the modified pkgname and appends your custom suffix to the the kernel's .config.

This how-to also assumes that you are compiling a recent kernel (a 2.6 series kernel released in the past 2-3 years).

Note that this is not an ABS howto - to successfully follow this how-to, a working knowledge of building packages with ABS is essential. Please read Arch Build System, Creating Packages and Patching in ABS.

Philosophy and Logic (how it works and why it works this way)

  • The Arch Way - Keep It Simple.
  • This PKGBUILD is based on the official method used by Arch devs.
  • This build provides kernel packages and components with a simple, logical and uncomplicated naming scheme that ONLY uses variables that are part of the ABS system and part of the kernel compilation process itself. If you want to prefix your kernel with your name, or reference to a patch involved, simply name the package as such, (e.g. kernel26-ckzero) and your kernel will be named similarly.
  • If you are familiar with ABS you will see that the PKGBUILD is transparently constructed, self-explanatory and can be customized easily.
  • User input is almost identical to all ABS builds: simply set pkgver, pkgrel and pkgdesc and add additional sources, including patches, to the source array. Patch users should insert the appropriate patch commands where indicated. Aside from uncommenting the config method and choosing whether to make clean or not the rest of the build is automated.
Note: For the duration of this article, -ckzero is the custom suffix. Anywhere you see this, you can (read: must) safely replace this with your own suffix.

Usage Notes

  • pkgname must be declared within 10 lines of the top of the PKGBUILD - so DO NOT move it - just leave it.

If you miss this simple instruction don't worry, it won't screw up your build but your PKGBUILD file will not have the pkgname automatically updated at the end of the build. This is to allow you to use gensync correctly BUT you can edit the PKGBUILD file manually afterwards of course.

  • Until you have your own config that you are happy with it is easiest just to start with the default Arch config; you should also get the Arch kernel26.install file, make your own kernel26.install script or comment out the line install=kernel26.install from the PKGBUILD. The official Arch files are both in your ABS tree, normally under /var/abs/core/kernel26. To download the ABS tree to your system simply run abs as root. It doesn't take long, even on dialup. You should keep this updated by running abs as root on a regular basis.
NOTE: If you use LILO or any other static bootloader (that is, one that requires update after every kernel change) you are advised to use an install file too. This is an example, kernel26.install, for use with Lilo:


  • If used correctly this PKGBUILD should always provide a unique kernel build based on EXTRAVERSION and LOCALVERSION, and on the pkgver and pkgrel (as normal) - however it is up to the user to double check resulting pkgnames and contents before installation to prevent overwrites (see below for more details and examples).

Anatomy of the PKGBUILD

This PKGBUILD is based on the split package that was introduced with the 2.6.32 kernel series. This gives you the flexibility of only installing what you want out of your custom kernel (e.g. you may not need the headers). This does, however, mean a little extra responsibility on the user's part to ensure that we build and package cleanly.

Check out the core/kernel26 port from ABS, and use the modified PKGBUILD below. Before building remember the following:

  1. pkgbase should be changed to be unique. This is what the kernel will be named.
  2. Elements in the pkgname array need to be updated as well, and should match the pkgbase provided above. This is what the built packages will be named.
  3. Insert the pkgver for your kernel (for example: 2.6.9).
  4. Change the pkgrel for your current revision. You should increment this each time you make changes to the kernel config and want to build a REPLACEMENT pkg. If you don't want to replace the previous build but rather install in parallel you should use LOCALVERSION to create a unique pkg.
  5. Change/expand the pkgdesc to describe any patches or special config options applied.
  6. Change the source to use a closer mirror and if you are using a patchset, add the patches to the source array.
  7. {OPTIONAL} Place the patch commands where indicated.
  8. Choose a make method by leaving your preferred method uncommented - gconfig (gtk based) xconfig (qt based) menuconfig (ncurses based).
Warning: This PKGBUILD makes some modifications from the one available directly from ABS. It will not build the firmware package as it assumes you will keep the vanilla ARCH kernel installed.

Template:File

  • Install your new pkg as normal.

Your .config file

PLEASE NOTE: during the build the final kernel config is stored in your $startdir as, for example, config-Apr13-12h. Your original config remains in the $startdir named config. If you wish to use the new config in another build make sure you copy the correct file!

Common .config Changes

  • The default Arch kernel is built for a generic i686 or x86_64 processor. You can compile for your specific architecture. On a 64-bit build, you'll see the following:

Template:Kernel


  • Preemptable RCU. This produces some mild improvement in desktop response for multi-core and/or multi-threading systems.

Template:Kernel


I Want the Arch logo!

Note: If you use the -ARCH patchset mentioned in the provided PKGBUILD, this is already included. If you opt not to use the patchset, you can still get the logo by doing the following

Download the logo_linux_clut224.ppm to your $startdir from: projects.archlinux.org/linux-2.6-ARCH.git/tree/patches

Add the the file logo_linux_clut224.ppm to the source array, and add the copy command marked with (>>) below into the PKGBUILD as indicated:

   ##### Uncomment and apply any patches here
   #patch -Np1 -i ../patchname || return 1

>>  ##### Arch logo - not compatible with gensplash!
>>  cp ../logo_linux_clut224.ppm drivers/video/logo/

   # get rid of the 'i' in i686
   carch=`echo $CARCH | sed 's|i||'`
   cat ../config | sed "s|#CARCH#|$carch|g" >./.config

The stock Arch config uses the following logo settings, ensure you set them at the config stage or use the stock config:

#
# Logo configuration
#
CONFIG_LOGO=y
CONFIG_LOGO_LINUX_MONO=y
CONFIG_LOGO_LINUX_VGA16=y
CONFIG_LOGO_LINUX_CLUT224=y

Install Scriptlet

Chances are high that you'll want to use a .install scriptlet to automate the creation and installation of boot images. Don't forget to replace the two declarations at the top of the file to match your suffix. Below is an example of a slimmed down script for handling a kernel that uses a boot image.

Template:File

Tip: If your config doesn't use a boot image, the only thing this script needs to do is run depmod $KERNELNAME.

Post Installation

Once you have your kernel installed, don't forget to add a new entry to your bootloader to load the new kernel. See Wiki pages about GRUB, GRUB2, or Lilo for more info on how to create these entries.

Problems

My kernel's version has a hash sum and/or 'dirty' appended to it!
  • Make sure that you're not building within the confines of a Git, SVN, or Mercurial repository. During the compilation process, the kernel will check for the presence of a repository, whether for the kernel or not, and append to the LOCALVERSION.

Using the nVIDIA video driver with your custom kernel

To use the nvidia driver with your new custom kernel, see: How to install NVIDIA driver with custom kernel

Original article written by DibbleTheWrecker. Updated by Falconindy.