You are not logged in.

#1 2008-06-16 07:14:58

OrionFyre
Member
Registered: 2008-03-16
Posts: 68

Criticisms? First package for r5u870-svn

NOTE: see below for finished product


So I'm building a Pkgbuild for the fun of learning how to do so.

In particular this one is for the r5u870 webcam driver which downloads from the svn and not a static source.

Thus far I have this:

# contributor: orionfyre <OrionFyre on ARCH Forums>
pkgname=r5u870-svn
pkgver=88
pkgrel=1
pkgdesc="r5u870 webcam driver"
arch=('i686' 'x86_64')
url="http://wiki.mediati.org/R5u870"
license=('unknown')
depends=()
makedepends=()
provides=(r5u870)
conflicts=()
source=()
md5sums=() 

_svntrunk="http://svn.mediati.org/svn/r5u870/trunk"
_svnmod=r5u870

build() {
  cd $startdir/src
  msg "Connecting to SVN server...."
  if [ -d $_svnmod/.svn ]; then
    (cd $_svnmod && svn up -r $pkgver)
  else
    svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod
  fi

  msg "SVN checkout done or server timeout"
  msg "Starting make..."
  svn export $_svnmod $_svnmod-build
  cd $_svnmod-build
  #
  # BUILD
  #
  
 sed -i 's/\/lib\/firmware/$pkgdir\/lib\/firmware/g' $startdir/src/r5u870/Makefile
  # NOTE: need to send "$pkgdir/lib/firmare" without messing up the
  #  regex line with a bunch of extra '/' reserved characters.
               
  make || return 1
  make DESTDIR=$pkgdir install || return 1

}

The Makefile has a section like this:

install::
    install -m 0644 -o root -g root $(FWFILES) $(FWDIR)
    /sbin/depmod -a

which installs all the firmware.
FWFILES= a list of the files
FWDIR = /lib/firmware

I of course want to change the variable from '/lib/firmware' to '$pkgdir/lib/firmware'
The first method that came to mind was to use sed to edit the text contained within the Makefile

the only problem is the regex:

sed -i 's/\/lib\/firmware/$pkgdir\/lib\/firmware/g' $startdir/src/r5u870/Makefile

however $pkgdir will contain the reserved / with no character escapes '\' before it.

I'm stumped and tired. here's the relevant parts from the Makefile:

V ?= 0
MDIR := extra

KVER ?= $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build
DESTDIR ?= /lib/firmware                   ## Firmware location

FWFILES = r5u870_1830.fw r5u870_1832.fw r5u870_1833.fw r5u870_1834.fw r5u870_1835.fw r5u870_1836.fw r5u870_1870_1.fw r5u870_1870.fw r5u870_1810.fw r5u870_183a.fw r5u870_183b.fw r5u870_1839.fw r5u870_1841.fw

<BIG SNIP...>

install::
    install -m 0644 -o root -g root $(FWFILES) $(FWDIR)
    /sbin/depmod -a

<SNIPS...>

So if you could school me on some sed regex or point me in the direction of another way of achieving the same I would be grateful.

Last edited by OrionFyre (2008-06-16 15:19:23)

Offline

#2 2008-06-16 07:53:35

pelle.k
Member
From: Åre, Sweden (EU)
Registered: 2006-04-30
Posts: 667

Re: Criticisms? First package for r5u870-svn

First of all, why don't you pass it with "make install DESTDIR=$pkgdir/lib/firmware" ?
Second, you have to expand $pkgdir in the makefile, since it has no idea of what $pkgdir is. Use double quotes, instead of single quotes if you want to expand a variable using sed.


"Your beliefs can be like fences that surround you.
You must first see them or you will not even realize that you are not free, simply because you will not see beyond the fences.
They will represent the boundaries of your experience."

SETH / Jane Roberts

Offline

#3 2008-06-16 14:25:37

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: Criticisms? First package for r5u870-svn

Also use sed s### or s||| instead of s///, it will make your life a lot easier.

Offline

#4 2008-06-16 14:41:49

OrionFyre
Member
Registered: 2008-03-16
Posts: 68

Re: Criticisms? First package for r5u870-svn

Two things. First I copied the wrong one into here. sad it's FWDIR.

and secondly.... yeah thats how tired I was tongue I'll just pass FWDIR, Soon as I woke up I slapped myself silly.


