[buildout]
extends =
  ../cpio/buildout.cfg
  ../rpm2cpio/buildout.cfg

parts =
  libreoffice-bin

[libreoffice-bin]
recipe = slapos.recipe.build
version = 7.5.2.2
url = https://downloadarchive.documentfoundation.org/libreoffice/old/${:version}/rpm/${:_url1}/LibreOffice_${:version}_${:_url2}_rpm.tar.gz

# where office code can be found?
officedir = libreoffice7.5
install =
  import os
  import sys
  workdir = guessworkdir(self.extract(self.download()))
  storagedir = os.path.join(workdir, 'storage')
  os.mkdir(storagedir)
  rpmsdir = os.path.join(workdir, 'RPMS')
  for q in os.listdir(rpmsdir):
    if q.endswith('.rpm') and 'javafilter' not in q and 'xsltfilter' not in q:
      self.pipeCommand((
        (sys.executable, options['rpm2cpio'], os.path.join(rpmsdir, q)),
        (options['cpio'], '-idum'),
      ), cwd=storagedir)
  self.copyTree(os.path.join(storagedir, 'opt', options['officedir']),
                location, ['ure-link'])
  os.symlink('ure', os.path.join(location, 'ure-link'))
  # backward compatibility for cloudooo configuration
  os.mkdir(os.path.join(location, 'basis-link'))
  os.symlink(os.path.join('..', 'program'),
             os.path.join(location, 'basis-link', 'program'))

# helper binaries
cpio = ${cpio:location}/bin/cpio
rpm2cpio = ${rpm2cpio:target}

[libreoffice-bin:getattr(sys,'_multiarch',None)!='x86_64-linux-gnu']
recipe = plone.recipe.command
command =
  echo unsupported architecture
  false
stop-on-error = true

[libreoffice-bin:getattr(sys,'_multiarch',None)=='x86_64-linux-gnu']
_url1 = x86_64
_url2 = Linux_x86-64
md5sum = efb0351ac9ebd954c43f77d59632bd28
