# Contributor: Sheila Aman <sheila@vulpine.house>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=socat
pkgver=1.8.0.3
pkgrel=1
pkgdesc="Multipurpose relay for binary protocols"
# test  58 CHILDDEFAULT: child process default properties... FAILED:
# ./socat -t 0.1  -u exec:./procan -
options="!check"
url="http://www.dest-unreach.org/socat/"
arch="all"
license="GPL-2.0-only WITH OpenSSL-Exception"
makedepends="openssl-dev>3 readline-dev linux-headers"
checkdepends="bash"
subpackages="$pkgname-doc $pkgname-scripts"
source="http://www.dest-unreach.org/socat/download/socat-$pkgver.tar.gz
	use-linux-headers.patch
	netdb-internal.patch
	"

# secfixes:
#   0:
#     - CVE-2024-54661

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr
	make
}

check() {
	make test
}

doc() {
	default_doc
	mkdir -p "$subpkgdir"/usr/share/socat/
	install -m644 "$builddir"/EXAMPLES "$builddir"/doc/*.html "$builddir"/doc/*.css "$subpkgdir"/usr/share/"$pkgname"/
}

package() {
	make DESTDIR="$pkgdir" install
}

scripts() {
	pkgdesc="$pkgdesc (helper scripts)"
	depends="$pkgname=$pkgver-r$pkgrel bash"

	amove usr/bin/socat-*.sh
}

sha512sums="
600a3387e9756e0937d2db49de9066df03d9818e4042da6b72109d1b5688dd72352754773a19bd2558fe93ec6a8a73e80e7cf2602fd915960f66c403fd89beef  socat-1.8.0.3.tar.gz
2032b6528cb27b69d8fb6a6f64af32fcc1f6e4934bb0d7c8931b38ab7ad5e27f6f4344a6cf49751fa3178cd725f954e195373362f7d5929e587d7f0309346059  use-linux-headers.patch
22a6e0c2317a9317997c98114daac258ebbcc3d8e58e49a6ebf24781b98967afed47c63807282582fa0909076fe349281f05e4462faacb90e7aabc853903d6e6  netdb-internal.patch
"
