Ufraw with Nikon D5100 and Archlinux

2012-10-10    Filed under photography, Tags nikon ufraw

In a past post I explained how to modify the Ufraw source code to support the Nikon D5100 SLR and create a Debian package. Now I show how to create a patched custom package for Archlinux, using the ABS (Archlinux Build System).

The general procedure is well explained in the ABS, Patching in ABS and PKGBUILD Archlinux wiki pages.

First, install the ABS and build utilities:

sudo pacman -S abs
sudo pacman -S base-devel

Configure the repositories that you want to be active and your name under PACKAGER directive in the files /etc/abs.conf and /etc/makepkg.conf

Download PKGBUILD for ufraw and create a copy in a working dir under your home dir:

pacman -Ss ufraw
sudo abs extra/gimp-ufraw
mkdir ~/abs
cp -r /var/abs/extra/gimp-ufraw ~/abs
cd ~/abs/extra/gimp-ufraw

Download the sources but without compiling them:

makepkg -o

Then make a copy of original sources in a parallel directory under src/. Modify (edit or copy from elsewhere) the sources in the copy:

cd src
cp -r ufraw-0.18 ufraw-0.18.new
cp ~/bin/ufraw-0.18/wb_presets.c ufraw-0.18.new
cp ~/bin/ufraw-0.18/dcraw.cc ufraw-0.18.new

Generate a patch file:

diff -aur ufraw-0.18 ufraw-0.18.new > ../gimp-ufraw.patch

Now edit file PKGBUILD to include the patch in the sources list, the md5sums and modify the build() function to apply the patch before compilation. This is how the PKGBUILD file looks after editing:

# [...]
source=(http://downloads.sourceforge.net/ufraw/ufraw-${pkgver}.tar.gz gimp-ufraw.patch)
md5sums=('454f40a402928998a82e2645d9265d96'
         '7e24ddc5e0bf6ddd24a9968419586ffe')
sha1sums=('41c9ad7aa7f1cbb63a6b0b330b3599b18a7e8cd2'
          '774bd13b4d9e3df7ffebcb46eb5a513ba25b6167')
build() {
  cd "${srcdir}/ufraw-${pkgver}"
  patch -Np1 -i ../gimp-ufraw.patch
  ./configure --prefix=/usr \
              --enable-extras \
              --enable-mime \
              --enable-openmp
  sed -i "s/-ffast-math -fomit-frame-pointer -W -Wall -O3/${CFLAGS}/" Makefile
  make
}

Finally, create the package with makepkg and install it:

makepkg -g
sudo pacman -U gimp-ufraw-d5100-0.18-5-x86_64.pkg.tar.xz