[buildout]

extends =
  ../attr/buildout.cfg

parts = libcap

[libcap2]
recipe = slapos.recipe.build
format = no
url = http://pkgs.fedoraproject.org/lookaside/pkgs/libcap/libcap-2.22.tar.bz2/ce64058bdb3f086ddbfca8ce6c919845/libcap-2.22.tar.bz2
md5sum = ce64058bdb3f086ddbfca8ce6c919845
attr-include = ${attr:location}/include/
attr-lib = ${attr:location}/lib/
slapos_promise =
  directory:sbin
  directory:usr/include
  statlib:lib/libcap.a
  file:lib/libcap.so
  file:sbin/getcap
  file:sbin/setcap
script =
  import os
  url = self.download(self.options['url'], self.options['md5sum'])
  extract_dir = self.extract(url)
  workdir = guessworkdir(extract_dir)
  cflags = '-I%(attr)s' % {'attr': self.options['attr-include']}
  ldflags = '-L%(attr)s -Wl,-rpath=%(attr)s' % {'attr': self.options['attr-lib']}
  call(['make', 'CFLAGS=%s' % cflags, 'LDFLAGS=%s' % ldflags, 'DESTDIR=%s' % self.options['location'], 'RAISE_SETFCAP=no', 'install'],
       cwd=workdir, env=env)
  lib64 = os.path.join(self.options['location'], 'lib64')
  lib = os.path.join(self.options['location'], 'lib')
  # XXX: Dirty if case
  #      if lib64 exists, then create a symlink from lib to lib64
  os.path.exists(lib64) and os.symlink(lib64, lib)

[libcap]
<= libcap2
