You are not logged in.

#1 2005-10-21 17:59:42

Flasher
Member
From: Bavaria / Germany
Registered: 2005-04-24
Posts: 126

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 <Flasher@bayern-mail.de>
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!  smile

Greetings

Flasher

Offline

#2 2005-10-21 23:19:15

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: Making a kernel PKGBUILD

source=(config ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$pkgver.tar.bz2 
   dvb_demux.c.patch av7110_ca.c.patch ) 

There should be no space after the "" and (although it might not matter) move your "dvb_" line all the way over to the left.
I'm guessing you do have that space after the "" which disregards the next line below as a continuation of the array. If thats the case, bash doesn't see an ending ")" to the array, hence your errors.

Offline

#3 2005-10-22 11:00:09

Flasher
Member
From: Bavaria / Germany
Registered: 2005-04-24
Posts: 126

Re: Making a kernel PKGBUILD

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  wink Any ideas?

Greetings

Flasher

P.S.: Sorry for my german-english  roll

Offline

#4 2005-10-22 14:36:23

Flasher
Member
From: Bavaria / Germany
Registered: 2005-04-24
Posts: 126

Re: Making a kernel PKGBUILD

Problem solved  smile

I edited the PKGBUILD in Windows and copied it to the linux system.
After making a new PKGBUILD only in Linux with VI there were no errors.

But the two files look completely same  :shock:

Greetings

Flasher

Offline

#5 2005-10-22 19:40:57

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Making a kernel PKGBUILD

I got caught by that too, back in my early Linux days. It's to do with the unseen Line Feed/Carriage Return characters used in M$ - Linux/Unix/etc only uses Line Feed.

I believe there are Linux-compatible editors available for Windows, if you ever have to do this again.

Offline

Board footer

Powered by FluxBB