public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-arch/zstd/files/, app-arch/zstd/
Date: Fri, 10 Mar 2023 12:24:26 +0000 (UTC)	[thread overview]
Message-ID: <1678451046.0d9fc63ebed2c44bb7912aab9b457c2f3b66b6c5.sam@gentoo> (raw)

commit:     0d9fc63ebed2c44bb7912aab9b457c2f3b66b6c5
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 10 12:24:06 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Mar 10 12:24:06 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0d9fc63e

app-arch/zstd: backport crash fix

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../zstd/files/zstd-1.5.4-crash-no-directory.patch | 115 +++++++++++++++++++++
 app-arch/zstd/zstd-1.5.4-r3.ebuild                 |  80 ++++++++++++++
 2 files changed, 195 insertions(+)

diff --git a/app-arch/zstd/files/zstd-1.5.4-crash-no-directory.patch b/app-arch/zstd/files/zstd-1.5.4-crash-no-directory.patch
new file mode 100644
index 000000000000..d64e1c1d34f0
--- /dev/null
+++ b/app-arch/zstd/files/zstd-1.5.4-crash-no-directory.patch
@@ -0,0 +1,115 @@
+https://github.com/facebook/zstd/issues/3523
+https://github.com/facebook/zstd/pull/3541
+
+From 50e8f55e7d5928af9c3411afdb4fbedb4d8f770d Mon Sep 17 00:00:00 2001
+From: "W. Felix Handte" <w@felixhandte.com>
+Date: Thu, 9 Mar 2023 12:46:37 -0500
+Subject: [PATCH 1/3] Fix Python 3.6 Incompatibility in CLI Tests
+
+--- a/tests/cli-tests/run.py
++++ b/tests/cli-tests/run.py
+@@ -535,7 +535,8 @@ def _run_script(self, script: str, cwd: str) -> None:
+             subprocess.run(
+                 args=[script],
+                 stdin=subprocess.DEVNULL,
+-                capture_output=True,
++                stdout=subprocess.PIPE,
++                stderr=subprocess.PIPE,
+                 cwd=cwd,
+                 env=env,
+                 check=True,
+
+From c4c3e11958aed4dc99ec22e3d31c405217575a8c Mon Sep 17 00:00:00 2001
+From: "W. Felix Handte" <w@felixhandte.com>
+Date: Thu, 9 Mar 2023 12:47:40 -0500
+Subject: [PATCH 2/3] Avoid Calling `setvbuf()` on Null File Pointer
+
+--- a/programs/fileio.c
++++ b/programs/fileio.c
+@@ -644,18 +644,24 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
+ #endif
+         if (f == NULL) {
+             DISPLAYLEVEL(1, "zstd: %s: %s\n", dstFileName, strerror(errno));
++        } else {
++            /* An increased buffer size can provide a significant performance
++             * boost on some platforms. Note that providing a NULL buf with a
++             * size that's not 0 is not defined in ANSI C, but is defined in an
++             * extension. There are three possibilities here:
++             * 1. Libc supports the extended version and everything is good.
++             * 2. Libc ignores the size when buf is NULL, in which case
++             *    everything will continue as if we didn't call `setvbuf()`.
++             * 3. We fail the call and execution continues but a warning
++             *    message might be shown.
++             * In all cases due execution continues. For now, I believe that
++             * this is a more cost-effective solution than managing the buffers
++             * allocations ourselves (will require an API change).
++             */
++            if (setvbuf(f, NULL, _IOFBF, 1 MB)) {
++                DISPLAYLEVEL(2, "Warning: setvbuf failed for %s\n", dstFileName);
++            }
+         }
+-        /* An increased buffer size can provide a significant performance boost on some platforms.
+-         * Note that providing a NULL buf with a size that's not 0 is not defined in ANSI C, but is defined
+-         * in an extension. There are three possibilities here -
+-         * 1. Libc supports the extended version and everything is good.
+-         * 2. Libc ignores the size when buf is NULL, in which case everything will continue as if we didn't
+-         *    call `setvbuf`.
+-         * 3. We fail the call and execution continues but a warning message might be shown.
+-         * In all cases due execution continues. For now, I believe that this is a more cost-effective
+-         * solution than managing the buffers allocations ourselves (will require an API change). */
+-        if(setvbuf(f, NULL, _IOFBF, 1 MB))
+-            DISPLAYLEVEL(2, "Warning: setvbuf failed for %s\n", dstFileName);
+         return f;
+     }
+ }
+
+From 957a0ae52d0f49eccd260a22ceb5f5dfed064e9f Mon Sep 17 00:00:00 2001
+From: "W. Felix Handte" <w@felixhandte.com>
+Date: Thu, 9 Mar 2023 12:48:11 -0500
+Subject: [PATCH 3/3] Add CLI Test
+
+--- /dev/null
++++ b/tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh
+@@ -0,0 +1,12 @@
++#!/bin/sh
++
++# motivated by issue #3523
++
++datagen > file
++mkdir out
++chmod 000 out
++
++zstd file -q --trace-file-stat -o out/file.zst
++zstd -tq out/file.zst
++
++chmod 777 out
+--- /dev/null
++++ b/tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh.stderr.exact
+@@ -0,0 +1,26 @@
++Trace:FileStat: > UTIL_isLink(file)
++Trace:FileStat: < 0
++Trace:FileStat: > UTIL_isConsole(2)
++Trace:FileStat: < 0
++Trace:FileStat: > UTIL_getFileSize(file)
++Trace:FileStat:  > UTIL_stat(-1, file)
++Trace:FileStat:  < 1
++Trace:FileStat: < 65537
++Trace:FileStat: > UTIL_stat(-1, file)
++Trace:FileStat: < 1
++Trace:FileStat: > UTIL_isDirectoryStat()
++Trace:FileStat: < 0
++Trace:FileStat: > UTIL_stat(-1, file)
++Trace:FileStat: < 1
++Trace:FileStat: > UTIL_isSameFile(file, out/file.zst)
++Trace:FileStat:  > UTIL_stat(-1, file)
++Trace:FileStat:  < 1
++Trace:FileStat:  > UTIL_stat(-1, out/file.zst)
++Trace:FileStat:  < 0
++Trace:FileStat: < 0
++Trace:FileStat: > UTIL_isRegularFile(out/file.zst)
++Trace:FileStat:  > UTIL_stat(-1, out/file.zst)
++Trace:FileStat:  < 0
++Trace:FileStat: < 0
++zstd: out/file.zst: Permission denied
++zstd: can't stat out/file.zst : Permission denied -- ignored 
+

