version: 1.0.10
git_url:  https://github.com/hlandau/svcutils.git
git_hash: c25dac49e50cbbcbef8c81b089f56156f4067729
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  container:
    use_container: 1
  go_lib: gopkg.in/hlandau/svcutils.v1
  go_lib_install:
    - gopkg.in/hlandau/svcutils.v1
    - gopkg.in/hlandau/svcutils.v1/caps
    - gopkg.in/hlandau/svcutils.v1/chroot
    - gopkg.in/hlandau/svcutils.v1/dupfd
    - gopkg.in/hlandau/svcutils.v1/exepath
    - gopkg.in/hlandau/svcutils.v1/passwd
    - gopkg.in/hlandau/svcutils.v1/pidfile
    - gopkg.in/hlandau/svcutils.v1/setuid
    - gopkg.in/hlandau/svcutils.v1/systemd
  build_go_lib_pre: |
    [% pc(c('var/compiler'), 'var/setup', {
      compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')),
      hardened_gcc => c('var/container/suite') != 'buster'
    }) %]

    tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
    export PATH="/var/tmp/dist/binutils/bin:$PATH"

    export CGO_ENABLED=1

    [% IF c("var/linux-cross") %]
      # libcap includes
      mkdir -p /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/include/sys/
      cp /usr/include/sys/capability.h /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/include/sys/

      # libcap libraries
      cp /lib/[% c("var/crosstarget") %]/libcap.* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/
      cp /usr/lib/[% c("var/crosstarget") %]/libcap.* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/
      [% IF c("var/linux-arm") %]
        cp /lib/[% c("var/crosstarget") %]/libattr.* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/
      [% END %]

      # libcap search paths
      export CGO_LDFLAGS="$CGO_LDFLAGS -Wl,-rpath-link=/var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/"

      [% IF c("var/linux-ppc64le") %]
        # GCC's cc1 expects Jessie libmpfr; we feed it a symlink to Buster's instead
        # as a stupid compat cludge.  TODO: Maybe copy in the actual Jessie version
        # from the GCC build container?
        mkdir -p /var/tmp/dist/libmpfr
        ln -s -T /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /var/tmp/dist/libmpfr/libmpfr.so.4
        export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/var/tmp/dist/libmpfr"
      [% END %]
    [% END %]

targets:
  linux:
    var:
      arch_deps:
        - 'libcap-dev:[% c("var/arch_debian") %]'
  linux-ppc64le:
    var:
      container:
        use_container: 1
        suite: buster
        arch: amd64
      # Disable hardening-wrapper since it doesn't exist for buster
      deps:
        - libc6-dev-i386
        - lib32stdc++6
        - build-essential
        - python
        - bison
        - automake
        - libtool
        - zip
        - unzip

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
  - name: binutils
    project: binutils
