2 kernel PKGBUILDs in wiki?

Hi all
I'm thinking of trying my first custom kernel (I'm after the hdaps_protect patch), so went to the wiki, and found these:
http://wiki.archlinux.org/index.php/Ker … n_with_ABS
http://wiki.archlinux.org/index.php/Cus … n_with_ABS
Both pages give a PKGBUILD but I'm not sure which one is better, indeed both pages seem to be written as though the other doesn't exist.
So, is there one page that supersedes the other, or are the two PKGBUILDs designed for different tasks? And in that case what's the difference?
Jack

Here the one I linked to you
#DO NOT CHANGE INSIDE THIS BLOCK
pkgver=$_kerver
if [ ! -z "$_extraver" ]; then
_scratch="_$_extraver"
pkgver=$pkgver$_scratch
_extraver=`echo "-$_extraver" | sed 's|_|-|'`
fi
pkgdesc="$_desc - ver: $_kerver$_extraver;"
pkgname=$_pkg_base
if [ ! -z "$_patchset" ]; then
pkgdesc="$pkgdesc pset: $_patchset;"
_patchset="-$_patchset"
pkgname="$pkgname$_patchset"
fi
if [ ! -z "$_cfgname" ]; then
pkgdesc="$pkgdesc cfg: $_cfgname;"
_cfgname="-$_cfgname"
pkgname="$pkgname$_cfgname"
fi
pkgdesc="$pkgdesc bld: $pkgrel"
_idstr="$_kerver$_extraver$_patchset$_cfgname"
Then after md5 check you get build() {
Where as with the other one it enters build almost straight away, but as said I'm far from sure.
build() {
echo "_pkg_base: $_pkg_base"
echo "_patchset: $_patchset"
echo "_cfgname: $_cfgname"
echo "_kerver: $_kerver"
echo "_extraver: $_extraver"
echo "pkgrel: $

Similar Messages

  • Kernel PKGBUILD naming

    Hi archers!
    I finally managed building a working kernel config and building the kernel with this PKGBUILD and it works fine so far.
    The only thing that disturbs me, is that the custom kernel's "name" (uname -r) and the /lib/modules dir are named "kernel26-custom-custom-custom" (note the three "-custom"s).
    In the PKGBUILD I only set "_pkg_base" to "kernel26" and "_cfgname" to "custom".
    During kernel configuration, I set "LOCALVERSION" to "-custom" as well.
    /boot files and everything is named just fine, but as I said, the kernel name is always screwed up with the triple "-custom".
    I'm not really good in bash but I think it's caused by these lines in the PKBGUILD:
    # set EXTRAVERSION to help use unique /lib/modules/ subdirectories
    _ker_make_ver=$(getvar "VERSION").$(getvar "PATCHLEVEL").$(getvar "SUBLEVEL")
    _ker_extraver=`echo $_idstr | sed "s|^$_ker_make_ver||"`
    # update EXTRAVERSION in the Makefile by adding our (for modules location)
    _oldline=$(cat Makefile | grep "^EXTRAVERSION")
    cat Makefile | sed "s|$_oldline|EXTRAVERSION\ =\ $_ker_extraver$_patchset$_cfgname|" > tmpMake
    mv tmpMake Makefile
    now, is this behaviour intended, did I just make some input mistake or is there an error in the pkgbuild?
    Thanks very much in advance!

    All right, I figured out that the first two "-custom"s are caused by this line in the PKGBUILD:
    cat Makefile | sed "s|$_oldline|EXTRAVERSION\ =\ $_ker_extraver$_patchset$_cfgname|" > tmpMake
    ( $_ker_extraver contains one and $_cfgname, of course, the other)
    The third one seems to be appended by the LOCALVERSION config setting, which should actually be the only one to be added I think.
    So would it be possible to just omit all of the PKGBUILD code quoted in the post above and let the -LOCALVERSION do the work for a unique name?
    EDIT: This actually works quite well, but I suppose problems might occur in other places then. No bash expert here?
    EDIT 2: When trying to compile the nvidia module afterwards, I also found out that
    # copy files necessary for later builds, like nvidia and vmware
    cp arch/i386/Makefile.cpu $startdir/pkg/usr/src/linux-$_idstr/arch/i386/
    was missing, but exists in the stock kernel PKGBUILD.
    Is this one acutally somehow out-dated or am I just too stupid to make it work correctly?
    Last edited by Eradest (2007-10-27 15:45:21)

  • Making a kernel PKGBUILD

    Hello,
    I tried to make my own kernel package with the abs system. I studied the wiki documentation (http://wiki.archlinux.org/index.php/Cus … n_with_ABS)
    After making all configurations in the PKGBUILD, I copied the "kernel126.install", kernel-config-file and the patches in /var/abs/local/kernel26-sn-client-04"
    My PKGBUILD:
    # Contributor: Flasher <[email protected]>
    pkgname=kernel26-sn-client-04
    pkgver=2.6.13
    pkgrel=1
    pkgdesc="The Linux Kernel 2.6.13.4 for sn-client-04 withpatches for softcam"
    url="http://www.kernel.org"
    depends=('module-init-tools')
    install=kernel26.install
    ##### add any patch sources to this section
    source=(config ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$pkgver.tar.bz2
    dvb_demux.c.patch av7110_ca.c.patch )
    # Function to grab var from src
    getvar() {
    old=$(cat Makefile | grep "^$1")
    echo $(echo ${old/"$1 ="/} | sed -e "s/[ ]*(.*)[ ]*/1/g")
    return 0
    build() {
    cd $startdir/src/linux-$pkgver
    ##### Uncomment and apply any patches here
    patch -Np1 -i ../dvb_demux.c.patch || return 1
    patch -Np1 -i ../av7110_ca.c.patch || return 1
    # get rid of the 'i' in i686
    carch=`echo $CARCH | sed 's|i||'`
    cat ../config | sed "s|#CARCH#|$carch|g" >./.config
    ##### Load config - uncomment your preferred config method
    #yes "" | make config
    #make oldconfig || return 1
    make menuconfig
    #make xconfig
    #make gconfig
    ##### NO USER CHANGES BELOW HERE #####
    # save the current pkgname
    old_pkgname=$pkgname
    # set pkgname for build purposes - DO NOT alter!
    pkgname=kernel26
    # save the updated config to build with today's date
    cp ./.config $startdir/config-$(date +%b%d-%Hh)
    # get EXTRAVERSION from Makefile to create a unique pkgname and /usr/src directory
    _kernextra=$(getvar "EXTRAVERSION")
    # grab the 2.6.x.y version suffix from pkgver
    _y="`echo $pkgver | cut --delim "." --fields 4`"
    # remove .y version suffix from _kernextra
    _kernextra="`echo $_kernextra | sed "s|.$_y||g"`"
    # Read the full kernel version info from new config to use in pathnames and pkgname
    . ./.config
    # Kernel custom - to create a unique pkgname (see below)
    _kerncust="${_kernextra}${CONFIG_LOCALVERSION}"
    # Kernel release - will be the same as Makefile
    _kernrel="${pkgver}${_kerncust}"
    # Get the pkgver suffix for unique pkgname and /boot file suffices
    _pkgversuf="`echo $pkgver | sed "s|2.6.||g" | sed "s|.||g"`"
    # Set /boot file suffices from kernel release and pkgver suffix
    _kernboot="${_pkgversuf}${_kerncust}"
    # Set a new pkgname from kernel release and pkgver suffix
    pkgname="${pkgname}${_pkgversuf}${_kerncust}"
    # build!
    echo
    echo -n "Do you want to make clean (default YES)? (YES/NO): "
    read choice
    echo
    echo -n "Press any key to start make or CTRL+C to quit"
    read anykey
    if [ "${choice}" = "NO" ] ; then
    make bzImage modules || return 1
    else
    make clean bzImage modules || return 1
    fi
    mkdir -p $startdir/pkg/{lib/modules,boot}
    make INSTALL_MOD_PATH=$startdir/pkg modules_install || return 1
    cp System.map $startdir/pkg/boot/System.map26${_kernboot}
    cp arch/i386/boot/bzImage $startdir/pkg/boot/vmlinuz26${_kernboot}
    install -D -m644 Makefile
    $startdir/pkg/usr/src/linux-${_kernrel}/Makefile
    install -D -m644 .config
    $startdir/pkg/usr/src/linux-${_kernrel}/.config
    install -D -m644 .config $startdir/pkg/boot/kconfig26${_kernboot}
    mkdir -p $startdir/pkg/usr/src/linux-${_kernrel}/include
    mkdir -p $startdir/pkg/usr/src/linux-${_kernrel}/arch/i386/kernel
    for i in acpi asm-generic asm-i386 config linux math-emu net pcmcia scsi video; do
    cp -a include/$i $startdir/pkg/usr/src/linux-${_kernrel}/include/
    done
    # copy files necessary for later builds, like nvidia and vmware
    cp Module.symvers $startdir/pkg/usr/src/linux-${_kernrel}
    cp -a scripts $startdir/pkg/usr/src/linux-${_kernrel}
    mkdir -p $startdir/pkg/usr/src/linux-${_kernrel}/.tmp_versions
    cp arch/i386/Makefile $startdir/pkg/usr/src/linux-${_kernrel}/arch/i386/
    cp arch/i386/kernel/asm-offsets.s
    $startdir/pkg/usr/src/linux-${_kernrel}/arch/i386/kernel/
    # copy in Kconfig files
    for i in `find . -name "Kconfig*"`; do
    mkdir -p $startdir/pkg/usr/src/linux-${_kernrel}/`echo $i | sed 's|/Kconfig.*||'`
    cp $i $startdir/pkg/usr/src/linux-${_kernrel}/$i
    done
    cd $startdir/pkg/usr/src/linux-${_kernrel}/include && ln -s asm-i386 asm
    chown -R root.root $startdir/pkg/usr/src/linux-${_kernrel}
    cd $startdir/pkg/lib/modules/${_kernrel} &&
    (rm -f source build; ln -sf /usr/src/linux-${_kernrel} build)
    # Correct the pkgname in our PKGBUILD - this allows correct gensync operation
    # NOTE: pkgname variable must be declared with first 10 lines of PKGBUILD!
    cd $startdir
    sed -i "1,11 s|pkgname=$old_pkgname|pkgname=$pkgname|" ./PKGBUILD
    # vim:syntax=sh
    When I execute the command "makepkg" I get the following error message:
    [root@sn-client-04 kernel26-sn-client-04]# makepkg
    : command not found
    : command not found:
    '/PKGBUILD: line 15: syntax error near unexpected token `{
    '/PKGBUILD: line 15: `getvar() {
    ) does not exist.l scriptlet (kernel26.install
    Does anybody know the mistake in my configuration?
    Thanks for your answers! 
    Greetings
    Flasher

    Sorry, but this wasn't the mistake  :?
    Now, all sources are located in one line:
    # Contributor: Flasher <xxxxxxxxxxxxxxxxxxxx>
    pkgname=kernel26-sn-client-04
    pkgver=2.6.13.4
    pkgrel=1
    pkgdesc="The Linux Kernel 2.6.13.4 for sn-client-04 with patches for softcam"
    url="http://www.kernel.org"
    depends=('module-init-tools')
    install=kernel26.install
    ##### add any patch sources to this section
    source=(config ftp://ftp.kernel.org/pub/linux/kernel/v … er.tar.bz2 dvb_demux.c.patch av7110_ca.c.patch)
    # Function to grab var from src
    getvar() {
      old=$(cat Makefile | grep "^$1")
      echo $(echo ${old/"$1 ="/} | sed -e "s/[ ]*(.*)[ ]*/1/g")
      return 0
    build() {
      cd $startdir/src/linux-$pkgver
      ##### Uncomment and apply any patches here
      patch -Np1 -i ../dvb_demux.c.patch || return 1
      patch -Np1 -i ../av7110_ca.c.patch || return 1
      # get rid of the 'i' in i686
      carch=`echo $CARCH | sed 's|i||'`
      cat ../config | sed "s|#CARCH#|$carch|g" >./.config
      ##### Load config - uncomment your preferred config method
      #yes "" | make config
      #make oldconfig || return 1
      make menuconfig
      #make xconfig
      #make gconfig
      ##### NO USER CHANGES BELOW HERE #####
    The error message is the same: (only line 14 instead of line 15)
    [root@sn-client-04 kernel26-sn-client-04]# makepkg
    : command not found
    : command not found:
    '/PKGBUILD: line 14: syntax error near unexpected token `{
    '/PKGBUILD: line 14: `getvar() {
    ) does not exist.l scriptlet (kernel26.install
    I think it must be correct  Any ideas?
    Greetings
    Flasher
    P.S.: Sorry for my german-english 

  • Kernel PKGBUILD force make menuconfig (SOLVED)

    Using an ABS kernel26 to build my own kernel package, but stuck on making menuconfig!
    I have my kernel, patches, PKGBUILD, etc... all collected in a directory on my desktop (ALL SET, READY TO GO)
    So, here's what i'd like to be able to do:
    #makepkg... [[ when makepkg runs i'd like to get to a terminal and make menuconfig before the process continues ]]
    Therefore i'd like the PKGBUILD file to specify that i complete make menuconfig myself before the makepkg continues:
    Okay, got it the sources have to be available to the makepkg script in order to do a make menuconfig!
    I'll collect all this together and produce a mini howto ASAP.
    Last edited by Hongkongblue (2007-08-17 04:57:48)

    There are already various wiki pages about this. If you would like to add to them, please feel free.

  • Software Raid and Kernel Panic (from wiki page) [SOLVED]

    I am trying to setup a RAID 5 array using the instructions on the wiki:
    http://wiki.archlinux.org/index.php/Ins … AID_or_LVM
    I get through the instructions (have actually done it several times now) and get the following error:
    io scheduler deadline registered
    io scheduler cfq registered
    FDC 0 is a post-1991 82077
    RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
    loop: loaded (max 8 devices)
    mice: PS/2 mouse device common for all mice
    NET: Registered protocol family 2
    IP route cache hash table entries: 65536 (order: 6, 262144 bytes)
    TCP establised hash table entries: 262144 (order: 9,3145728 bytes)
    input: AT Translated Set 2 keyboard on isa0060/serio0
    TCP bind hash table entries: 65536 (order: 7, 786432 bytes)
    TCP: Hash tables configured (established 262144 bind 65536)
    TCP reno registered
    TCP bic registered
    NET: Registered protocol family 1
    NET: Registered protocol family 10
    Disabled Privacy Extensions on device c03f6580(lo)
    IPv6 over IPv4 tunneling driver
    NET: Registered protocol family 17
    Starting balanced_irq
    Using IPI Shortcut mode
    VFS: Cannot open root device "md0" or unknown-block(0,0)
    Please append a correct "root=" boot option
    Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
    The grub menu.lst
    root (hd0,0)
    kernel /vmlinuz26 root=/dev/md0 ro
    I setup three partitions on IDE drives
    /dev/md0 - root (8 GB / drive)
    /dev/md1 - boot (100 MB / drive)
    /dev/md2 - swap (1 GB / drive)
    I have three drives for the area with three partitions on each:
    hda1 - boot
    hda2 - swap
    hda3 - root
    I did skip the LVM step in the wiki pages.
    fstab
    none /dev/pts devpts defaults 0 0
    none /dev/shm tmpfs defaults 0 0
    /dev/cdrom /mnt/cd iso9660 ro,user,noauto,unhide 0 0
    /dev/cdrom /mnt/dvd udf ro,user,noauto,unhide 0 0
    /dev/fd0 /mnt/fl vfat user,noauto 0 0
    /dev/md0 / reiserfs defaults 0 0
    /dev/md2 swap swap defaults 0 0
    /dev/md1 /boot reiserfs defaults 0 0
    mkinintrd.conf
    REMOVE_IDE=
    REMOVE_SCSI=
    REMOVE_SATA=1
    REMOVE_CDROM=
    REMOVE_USB=1
    REMOVE_FW=1
    REMOVE_RAID=
    REMOVE_CRYPT=1
    REMOVE_FS=
    REMOVE_DM=
    RAID_ROOT_ARRAY="md0"
    RAID_ROOT_DEVICES="/dev/hda3 /dev/hdb3 /dev/hdc3"
    HOSTCONTROLLER_IDE=
    HOSTCONTROLLER_SCSI=
    HOSTCONTROLLER_SATA=
    HOSTCONTROLLER_USB=
    FILESYSTEMS=
    CRYPT_DEVICE=
    ADD_MODULE=
    REMOVE_MODULE=
    The system is a dual PIII using the arch ISO 7.1 release.
    Any thoughts on what is wrong with my setup?  Or something I can try.  I'm game for just about anything in my test environment to try and get it working.
    Thanks,
    Chris....

    After the basketball games where over tonight I had a thought (and a little research).  The install iso I was using was a pre-release of 0.7.1.  When I downloaded the real mccoy and did a fresh install following the instructions on the wiki, all worked flawlessly!
    Chris....

  • Question about kernel compilation from wiki

    Hello,
    I compile kernel in line with arch wiki (http://wiki.archlinux.org/index.php/Ker … rom_Source). In paragraph '2. With makepkg and pacman (Recommended)' are lines:
    mv [kernel location]/* src/
    cp -r [kernel location]/* src/
    Does it make sense? First I move [kernel location] to src/ (I think it should be '/src/') and then I copy nonexistent [kernel location] to the same path.
    Thanks
    #edit:
    I looked through word 'either' So now I'm not sure with this:
    (my build directory is ~/kernelbuild)
    1. in ~/kernelbuild create 'src' directory
    2. copy ~/kernelbuild/linux-2.6.30.5/* src/
    Am I right?
    Last edited by cinan (2009-08-22 12:16:34)

    Commands are correct, but as I said I was little confused about names/terms (eg kernel location-kernel source, making directory usr). I hope the wiki page will be more clear for users who never compiled custom kernel.

  • [SOLVED] Compiling kernel PKGBUILD from ABS (2.6.34)

    So I'm currently compiling a kernel from ABS, and its been running som docbook stuff for 2-3 hours now which I've never seen before when compiling a kernel with ABS.
    I commented out the line that allowed me to edit the config with make menuconfig. I tweaked the kernel to 1000hz and set up my cpu family.
    Is this normal? Im pretty sure this didnt happen when I compiled 2.6.33.4 from ABS
    This is what its been spamming for the past ~2 hours:
    Note: Writing struct_usb_host_ss_ep_comp.9
    Warn: meta author : no refentry/info/author struct usb_host_endpoint
    Note: meta author : see http://docbook.sf.net/el/author struct usb_host_endpoint
    Warn: meta author : no author data, so inserted a fixme struct usb_host_endpoint
    Note: Writing struct_usb_host_endpoint.9
    Warn: meta author : no refentry/info/author struct usb_interface
    Note: meta author : see http://docbook.sf.net/el/author struct usb_interface
    Warn: meta author : no author data, so inserted a fixme struct usb_interface
    Note: Writing struct_usb_interface.9
    Warn: meta author : no refentry/info/author struct usb_interface_cache
    Note: meta author : see http://docbook.sf.net/el/author struct usb_interface_cache
    Warn: meta author : no author data, so inserted a fixme struct usb_interface_cache
    Last edited by XAM (2010-06-29 06:19:50)

    Coacher wrote:Since 2.6.34 there is also kernel26-manpages and kernel26-docs packages that also placed in kernel26 PKGBUILD.
    I've never compiled that docs stuff for myself so cant say how long it takes, but if you need only new kernel26 package you can safely wipe out that lines from PKGBUILD.
    wow, thats good to hear. Took ages compiling with it there.

  • A PKGBUILD that allows multiple installed kernels

    Hi All,
    I've had so many people help me with so many things here at Arch, hopefully this will be useful to someone.
    What is it:
    I've got a kernel PKGBUILD file that allows me to build and install as many different kernels as desired, as long as each one has a unique $pkgver-$pkgrel setting.
    /var/abs/local/kernel-custom1/PKGBUILD:
    # $Id: PKGBUILD,v 1.17 2004/05/11 23:25:20 judd Exp $
    # Maintainer: judd <[email protected]>
    # 2004/06/30: Modified to support multiple loaded kernels -jea
    # Any kernel with a unique $pkgver-$pkgrel will not conflict with others.
    pkgver=2.6.6
    pkgrel=custom1
    # name mangling is necessary so pacman will load multiple packages
    pkgname=kernel$pkgver$pkgrel
    pkgdesc="Linux Kernel ver: $pkgver, build: $pkgrel"
    url="http://www.kernel.org"
    depends=('module-init-tools')
    # Is this file were patches to grub/menu.lst should occur? -jea
    install=kernel26.install
    source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$pkgver.tar.bz2
    config)
    # patch makepkg to use as many sums as listed, in order? -jea
    md5sums=('5218790bc3db41e77a7422969639a9ad' 'fd32e9f43e9b6060e01f71d666372518')
    build() {
    cd $startdir/src/linux-$pkgver
    # get rid of the 'i' in i686
    carch=`echo $CARCH | sed 's|i||'`
    cat ../config | sed "s|#CARCH#|$carch|g" >./.config
    yes "" | make config
    # set EXTRAVERSION to create unique /lib/modules/ subdirectories
    cat Makefile | sed "s|EXTRAVERSION =|EXTRAVERSION = -$pkgrel|" > tmpMake
    mv tmpMake Makefile
    make clean bzImage modules || return 1
    mkdir -p $startdir/pkg/{lib/modules,boot}
    make INSTALL_MOD_PATH=$startdir/pkg modules_install || return 1
    # create unique names in /boot/
    cp System.map $startdir/pkg/boot/System.map-$pkgver-$pkgrel
    cp arch/i386/boot/bzImage $startdir/pkg/boot/vmlinuz-$pkgver-$pkgrel
    install -D -m644 Makefile $startdir/pkg/usr/src/linux-$pkgver/Makefile
    install -D -m644 .config $startdir/pkg/usr/src/linux-$pkgver/.config
    install -D -m644 .config $startdir/pkg/boot/kconfig-$pkgver-$pkgrel
    mkdir -p $startdir/pkg/usr/src/linux-$pkgver/include
    mkdir -p $startdir/pkg/usr/src/linux-$pkgver/arch/i386/kernel
    for i in acpi asm-generic asm-i386 config linux math-emu net pcmcia scsi video; do
    cp -a include/$i $startdir/pkg/usr/src/linux-$pkgver/include/
    done
    # copy files necessary for later builds, like nvidia and vmware
    # does this "$pkgver-$pkgrel" multi-kernel strategy screw these up? -jea
    cp -a scripts $startdir/pkg/usr/src/linux-$pkgver/
    cp arch/i386/Makefile $startdir/pkg/usr/src/linux-$pkgver/arch/i386/
    cp arch/i386/kernel/asm-offsets.s $startdir/pkg/usr/src/linux-$pkgver/arch/i386/kernel/
    # copy in Kconfig files
    for i in `find . -name "Kconfig*"`; do
    mkdir -p $startdir/pkg/usr/src/linux-$pkgver/`echo $i | sed 's|/Kconfig.*||'`
    cp $i $startdir/pkg/usr/src/linux-$pkgver/$i
    done
    cd $startdir/pkg/usr/src/linux-$pkgver/include && ln -s asm-i386 asm
    cd $startdir/pkg/usr/src
    # create a unique subdirectory under /usr/src/
    mv linux-$pkgver linux-$pkgver-$pkgrel
    chown -R root.root $startdir/pkg/usr/src/linux-$pkgver-$pkgrel
    cd $startdir/pkg/lib/modules/$pkgver-$pkgrel &&
    (rm -f build; ln -sf /usr/src/linux-$pkgver-$pkgrel build)
    How it works:
    The primary thing I've usually done is wipe out my custom kernel by inadvertantly overwriting the loadable modules in the /lib/modules/$pkgver directory with a pacman -Su.
    The reason for this is that the current arch kernel build does not set the EXTRAVERSION variable in the kernel top level makefile. Therefore all kernels of the same $pkgver use the same /lib/modules/$pkgver/ subdirectory.
    The above PKGBUILD sets EXTRAVERSION to the $pkgrel variable.
    This causes the loadable module tree to be in a /lib/modules/$pkgver-$pkgrel/ directory.
    There are two other places where kernels experience file conflicts:
    /boot/
    /usr/src/
    The /boot/ files: vmlinuz, System.map and kconfig are given unique names by appending the $pkgver-$pkgrel string.
    The /usr/src/linux-$pkgver/ directory is moved to /usr/src/linux-$pkgver-$pkgrel/.
    This allows the loadable kernel, the loadable modules and the stripped source headers to be in a unique place for each different kernel. Therefore multiple kernels can be loaded concurrently and the desired one may be chosen at boot time by grub.
    The only thing a little weird about this, is the $pkgname variable. pacman will only load one version of each $pkgname, so for multiple kernels to be loaded, they each have to have a unique $pkgname. This is accomplished by appending the $pkgver and $pkgrel to the $pkgname. This is fine, except it gives a slightly weird name for the resulting kernel package file. It has the format:
    kernel$pkgver$pkgrel-$pkgver-$pkgrel.pkg.tar.gz
    That is, the $pkgver and $pkgrel appear in the package file name twice. This also shows if one issues:
    pacman -Q | grep kernel -
    Which yields for me:
    kernel2.6.6custom1 2.6.6-custom1
    kernel2.6.61 2.6.6-1
    kernel26 2.6.7-1
    This command could only have shown one package before, now it shows that I currently have installed: a custom 2.6.6 kernel, the stock arch 2.6.6 kernel built with the above PKGBUILD and the current arch kernel26 package.
    I may choose between any of these at boot time with grub. And as an added bonus, the next time I pacman -Su I won't wipe out my custom /lib/modules subdirectory 8-)
    All of this assumes the supply of your own custom config file as in the arch wiki Building the Kernel in ABS instructions.
    Idle thoughts:
    It would sure be nice if something like this could be adopted for the stock arch kernels. Unlike most other packages it is often desirable to have multiple versions of the kernel package installed at once.
    I wonder if it is practical for pacman to allow multiple versions of the same $pkgname to be installed concurrently if the $pkgname-$pkgver-$pkgrel string is unique and the different versions do not have file conflicts?
    The other major package I could see this being applied to is gcc. It would be really cool to load different cross and other configurations of gcc concurently.
    I find one of the most diifficult things needed to get a workstation running is getting all of the correct kernel modules built in. It seems that most PCs today have all the major features built in to the motherboard chipset: graphics controller, sound, usb, ethernet, etc. If it was possible to build a database of custom kernels, one for each major chipset, then one could be chosen by hardware detection at install time. This would provide the benefits of a custom kernel in an autoload fashion.
    Just dreaming...
    Conclusion:
    I'm not sure how this strategy fits in with the bigger pictiure of running pkg repositories, building dependent packages, who knows what else.
    The thing I hope to add next is automatically adding and removing entries into: /boot/grub/menu.lst when the kernel package is installed and removed. The $pkgdesc string is perfect for serving as the title line.
    Hopefully this can be useful to others, it has helped me clean up my multi-kernel mess here.
    Thanks Again for such an awesome distro...
    John E. A.
    p.s Arch Rulz!

    Thank you, I tried to set something up like this in the wiki, but never tested it and it didn't work for some users. You've tested it well?
    If so, you can copy it over to the wiki (edit or overwrite the Kernel compile with ABS wiki entry), or I can.
    Thanks again, its much appreciated.
    Dusty

  • PKGBUILD Custom Kernel

    Hello
    I have been following https://wiki.archlinux.org/index.php/Ke … rom_Source specifically with pacman and pkgbuild.
    My issue is that the pkgbuild file generates just the kernel.
    As I am wanting to run vmware with this kernel
    I also need it to build kernel-sources and kernel-headers.
    Could anyone guide my in the right direction of a PKGBUILD
    file that will accomplish this standard requirement..
    Thank you.
    Last edited by jebus (2010-11-04 08:07:08)

    Hi
    What I do is use ABS, then just copy /var/abs/core/kernel26 to whatever folder you're working in. That's the official PKGBUILD.
    https://wiki.archlinux.org/index.php/Ke … 26_Package

  • [SOLVED]How to patch a kernel using PKGBUILD

    Hello guys,
    Sorry if my question looks stupid but I'm trying to compile my first kernel following this wiki page and I wonder how to apply a patchset...
    The patchset to apply is the ck one and I've downloaded the patch file from http://ck.kolivas.org/patches/3.0/3.3/3 … .3-ck1.bz2 and placed the patch itself at the root of my PKGBUILD folder.
    At my first attempt to run makepkg, I could see several 'found xxx.patch' (the other patches which were already in the abs tree) but not my ck patch.
    After taking a look in my PKGBUILD file I modified the source instruction as follow to include my pach:
    source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.3.tar.xz"
            "http://www.kernel.org/pub/linux/kernel/ … pkgver}.xz"
            # the main kernel config files
            'config' 'config.x86_64'
            # standard config files for mkinitcpio ramdisk
            "${pkgname}.preset"
            'fix-acerhdf-1810T-bios.patch'
            'change-default-console-loglevel.patch'
            'i915-fix-ghost-tv-output.patch'
            'ext4-options.patch'
        'patch-3.3-ck1')
    Now when I run makepkg, it founds my patch but right after I get  a md5 cheksum error:
    -> Found config
    -> Found config.x86_64
    -> Found linux-custom.preset
    -> Found fix-acerhdf-1810T-bios.patch
    -> Found change-default-console-loglevel.patch
    -> Found i915-fix-ghost-tv-output.patch
    -> Found ext4-options.patch
    -> Found patch-3.3-ck1
    ==> ERROR: Integrity checks (md5) differ in size from the source array.
    [sclarckone@archLaptop linux]$
    I could disable the checksum in makepkg.conf but maybe I'm doing it wrong so I'd like to know the clean way to do it ;-)
    Thanks for your help.
    Last edited by sclarckone (2012-04-18 19:42:01)

    makepkg -g >> PKGBUILD will do this automatically for ya.  FYI, there is a linux-ck package in the AUR you can use as a model if you wish.

  • Kernel-fglrx-custom: Please could someone check/improve my PKGBUILD

    I decided to share a script as it has been very useful to me.  I have never written a PKGBUILD before and it took some attempts to make a working one, so please could someone check the PKGBUILD over and let me know how horrible it is and what I should do differently
    https://aur.archlinux.org/packages/kern … ustom-git/
    It installs fine on my PC, but I'm pretty sure that I'm not using the PKGBUILD file properly.
    Last edited by windows_me (2013-08-27 17:18:45)

    There's a couple of things I would change:
    1) The name doesn't really tell the user what the package is for. "kernel-fglrx-legacy" would probably be more helpful.
    2) Rather than pulling a script that will then pull down the kernel package, why not use the existing kernel PKGBUILD in the ABS? You can easily modify that PKGBUILD to apply your script/patches.

  • Need to compile nvidia driver for a custom kernel [SOLVED]

    I compiled a custom kernel following this wiki page: http://wiki.archlinux.org/index.php/Ker … rom_Source
    I can boot into it just fine.  I now want to compile an nvidia driver for use with it and followed the steps on this wiki page: http://wiki.archlinux.org/index.php/NVI … tom_kernel
    I run into a problem when makepkg trys to compile it.  Here is the output:
    $ cd ~/devel/abs/nvidia/
    $ makepkg -c
    ==> Making package: nvidia-my 190.42-1 x86_64 (Thu Nov 5 17:42:29 EST 2009)
    ==> Checking Runtime Dependencies...
    ==> Checking Buildtime Dependencies...
    ==> Retrieving Sources...
    -> Found NVIDIA-Linux-x86_64-190.42-pkg0.run in build dir
    ==> Validating source files with md5sums...
    NVIDIA-Linux-x86_64-190.42-pkg0.run ... Passed
    ==> Extracting Sources...
    ==> Entering fakeroot environment...
    ==> Starting build()...
    Creating directory NVIDIA-Linux-x86_64-190.42-pkg0
    Verifying archive integrity... OK
    Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 190.42..................................................................................................................................................
    If you are using a Linux 2.4 kernel, please make sure
    you either have configured kernel sources matching your
    kernel or the correct set of kernel headers installed
    on your system.
    If you are using a Linux 2.6 kernel, please make sure
    you have configured kernel sources matching your kernel
    installed on your system. If you specified a separate
    output directory using either the "KBUILD_OUTPUT" or
    the "O" KBUILD parameter, make sure to specify this
    directory with the SYSOUT environment variable or with
    the equivalent nvidia-installer command line option.
    Depending on where and how the kernel sources (or the
    kernel headers) were installed, you may need to specify
    their location with the SYSSRC environment variable or
    the equivalent nvidia-installer command line option.
    *** Unable to determine the target kernel version. ***
    make: *** [select_makefile] Error 1
    ==> ERROR: Build Failed.
    Aborting...
    The step it's choking on is (from the PKGBUILD), "make SYSSRC=/lib/modules/${_kernver}/build module || return 1"
    What am I doing wrong?
    My PKGBUILD:
    pkgname=nvidia-my
    pkgver=190.42
    _kernver='2.6.32-rc6-MINE'
    pkgrel=1
    pkgdesc="NVIDIA drivers for kernel26."
    arch=('i686' 'x86_64')
    [ "$CARCH" = "i686" ] && ARCH=x86
    [ "$CARCH" = "x86_64" ] && ARCH=x86_64
    url="http://www.nvidia.com/"
    depends=('kernel26>=2.6.31' 'kernel26<2.6.32' "nvidia-utils=${pkgver}")
    conflicts=('nvidia-96xx' 'nvidia-173xx')
    license=('custom')
    install=nvidia.install
    source=("http://download.nvidia.com/XFree86/Linux-$ARCH/${pkgver}/NVIDIA-Linux-$ARCH-${pkgver}-pkg0.run")
    md5sums=('f94806feee87de756d14fe3e9bcaf05a')
    [ "$CARCH" = "x86_64" ] && md5sums=('ae431ff849ec01446e6724f9fcfe3bb4')
    build() {
    cd $srcdir
    sh NVIDIA-Linux-$ARCH-${pkgver}-pkg0.run --extract-only
    cd NVIDIA-Linux-$ARCH-${pkgver}-pkg0
    cd usr/src/nv/
    ln -s Makefile.kbuild Makefile
    make SYSSRC=/lib/modules/${_kernver}/build module || return 1
    mkdir -p $pkgdir/lib/modules/${_kernver}/kernel/drivers/video/
    install -m644 nvidia.ko $pkgdir/lib/modules/${_kernver}/kernel/drivers/video/
    sed -i -e "s/KERNEL_VERSION='.*'/KERNEL_VERSION='${_kernver}'/" $startdir/nvidia.install
    My nvidia.install
    post_install() {
    KERNEL_VERSION='2.6.32-rc6-MINE'
    depmod $KERNEL_VERSION
    post_upgrade() {
    post_install
    rmmod nvidia || echo 'In order to use the new nvidia module, exit Xserver and unload it manually.'
    post_remove() {
    KERNEL_VERSION='2.6.32-rc6-MINE'
    depmod $KERNEL_VERSION
    Last edited by graysky (2009-11-07 10:54:33)

    Hello,
    I'm kind of a noob and am trying to get follow the directions from the Nvidia wiki on installing on a custom kernel.  I'm trying to use the abs method to install on kernel26rt version 2.6.33rt.  I followed directions exactly and am getting an error that I didn't find on any other posts.  Can you please take a look?  Here is my terminal:
    [jsadural@jlinux nvidia]$ makepkg -ci
    ==> Making package: nvidia-2633rt 270.30-3 (Wed Mar 30 08:53:08 PDT 2011)
    ==> Checking runtime dependencies...
    ==> Checking buildtime dependencies...
    ==> Retrieving Sources...
      -> Downloading NVIDIA-Linux-x86_64-270.30-no-compat32.run...
    --2011-03-30 08:53:08--  ftp://download.nvidia.com/XFree86/Linux … mpat32.run
               => “NVIDIA-Linux-x86_64-270.30-no-compat32.run.part”
    Resolving download.nvidia.com... 69.31.121.43
    Connecting to download.nvidia.com|69.31.121.43|:21... connected.
    Logging in as anonymous ... Logged in!
    ==> SYST ... done.    ==> PWD ... done.
    ==> TYPE I ... done.  ==> CWD (1) /XFree86/Linux-x86_64/270.30 ... done.
    ==> SIZE NVIDIA-Linux-x86_64-270.30-no-compat32.run ... 30037601
    ==> PASV ... done.    ==> RETR NVIDIA-Linux-x86_64-270.30-no-compat32.run ... done.
    Length: 30037601 (29M) (unauthoritative)
    100%[======================================>] 30,037,601   696K/s   in 42s     
    2011-03-30 08:53:50 (696 KB/s) - “NVIDIA-Linux-x86_64-270.30-no-compat32.run.part” saved [30037601]
    ==> Validating source files with md5sums...
        NVIDIA-Linux-x86_64-270.30-no-compat32.run ... Passed
    ==> Extracting Sources...
    ==> Starting build()...
    Creating directory NVIDIA-Linux-x86_64-270.30-no-compat32
    Verifying archive integrity... OK
    Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 270.30........................................................................................................................
    NVIDIA: calling KBUILD...
    test -e include/generated/autoconf.h -a -e include/config/auto.conf || (    \
        echo;                                \
        echo "  ERROR: Kernel configuration is invalid.";        \
        echo "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
        echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";    \
        echo;                                \
        /bin/false)
    mkdir -p /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/.tmp_versions ; rm -f /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/.tmp_versions/*
    make -f scripts/Makefile.build obj=/home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel
      cc -Wp,-MD,/home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/.nv.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.2/include -I/usr/src/linux-2.6.33-rt/arch/x86/include -Iinclude  -include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-dwarf2-cfi-asm -fconserve-stack -I/home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel -Wall -MD -Wsign-compare -Wno-cast-qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"270.30\" -Wno-unused-function -mcmodel=kernel -mno-red-zone -UDEBUG -U_DEBUG -DNDEBUG  -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(nv)"  -D"KBUILD_MODNAME=KBUILD_STR(nvidia)"  -c -o /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.o /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c
    In file included from /usr/src/linux-2.6.33-rt/arch/x86/include/asm/uaccess.h:573:0,
                     from include/linux/poll.h:13,
                     from /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv-linux.h:84,
                     from /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:13:
    /usr/src/linux-2.6.33-rt/arch/x86/include/asm/uaccess_64.h: In function ‘copy_from_user’:
    /usr/src/linux-2.6.33-rt/arch/x86/include/asm/uaccess_64.h:35:6: warning: comparison between signed and unsigned integer expressions
    In file included from /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:13:0:
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv-linux.h: At top level:
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv-linux.h:251:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘nv_spinlock_t’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv-linux.h:1436:5: error: expected specifier-qualifier-list before ‘nv_spinlock_t’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c: In function ‘nv_alloc_file_private’:
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:1993:5: error: implicit declaration of function ‘semaphore_init’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:1994:5: error: ‘nv_file_private_t’ has no member named ‘waitqueue’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:1995:5: error: implicit declaration of function ‘atomic_spin_lock_init’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:1995:5: error: ‘nv_file_private_t’ has no member named ‘fp_lock’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c: In function ‘nv_kern_poll’:
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:2790:30: error: ‘nv_file_private_t’ has no member named ‘waitqueue’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:2793:5: error: implicit declaration of function ‘atomic_spin_lock_irqsave’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:2793:5: error: ‘nv_file_private_t’ has no member named ‘fp_lock’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:2804:5: error: implicit declaration of function ‘atomic_spin_unlock_irqrestore’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:2804:5: error: ‘nv_file_private_t’ has no member named ‘fp_lock’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c: In function ‘nv_kern_close_registry’:
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:3595:18: error: ‘nv_file_private_t’ has no member named ‘off’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:3611:22: error: ‘nv_file_private_t’ has no member named ‘off’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c: In function ‘nv_kern_write_registry’:
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:3703:51: error: ‘nv_file_private_t’ has no member named ‘off’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:3710:45: error: ‘nv_file_private_t’ has no member named ‘off’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:3720:9: error: ‘nv_file_private_t’ has no member named ‘off’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c: In function ‘nv_post_event’:
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:4330:5: error: ‘nv_file_private_t’ has no member named ‘fp_lock’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:4347:5: error: ‘nv_file_private_t’ has no member named ‘waitqueue’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:4348:5: error: ‘nv_file_private_t’ has no member named ‘fp_lock’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c: In function ‘nv_get_event’:
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:4362:5: error: ‘nv_file_private_t’ has no member named ‘fp_lock’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:4365:9: error: ‘nv_file_private_t’ has no member named ‘fp_lock’
    /home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.c:4390:5: error: ‘nv_file_private_t’ has no member named ‘fp_lock’
    make[3]: *** [/home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel/nv.o] Error 1
    make[2]: *** [_module_/home/jsadural/devel/abs/nvidia/src/NVIDIA-Linux-x86_64-270.30-no-compat32/kernel] Error 2
    NVIDIA: left KBUILD.
    nvidia.ko failed to build!
    make[1]: *** [module] Error 1
    make: *** [module] Error 2
    ==> ERROR: A failure occurred in build().
        Aborting...
    thanks,
    jason

  • Questions about compiling kernel on archlinux

    hi...i'm new of this forum and new of archlinux
    i'm tryng to compiling a custom kernel in order not to replace the kernel26 package.. i prefere to make it with abs for managing it with pacman.. i followed the wiki but something went wrong.... i used both the pkgbuild i found on the wiki but nothing...can someone help me please??

    if it can be of any help, this works for me too. actually, it's the official arch kernel PKGBUILD (maybe not the latest one) that I've just changed according to my needs:
    # $Id: PKGBUILD 17203 2008-10-26 20:28:29Z tpowa $
    # Maintainer: Tobias Powalowski <[email protected]>
    # Maintainer: Thomas Baechler <[email protected]>
    pkgname=kernel26mm
    _basekernel=2.6.27
    pkgver=2.6.28
    pkgrel=5
    _patchname="patch-${pkgver}-${pkgrel}-ARCH"
    pkgdesc="The Linux Kernel and modules"
    arch=(i686 x86_64)
    license=('GPL2')
    groups=('base')
    url="http://www.kernel.org"
    backup=(etc/mkinitcpio.d/${pkgname}.preset)
    depends=('coreutils' 'module-init-tools' 'mkinitcpio>=0.5.18')
    # pwc, ieee80211 and hostap-driver26 modules are included in kernel26 now
    # nforce package support was abandoned by nvidia, kernel modules should cover everything now.
    # kernel24 support is dropped since glibc24
    replaces=('kernel24' 'kernel24-scsi' 'kernel26-scsi'
    'alsa-driver' 'ieee80211' 'hostap-driver26'
    'pwc' 'nforce' 'squashfs' 'unionfs' 'ivtv'
    'zd1211' 'kvm-modules' 'iwlwifi' 'rt2x00-cvs'
    'gspcav1')
    install=kernel26mm.install
    source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_basekernel.tar.bz2
    ftp://ftp.kernel.org/pub/linux/kernel/v2.6/testing/patch-2.6.28-rc2.bz2
    http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.28-rc2/2.6.28-rc2-mm1/2.6.28-rc2-mm1.bz2
    # the main kernel config files
    config config.x86_64
    iosched-bfq-03-update-kconfig-kbuild.patch
    iosched-bfq-02-add-bfq-scheduler.patch
    iosched-bfq-01-prepare-iocontext-handling.patch
    zen.git-aircrack.patch
    march-native.patch
    # standard config files for mkinitcpio ramdisk
    kernel26mm.preset)
    build() {
    KARCH=x86
    cd $startdir/src/linux-$_basekernel
    # Add -ARCH patches
    # See http://projects.archlinux.org/git/?p=linux-2.6-ARCH.git;a=summary
    patch -Np1 -i $startdir/src/patch-2.6.28-rc2 || return 1
    patch -Np1 -i $startdir/src/2.6.28-rc2-mm1 || return 1
    patch -Np1 -i $startdir/src/iosched-bfq-01-prepare-iocontext-handling.patch || return 1
    patch -Np1 -i $startdir/src/iosched-bfq-02-add-bfq-scheduler.patch || return 1
    patch -Np1 -i $startdir/src/iosched-bfq-03-update-kconfig-kbuild.patch || return 1
    patch -Np1 -i $startdir/src/zen.git-aircrack.patch || return 1
    patch -Np1 -i $startdir/src/march-native.patch || return 1
    sed -i 's|^EXTRAVERSION = .*$|EXTRAVERSION =|g' Makefile
    if [ "$CARCH" = "x86_64" ]; then
    cat ../config.x86_64 >./.config
    else
    cat ../config >./.config
    fi
    # build the full kernel version to use in pathnames
    . ./.config
    ### next line is only needed for rc kernels
    #_kernver="2.6.25${CONFIG_LOCALVERSION}"
    _kernver="2.6.28${CONFIG_LOCALVERSION}"
    # load configuration
    make menuconfig
    # build!
    # stop here
    # this is useful to configure the kernel
    #msg "Stopping build"
    #return 1
    make bzImage modules || return 1
    mkdir -p $startdir/pkg/{lib/modules,boot}
    make INSTALL_MOD_PATH=$startdir/pkg modules_install || return 1
    cp System.map $startdir/pkg/boot/System.map26mm
    cp arch/$KARCH/boot/bzImage $startdir/pkg/boot/vmlinuz26mm
    install -D -m644 Makefile \
    $startdir/pkg/usr/src/linux-${_kernver}/Makefile
    install -D -m644 kernel/Makefile \
    $startdir/pkg/usr/src/linux-${_kernver}/kernel/Makefile
    install -D -m644 .config \
    $startdir/pkg/usr/src/linux-${_kernver}/.config
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/include
    for i in acpi asm-{generic,x86} config linux math-emu media net pcmcia scsi sound video; do
    cp -a include/$i $startdir/pkg/usr/src/linux-${_kernver}/include/
    done
    # copy files necessary for later builds, like nvidia and vmware
    cp Module.symvers $startdir/pkg/usr/src/linux-${_kernver}
    cp -a scripts $startdir/pkg/usr/src/linux-${_kernver}
    # fix permissions on scripts dir
    chmod og-w -R $startdir/pkg/usr/src/linux-${_kernver}/scripts
    #mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/.tmp_versions
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/arch/$KARCH/kernel
    cp arch/$KARCH/Makefile $startdir/pkg/usr/src/linux-${_kernver}/arch/$KARCH/
    if [ "$CARCH" = "i686" ]; then
    cp arch/$KARCH/Makefile_32.cpu $startdir/pkg/usr/src/linux-${_kernver}/arch/$KARCH/
    fi
    cp arch/$KARCH/kernel/asm-offsets.s $startdir/pkg/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
    # add headers for lirc package
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/drivers/media/video
    cp drivers/media/video/*.h $startdir/pkg/usr/src/linux-${_kernver}/drivers/media/video/
    for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/drivers/media/video/$i
    cp -a drivers/media/video/$i/*.h $startdir/pkg/usr/src/linux-${_kernver}/drivers/media/video/$i
    done
    # add dm headers
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/drivers/md
    cp drivers/md/*.h $startdir/pkg/usr/src/linux-${_kernver}/drivers/md
    # add inotify.h
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/include/linux
    cp include/linux/inotify.h $startdir/pkg/usr/src/linux-${_kernver}/include/linux/
    # add CLUSTERIP file for iptables
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/net/ipv4/netfilter/
    # add wireless headers
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/net/mac80211/
    cp net/mac80211/*.h $startdir/pkg/usr/src/linux-${_kernver}/net/mac80211/
    # add dvb headers for external modules
    # in reference to:
    # http://bugs.archlinux.org/task/9912
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
    cp drivers/media/dvb/dvb-core/*.h $startdir/pkg/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
    # add dvb headers for external modules
    # in reference to:
    # http://bugs.archlinux.org/task/11194
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/include/config/dvb/
    cp include/config/dvb/*.h $startdir/pkg/usr/src/linux-${_kernver}/include/config/dvb/
    # add xfs and shmem for aufs building
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/fs/xfs
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/mm
    cp fs/xfs/xfs_sb.h $startdir/pkg/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
    # add vmlinux
    cp vmlinux $startdir/pkg/usr/src/linux-${_kernver}
    # copy in Kconfig files
    for i in `find . -name "Kconfig*"`; do
    mkdir -p $startdir/pkg/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
    cp $i $startdir/pkg/usr/src/linux-${_kernver}/$i
    done
    cd $startdir/pkg/usr/src/linux-${_kernver}/include && ln -s asm-$KARCH asm
    chown -R root.root $startdir/pkg/usr/src/linux-${_kernver}
    find $startdir/pkg/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
    cd $startdir/pkg/lib/modules/${_kernver} && \
    (rm -f source build; ln -sf ../../../usr/src/linux-${_kernver} build)
    # install fallback mkinitcpio.conf file and preset file for kernel
    install -m644 -D $startdir/src/${pkgname}.preset $startdir/pkg/etc/mkinitcpio.d/${pkgname}.preset || return 1
    # set correct depmod command for install
    sed -i -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" $startdir/kernel26mm.install
    echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${startdir}/pkg/etc/mkinitcpio.d/${pkgname}.kver
    # remove unneeded architectures
    rm -rf $startdir/pkg/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}
    just replace all the kernel26mm by kernel26mycustomkernelname. same below with the install file and of course in your kernel config.
    # arg 1: the new package version
    # arg 2: the old package version
    KERNEL_VERSION=2.6.28-mm
    post_install () {
    # updating module dependencies
    echo ">>> Updating module dependencies. Please wait ..."
    depmod $KERNEL_VERSION > /dev/null 2>&1
    # generate init ramdisks
    echo ">>> MKINITCPIO SETUP"
    echo ">>> ----------------"
    echo ">>> If you use LVM2, Encrypted root or software RAID,"
    echo ">>> Ensure you enable support in /etc/mkinitcpio.conf ."
    echo ">>> More information about mkinitcpio setup can be found here:"
    echo ">>> http://wiki.archlinux.org/index.php/Mkinitcpio"
    echo ""
    echo ">>> Generating initial ramdisk, using mkinitcpio. Please wait..."
    /sbin/mkinitcpio -p kernel26mm
    post_upgrade() {
    pacman -Q grub &>/dev/null
    hasgrub=$?
    pacman -Q lilo &>/dev/null
    haslilo=$?
    # reminder notices
    if [ $haslilo -eq 0 ]; then
    echo ">>>"
    if [ $hasgrub -eq 0 ]; then
    echo ">>> If you use the LILO bootloader, you should run 'lilo' before rebooting."
    else
    echo ">>> You appear to be using the LILO bootloader. You should run"
    echo ">>> 'lilo' before rebooting."
    fi
    echo ">>>"
    fi
    if grep "/boot" /etc/fstab 2>&1 >/dev/null; then
    if ! grep "/boot" /etc/mtab 2>&1 >/dev/null; then
    echo "WARNING: /boot appears to be a seperate partition but is not mounted"
    echo " This is most likely not what you want. Please mount your /boot"
    echo " partition and reinstall the kernel unless you are sure this is OK"
    fi
    fi
    # updating module dependencies
    echo ">>> Updating module dependencies. Please wait ..."
    depmod -v $KERNEL_VERSION > /dev/null 2>&1
    echo ">>> MKINITCPIO SETUP"
    echo ">>> ----------------"
    echo ">>> If you use LVM2, Encrypted root or software RAID,"
    echo ">>> Ensure you enable support in /etc/mkinitcpio.conf ."
    echo ">>> More information about mkinitcpio setup can be found here:"
    echo ">>> http://wiki.archlinux.org/index.php/Mkinitcpio"
    echo ""
    echo ">>> Generating initial ramdisk, using mkinitcpio. Please wait..."
    if [ "`vercmp $2 2.6.19`" -lt 0 ]; then
    /sbin/mkinitcpio -p kernel26mm -m "ATTENTION:\nIf you get a kernel panic below
    and are using an Intel chipset, append 'earlymodules=piix' to the
    kernel commandline"
    else
    /sbin/mkinitcpio -p kernel26mm
    fi
    if [ "`vercmp $2 2.6.21`" -lt 0 ]; then
    echo ""
    echo "Important ACPI Information:"
    echo ">>> Since 2.6.20.7 all possible ACPI parts are modularized."
    echo ">>> The modules are located at:"
    echo ">>> /lib/modules/$(uname -r)/kernel/drivers/acpi"
    echo ">>> For more information about ACPI modules check this wiki page:"
    echo ">>> 'http://wiki.archlinux.org/index.php/ACPI_modules'"
    fi
    op=$1
    shift
    $op $*
    Last edited by bangkok_manouel (2009-01-27 13:55:34)

  • How to create a custom kernel with initrd and ARCH patches

    Hi,
    I like the default kernel because everything seems to work well and I think the Arch kernel includes patches I need (such as the mactel patch). But some options that i would like to be enabled are not. in fact i would like to use powertop but i can't because it needs the CONFIG_TIMER_STATS option.
    What I would like is a kernel based on the arch kernel but with a different config file. Nothing more.
    if i look at the solution on the Wiki, I see that I have to add all patches the standard kernel have ... Moreover there is no initrd creation. i think i will need it if I use the Arch kernel configuration.
    And if i use the kernel26 PKGBUILD, I must change the package name in order to keep my current kernel. It's easy to do in the PKGBUILD but much more complicated to do it in the kernel26.install file beacuse I have to change the filenames in /boot and I do not want to replace the kernel26 files.
    So do you have any ideas how to compile my custom kernel ? Is there a better solution ?
    Thanks.
    Mildred.
    Last edited by mildred (2007-07-03 01:46:33)

    tomk wrote:It's possible I'm missing something here, but I don't understand what you're worried about. If I understand correctly, you now have a PKGBUILD and associated files for kernel26mildred (or whatever you've decided to call it). Why do you think you would have to change the files again when kernel26 is updated?
    don't the patches change from version to version?
    anyways, i was bored so i wrote a little script... edit the configuration variables at the top and it'll do the work for you. just put it in /var/abs/kernels or wherever you have the kernel26/ at, chmod +x scriptname, and run.
    if you're in /var/abs/kernels you'll probably have to run as root.
    from my testing, it seems to be all working (looking at resulting files and no errors so far from makepkg); but i'm still building my test kernel with it.
    #!/bin/bash
    # Author: kano <[email protected]>
    # Configuration #
    appendname="-custom1" # Name to append to kernel package
    BUILD=0 # Build package when done? No = 0; Yes = 1
    #MAKEPKGOPT="" # Uncomment if you're building after you make; Add any options you want passed to makepkg (can be nothing)
    # Work starts here; shouldn't have to edit anything below #
    mkdir kernel26${appendname}/
    cp kernel26/* kernel26${appendname}/
    regen_md5sum() {
    if [ ${file} != 'PKGBUILD' ]; then
    echo "Regenerating md5sum for ${file}"
    cat kernel26${appendname}/PKGBUILD \
    | sed "s/'`md5sum kernel26/${file} | awk '{ print $1 }'`'/'`md5sum kernel26${appendname}/${file} | awk '{ print $1 }'`'/;" \
    > PKGBUILD.tmp
    mv PKGBUILD.tmp kernel26${appendname}/PKGBUILD
    fi
    for file in "PKGBUILD" "kernel26.preset" "kernel26.install"; do
    echo "Editing ${file}"
    cat kernel26/${file} | \
    sed "s/kernel26/kernel26${appendname}/g" \
    | sed "s/vmlinuz26/vmlinuz26${appendname}/g" \
    | sed "s/kconfig26/kconfig26${appendname}/g" \
    | sed "s/System.map26/System.map26${appendname}/g" \
    > kernel26${appendname}/${file}
    # Regenerate md5sum
    regen_md5sum
    done
    for file in "config" "config.x86_64"; do
    echo "Editing ${file}"
    cat kernel26/${file} | \
    sed "s/CONFIG_LOCALVERSION=\"-ARCH\"/CONFIG_LOCALVERSION=\"-ARCH${appendname}\"/" \
    > kernel26${appendname}/${file}
    # Regenerate md5sum
    regen_md5sum
    done
    mv kernel26${appendname}/mkinitcpio-kernel26.conf kernel26${appendname}/mkinitcpio-kernel26${appendname}.conf
    mv kernel26${appendname}/kernel26.install kernel26${appendname}/kernel26${appendname}.install
    mv kernel26${appendname}/kernel26.preset kernel26${appendname}/kernel26${appendname}.preset
    # Add make menuconfig to PKGBUILD
    cat kernel26${appendname}/PKGBUILD | \
    sed 's/# load configuration/\n # configure kernel before build\n make menuconfig\n\n # load configuration/;' \
    > PKGBUILD.tmp
    mv PKGBUILD.tmp kernel26${appendname}/PKGBUILD
    echo "Custom kernel pkgbuild created."
    # To build or to not to build?
    if [ ${BUILD} -eq 1 ]; then
    cd kernel26${appendname}
    makepkg ${MAKEPKGOPT}
    fi

  • Kernel The Arch Way

    Hi,
    after some problems with alsa and #archlinux irc talk I decided to try and build my own kernel. As I see it's lot of learning. I already read The Arch Way, ABS - The Arch Build System, The Arch package making HOW-TO - with guidelines, man makepkg, dependencies thread, makepkg/abs tutorial thread, PKGBUILD help, Arch CVS & SVN PKGBUILD guidelines, Arch Packaging Standards, Kernel Compilation, Kernel Compilation with ABS, Custom Kernel Compilation with ABS, Kernel Patches and Patchsets. And at last I read this thread and I feel the same... Btw I thing kernel compilation also has lots to do with mkinitcpio, right?
    I want to build kernel that would have all necessary stuff for my hw configuration built in. Thats the fastest boot, right? But actually all this wiki stuff got me more confused than I was before .
    What would be the best way? I know all the hw details, so just do 'make menuconfig' and select everything as built in (*), maybe add some patches and automate this using one of example PKGBUILDs?
    I'm still reading forums and googling but I believe some of you can point me faster.

    It is a bit of learning at first.  Once you understand how it works it's very simple.  There is no shortcut, I'm afraid, it seems like you're looking for one...  If there was one it would be outlined in the wiki most likely.
    As far as building kernel with all the hw stuff built in...  IMO, it's not a good idea.  This is something that needed to be done in the past when there was no way to autoload system specific modules at boot.  Boot time benefits would be negligible.  The kernel wouldn't be any faster either.  And you would have to recompile every time there is a kernel update if you wanted to keep up with Arch repos - the net result would be wasting time and speed.
    Kernel compilation itself has nothing to do with mkinitcpio - mkinitcpio is only necessary to generate boot image which happens after the kernel is already compiled; pacman will do it for you completely automatically if you customize the Arch kernel PKGBUILD instead of compiling manually.

Maybe you are looking for