Alright. So the package construct just fine.

I pacman'd it and it installed just fine.

I did however, as I was expecting,

to issue the following commands

depmod -a
modprobe r5u870

Is this something I should keep this way or should that be automated during the install?

Offline

#5 2008-06-16 14:43:37

OrionFyre
Member
Registered: 2008-03-16
Posts: 68

Re: Criticisms? First package for r5u870-svn

Daenyth wrote:

Also use sed s### or s||| instead of s///, it will make your life a lot easier.

I was unaware I was making my life so incredibly difficult with that... and indeed i am __/|\__ thank you.

Offline

#6 2008-06-16 15:17:03

OrionFyre
Member
Registered: 2008-03-16
Posts: 68

Re: Criticisms? First package for r5u870-svn

OK. here goes.

pkgbuild:

# contributor: orionfyre <OrionFyre on ARCH Forums>
pkgname=r5u870-svn
pkgver=88
pkgrel=1
pkgdesc="r5u870 webcam driver"
arch=('i686' 'x86_64')
url="http://wiki.mediati.org/R5u870"
license=('unknown')
depends=()
makedepends=()
provides=(r5u870)
conflicts=()
source=()
md5sums=() 
install=$pkgname.install

_svntrunk="http://svn.mediati.org/svn/r5u870/trunk"
_svnmod=r5u870

build() {
  cd $startdir/pkg
  mkdir lib
  cd lib
  mkdir firmware
   
  cd $startdir/src
  msg "Connecting to SVN server...."
  if [ -d $_svnmod/.svn ]; then
    (cd $_svnmod && svn up -r $pkgver)
  else
    svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod
  fi

  msg "SVN checkout done or server timeout"
  msg "Starting make..."
  svn export $_svnmod $_svnmod-build

 cd $startdir/src/r5u870
 sed -i 's/\/sbin\/depmod\ \-a/ /g' Makefile
   
cd $_svnmod-build
  #
  # BUILD
  #
               
  make || return 1
  make DESTDIR=$pkgdir FWDIR=$pkgdir/lib/firmware install || return 1
}

and the install:

# arg 1:  the new package version
post_install() {
  # updating module dependencies
  echo ">>> Updating module dependencies. Please wait ..."
  depmod -a > /dev/null 2>&1
  modprobe r5u870
  /bin/true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  # updating module dependencies
  echo ">>> Updating module dependencies. Please wait ..."
  depmod -a > /dev/null 2>&1
  modprobe r5u870
  /bin/true
}

# arg 1:  the old package version
post_remove() {
  # updating module dependencies
  echo ">>> Updating module dependencies. Please wait ..."
  KERNEL_VERSION=2.6.25-ARCH
  depmod -a > /dev/null 2>&1
  /bin/true
}

op=$1
shift
$op $*

I know it's messy. my first real attempt. any help at cleaning up that mkdir at the top of build{ couldn't seem to get to work any other way, would be appreciated.


Kudos? praise? criticisms? lambastes?

Offline

#7 2008-06-16 15:45:00

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: Criticisms? First package for r5u870-svn

Here's how I would do it... Also you may waqnt to take a look at /usr/share/pacman/PKGBUILD-svn.proto

  #cd $startdir/pkg
  #mkdir lib
  #cd lib
  #mkdir firmware
  install -d $pkgdir/lib/firmware # Preferred method
  mkdir -p $pkgdir/lib/firmware # Works too
 
  cd $srcdir # Preferred
 sed -i 's#/sbin/depmod\ \-a# #g' Makefile # Sed s/// gives ugly escapes

and the install:

# arg 1:  the new package version
post_install() {
  # updating module dependencies
  echo ">>> Updating module dependencies. Please wait ..."
  depmod -a > /dev/null 2>&1
  modprobe r5u870
  /bin/true
}

post_upgrade() {
  echo ">>> Updating module dependencies. Please wait ..."
  depmod -a > /dev/null 2>&1
  #modprobe r5u870 # Do not autoload, leave it to the user
  /bin/true
}

post_remove() {
  echo ">>> Updating module dependencies. Please wait ..."
  KERNEL_VERSION=$(uname -r) # Less maintenance
  depmod -a > /dev/null 2>&1
  /bin/true
}

# This is no longer needed
#op=$1
#shift
#$op $*

Offline

Board footer

Powered by FluxBB