From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1409023-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 0DF8A158091
	for <garchives@archives.gentoo.org>; Thu, 16 Jun 2022 15:30:59 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 50BD8E07D3;
	Thu, 16 Jun 2022 15:30:58 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 392A3E07D3
	for <gentoo-commits@lists.gentoo.org>; Thu, 16 Jun 2022 15:30:58 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 60DE334203F
	for <gentoo-commits@lists.gentoo.org>; Thu, 16 Jun 2022 15:30:57 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id AA95A3C3
	for <gentoo-commits@lists.gentoo.org>; Thu, 16 Jun 2022 15:30:55 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1655393146.1ae31721af31ad1eff932f9de790e2584fdd3a9f.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: app-arch/zstd/
X-VCS-Repository: repo/gentoo
X-VCS-Files: app-arch/zstd/zstd-1.5.1-r3.ebuild
X-VCS-Directories: app-arch/zstd/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 1ae31721af31ad1eff932f9de790e2584fdd3a9f
X-VCS-Branch: master
Date: Thu, 16 Jun 2022 15:30:55 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 53fdf0da-cdd2-46da-9498-b1143766cc9f
X-Archives-Hash: 220fd860ec9cd40b7a3007f2c716afda

commit:     1ae31721af31ad1eff932f9de790e2584fdd3a9f
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 16 15:25:44 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 16 15:25:46 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1ae31721

app-arch/zstd: add split-usr support

Done with some reluctance, as I don't really want to be introducing more of
these, but it blocks being able to turn on zstd by default safely in kmod,
and it's a simple enough fix that I can't justify breaking things - it'd
be gratuitious.

Not tested on a split-usr system though, so it's really best-effort.

(split-usr being "/usr is a separate partition and therefore libraries
need to be in /$(get_libdir) for boot to bring it up", and not anything
to do with "merged-usr").

Closes: https://bugs.gentoo.org/771078
Signed-off-by: Sam James <sam <AT> gentoo.org>

 app-arch/zstd/zstd-1.5.1-r3.ebuild | 81 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/app-arch/zstd/zstd-1.5.1-r3.ebuild b/app-arch/zstd/zstd-1.5.1-r3.ebuild
new file mode 100644
index 000000000000..83b2103a30b0
--- /dev/null
+++ b/app-arch/zstd/zstd-1.5.1-r3.ebuild
@@ -0,0 +1,81 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit multilib-minimal toolchain-funcs usr-ldscript
+
+DESCRIPTION="zstd fast compression library"
+HOMEPAGE="https://facebook.github.io/zstd/"
+SRC_URI="https://github.com/facebook/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="|| ( BSD GPL-2 )"
+SLOT="0/1"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="lz4 static-libs split-usr +threads"
+
+RDEPEND="app-arch/xz-utils
+	lz4? ( app-arch/lz4 )"
+DEPEND="${RDEPEND}"
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-1.5.1-respect-CFLAGS.patch
+)
+
+src_prepare() {
+	default
+	multilib_copy_sources
+}
+
+mymake() {
+	# We need to turn off asm for certain arches (!amd64) for now.
+	# - bug #829849
+	# - https://bugzilla.redhat.com/show_bug.cgi?id=2035802
+	# - https://github.com/facebook/zstd/issues/2963
+	local asm="ZSTD_NO_ASM=1"
+
+	if use amd64 && [[ ${ABI} == amd64 ]] ; then
+		asm=
+	fi
+
+	emake \
+		CC="$(tc-getCC)" \
+		CXX="$(tc-getCXX)" \
+		AR="$(tc-getAR)" \
+		PREFIX="${EPREFIX}/usr" \
+		LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
+		V=1 \
+		${asm} \
+		"${@}"
+}
+
+multilib_src_compile() {
+	local libzstd_targets=( libzstd{,.a}$(usex threads '-mt' '') )
+
+	mymake -C lib ${libzstd_targets[@]} libzstd.pc
+
+	if multilib_is_native_abi ; then
+		mymake HAVE_LZ4="$(usex lz4 1 0)" zstd
+
+		mymake -C contrib/pzstd
+	fi
+}
+
+multilib_src_install() {
+	mymake -C lib DESTDIR="${D}" install
+
+	if multilib_is_native_abi ; then
+		mymake -C programs DESTDIR="${D}" install
+		gen_usr_ldscript -a zstd
+
+		mymake -C contrib/pzstd DESTDIR="${D}" install
+	fi
+}
+
+multilib_src_install_all() {
+	einstalldocs
+
+	if ! use static-libs; then
+		find "${ED}" -name "*.a" -delete || die
+	fi
+}