[buildout]
extends =
  ../librsync/buildout.cfg
  ../patch/buildout.cfg
parts =
  duplicity

[duplicity]
recipe = slapos.recipe.build
url = http://code.launchpad.net/duplicity/0.6-series/0.6.15/+download/duplicity-0.6.15.tar.gz
md5sum = 88f3c990f41fde86cd7d5af5a1bc7b81
patch = ${:_profile_base_location_}/duplicity-ipv6.patch 32c44816a9a59401e233ef622bf50223
script =
  import os
  import tempfile
  import sys
  workingdir = guessworkdir(self.extract(self.download(%(url)r, %(md5sum)r)))
  os.chdir(workingdir)
  self.applyPatchList('${:patch}', patch_binary='${patch:location}/bin/patch', patch_options='-p0', cwd=workingdir)
  call([sys.executable, os.path.join(workingdir, 'setup.py'),
       'build_ext',
       '--include-dirs', os.path.join('${librsync:location}', 'include'),
       '--library-dirs', os.path.join('${librsync:location}', 'lib'),
       '--rpath', os.path.join('${librsync:location}', 'lib')])
  call([sys.executable, os.path.join(workingdir, 'setup.py'),
        'install',
        '--prefix', %(location)r])
  os.chdir(os.path.join(%(location)r, 'bin'))
  paths = [os.path.join(%(location)r, 'lib', 'python%%s.%%s' %% sys.version_info[:2], 'site-packages')]
  from zc.buildout.easy_install import scripts
  scripts([('duplicity', '__builtin__', 'execfile')], [], sys.executable, '${buildout:bin-directory}', arguments='%%r' %% os.path.abspath('duplicity'), extra_paths=paths)
  scripts([('rdiffdir', '__builtin__', 'execfile')], [], sys.executable, '${buildout:bin-directory}', arguments='%%r' %% os.path.abspath('rdiffdir'), extra_paths=paths)
