# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>

pkgbase=podman
pkgname=(podman podman-docker)
pkgver=5.2.5
pkgrel=1
pkgdesc='Tool and library for running OCI-based containers in pods'
arch=(x86_64 powerpc64le riscv64)
url='https://github.com/containers/podman'
license=(Apache-2.0)
makedepends=(
  apparmor
  btrfs-progs
  catatonit
  git
  go
  go-md2man
  gpgme
  libseccomp
  man-db
  shadow
  systemd
)
# https://github.com/containers/podman/issues/13297
options=(!lto)
source=(
  "git+$url?signed#tag=v$pkgver"
)
# See the release-keys repository
# https://github.com/containers/release-keys
validpgpkeys=(
  B7DBDCA456F7335E91F1C25CD3624C551D0515C4  # Matthew Heon <mheon@redhat.com>
  7CE1E6F8C90CB53E7E4D8F2D502E08DB0BBF8EEE  # Ashley Cui <acui@redhat.com>
  9E33DD8704CC03E2DEB84D9A1C1EDD7CC7C3A0DD  # Lokesh Mandvekar <lsm5@redhat.com>
)
sha256sums=('22afdc76311ec0696390724b0ce4a33d79973f9b2c8138f3d0c5403a4a3cd30c')

build() {
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie"
  export GOPATH="${srcdir}"

  make -j1 EXTRA_LDFLAGS='-compressdwarf=false -linkmode=external' PREFIX=/usr -C $pkgbase
  make docker-docs -C $pkgbase
}

package_podman() {
  depends=(
    catatonit
    conmon
    containers-common
    oci-runtime
    gcc-libs
    glibc
    iptables
    gpgme libgpgme.so
    libseccomp libseccomp.so
    passt
    shadow
  )
  optdepends=(
    'apparmor: for AppArmor support'
    'btrfs-progs: support btrfs backend devices'
    'cni-plugins: for an alternative container-network-stack implementation'
    'fuse-overlayfs: for storage driver in rootless environment'
    'slirp4netns: for alternative rootless network support'
    'podman-compose: for docker-compose compatibility'
    'podman-docker: for Docker-compatible CLI'
  )

  make install install.completions DESTDIR="$pkgdir" PREFIX=/usr LIBEXECDIR=/usr/lib -C $pkgbase
}

package_podman-docker() {
  pkgdesc='Emulate Docker CLI using podman'
  depends=(
    podman
    sh
  )
  conflicts=(docker)
  provides=(docker)

  make -j1 install.docker-full DESTDIR="$pkgdir" PREFIX=/usr -C $pkgbase
}
