# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=skopeo
pkgver=1.18.0
pkgrel=2
# set this to the gitrev of the version
_gitrev=64361bde0687b2d8ae490fd9d7358a1e89d70e5b
pkgdesc="Work with remote images registries - retrieving information, images, signing content"
url="https://github.com/containers/skopeo"
license="Apache-2.0"
arch="all"
options="net !check" # needs docker
depends="containers-common"
makedepends="
	bash
	btrfs-progs-dev
	glib-dev
	go
	go-md2man
	gpgme-dev
	libselinux-dev
	linux-headers
	lvm2-dev
	ostree-dev
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/containers/skopeo/archive/v$pkgver/skopeo-$pkgver.tar.gz"

# secfixes:
#   1.15.1-r0:
#     - CVE-2024-3727
#   1.5.2-r0:
#     - CVE-2021-41190

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	# https://github.com/mattn/go-sqlite3/issues/1164
	export CGO_CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"

	make GIT_COMMIT=$_gitrev all
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" PREFIX=/usr install-docs install-completions
	install -Dm755 bin/skopeo -t "$pkgdir"/usr/bin/
}

sha512sums="
7d56d78b4e0299c187eb2ea46a2d6ac41a4ad30848e9f5fe43285af74c5207f6fc4ee98c15bd5114de7a660e52846f75c26632ae1aa3ccf656b504798a6b1d56  skopeo-1.18.0.tar.gz
"