diff --git a/app-arch/zstd/zstd-1.5.4-r3.ebuild b/app-arch/zstd/zstd-1.5.4-r3.ebuild
new file mode 100644
index 000000000000..a74b317a3e8d
--- /dev/null
+++ b/app-arch/zstd/zstd-1.5.4-r3.ebuild
@@ -0,0 +1,80 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit meson-multilib usr-ldscript
+
+DESCRIPTION="zstd fast compression library"
+HOMEPAGE="https://facebook.github.io/zstd/"
+# Drop .gh on next bump (>1.5.4), it's only here as we switched to release
+# tarball.
+SRC_URI="https://github.com/facebook/zstd/releases/download/v${PV}/${P}.tar.gz -> ${P}.gh.tar.gz"
+S="${WORKDIR}"/${P}/build/meson
+
+LICENSE="|| ( BSD GPL-2 )"
+SLOT="0/1"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="+lzma lz4 static-libs test zlib"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	lzma? ( app-arch/xz-utils )
+	lz4? ( app-arch/lz4:= )
+	zlib? ( sys-libs/zlib )
+"
+DEPEND="${RDEPEND}"
+
+MESON_PATCHES=(
+	# Workaround until Valgrind bugfix lands
+	"${FILESDIR}"/${PN}-1.5.4-no-find-valgrind.patch
+	# Allow building tests w/o programs (useful for multilib)
+	"${FILESDIR}"/${PN}-1.5.4-tests-no-programs.patch
+)
+
+PATCHES=(
+	# Fix build w/o zlib, bug #894058
+	"${FILESDIR}"/${P}-fix-no-zlib-build.patch
+	"${FILESDIR}"/${P}-crash-no-directory.patch
+)
+
+src_prepare() {
+	cd "${WORKDIR}"/${P} || die
+	default
+
+	cd "${S}" || die
+	eapply "${MESON_PATCHES[@]}"
+}
+
+multilib_src_configure() {
+	local native_file="${T}"/meson.${CHOST}.${ABI}.ini.local
+
+	# This replaces the no-find-valgrind patch once bugfix lands in a meson
+	# release + we can BDEPEND on it (https://github.com/mesonbuild/meson/pull/11372)
+	cat >> ${native_file} <<-EOF || die
+	[binaries]
+	valgrind='valgrind-falseified'
+	EOF
+
+	local emesonargs=(
+		-Ddefault_library=$(multilib_native_usex static-libs both shared)
+
+		$(meson_native_true bin_programs)
+		$(meson_native_true bin_contrib)
+		$(meson_use test bin_tests)
+
+		$(meson_native_use_feature zlib)
+		$(meson_native_use_feature lzma)
+		$(meson_native_use_feature lz4)
+
+		--native-file "${native_file}"
+	)
+
+	meson_src_configure
+}
+
+multilib_src_install() {
+	meson_src_install
+
+	multilib_is_native_abi && gen_usr_ldscript -a zstd
+}


             reply	other threads:[~2023-03-10 12:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 12:24 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-09-24 22:42 [gentoo-commits] repo/gentoo:master commit in: app-arch/zstd/files/, app-arch/zstd/ Sam James
2021-12-22  3:57 Sam James
2021-03-31  8:06 Mikle Kolyada
2019-11-20 15:49 Lars Wendler
2016-10-03 23:45 Matthias Maier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1678451046.0d9fc63ebed2c44bb7912aab9b457c2f3b66b6c5.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox