# Compiling Time: 0.39 SBU
# Maintainer: James Buren <ryuo@frugalware.org>
# Contributor: Miklos Vajna <vmiklos@frugalware.org>

USE_DEBUG=${USE_DEBUG:-"n"}
USE_MINIMAL=${USE_MINIMAL:-"n"}

pkgname=pacman-g2
pkgver=3.9.4
pkgrel=63
pkgdesc="A .tar.xz based package manager library (libpacman) and client (pacman-g2) with dependency support."
url="https://ftp.frugalware.org/pub/other/pacman-g2/"
backup=(etc/{makepkg,pacman-g2}.conf etc/pacman-g2/repos/frugalware-current etc/makepkg.d/current-makepkg.conf)
depends=('libarchive>=3.3.2' 'glibc>=2.36' 'grep>=2.5.3-4' 'util-linux>=2.28.2-2' \
	'nettle>=3.5.1' 'xz>=5.2.2-4' 'lz4>=r131-8' 'openssl>=3.0.7' 'zstd' 'python3>=3.13')
rodepends=('shadow' 'diffutils' 'coreutils' 'libeatmydata')
makedepends+=('perl>=5.42' 'zlib-ng-static' 'lz4-static' 'libarchive-static' 'glibc-devel' 'gettext' \
	'xz-static' 'nettle-static' 'bzip2-static' 'expat-static' 'openssl-static'  'zstd-static')
## not sure why it needs nettle ?:( nettle is in chroot-core so something else need it
if ! Fuse $USE_MINIMAL; then
	## temporarily disable some makedepends
	makedepends+=('doxygen>=1.7.3-1' 'po4a' 'swig' \
	'asciidoc' 'perl-yaml-tiny' 'docbook-xsl' 'docbook-xml' 'sgml-common' \
	'lzo>=2.09-6' 'lz4>=r131-8' 'vala' 'gcc>=12.2')
	options+=('scriptlet')
	_Fbuild_no_patch=yes
fi
groups=('base' 'chroot-core')
archs=('x86_64')
_F_archive_nosort=y
up2date="Flasttar $url/releases/"
source=($url/releases/$pkgname-$pkgver.tar.gz \
	git.patch \
	makepkg-no-lto-fix.patch \
	python.patch \
	perl.patch \
	fix-tests.patch \
	allow-share-pkgconfig.patch \
	0001-systemd-now-installs-everything-into-usr.patch \
	0001-check-for-TERM-before-trying-to-use-tput.patch \
	0002-fix-test.patch \
	usr-merge.patch \
	0003-allow-checking-files-with-spaces-in-symbolic-links-c.patch
	raise-generic-opt-lvl-to-x86-64-v2.patch \
	default-link-with-mold.patch \
	enable-libeatmydata.patch \
	fix-path.patch \
	fix-fuse-ld-with-clang.patch \
	use-gpgv-to-verify-signatures.patch \
	use-gpgv-to-verify-signatures-2.patch \
	use-sqv-instead-of-gpg.patch \
	use-sqv-directly.patch \
	check-for-sqv.patch \
	use-sqopv-since-it-supports-reading-from-stdin.patch \
	orphans \
	foreign)
sha1sums=('9fa3eeb77a3e53e4481c9a64beda32dc44775440' \
          '534ad959a052038c180df10f730f530126e3b94d' \
          '35d4bee203626b9bf2e7d8cf60f0fc08b7fef650' \
          'aedbe05f6a7d83189eb54d085390fdff5cbebf98' \
          '86dcd78a9a502ed68bc97c6225ab0804831066f3' \
          '9e2a40935527dc6bb5f356dbdfeb1fdb5a5318d1' \
          'fdcec88ef13362fa71be35fe7a04f6ce2cf778c9' \
          '0174a3ad4f2b43110ed6619a1957fce8949fd902' \
          'c75d25af76bb7dd2303f1e4c7a88a257a21a2466' \
          'd755e8326f11fb71f4fa37adb27290c04d3d5527' \
          'b95f1b222e8ce2563a36b1c70df88fb6e75a4c99' \
          'd3a6f3894e4c63c6c70c1e484e3b72df0c2c54c0' \
          '8a3ad2c2b1323f1631133365a204bcd0b5a201a5' \
          '0a5982e633cae3308d7ebed459dbdd7fa7d402a2' \
          '857e82ce07df5c1a1a7b085403a9aeb6e82da02f' \
          '4499af95a6a50916ca59d5e46ea548b4ca3e032a' \
          'de5a3905cd4e342d32f3a567365737bcab9ccd9f' \
          '18af57437201d805b1d200ff21fff59dabdcb019' \
          'c3747184f18979d7d41a51d5fac54385c12459b7' \
          '8ad65a1f0e75fdf64542980aa1e8e4869bc5f253' \
          '3d25f83dcfdbbe0230fac3162ead44b19fc41e0f' \
          '0d372560702b4c5c68de5f446180857d8feace5f' \
          'ab16a981d3f1db865ffd3e01fd37c439f0587b69' \
          '40d64b4306cd43a1f1396ce45449e0c895eb6e7d' \
          '9a4e3df9bca3c85c40c79c79e2ac9ab23eec9081')

if ! Fuse $USE_DEBUG; then
	Fconfopts+=" --disable-debug"
else
	Fconfopts+=" --enable-debug"
	options+=('nostrip')
fi

conflicts=('pacman-returns')
provides=('pacman-returns')

options+=('static' 'nowfsecurity')
_Fbuild_autoreconf=yes

#TODO: gcc11 defaults to no-common
CFLAGS+="	 -fcommon"

build()
{

	if Fuse $USE_MINIMAL; then
		Fbuild
	else
		Fcd
		Fpatchall
		Fautoreconf
		Fbuild
	fi
	Fexec make check || Fdie
	Finstall 0755 /etc/pacman-g2/hooks/foreign
	Finstall 0755 /etc/pacman-g2/hooks/orphans
}

# optimization OK
