commit:     22722d7ae735b3a95137a217d92b7923032dfaa7
Author:     Brahmajit Das <listout <AT> listout <DOT> xyz>
AuthorDate: Sun Jul 27 18:27:52 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 28 15:50:12 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=22722d7a

app-arch/lrzip: fix incorrect use of shell commands in handmade

Closes: https://bugs.gentoo.org/923990
Signed-off-by: Brahmajit Das <listout <AT> listout.xyz>
Part-of: https://github.com/gentoo/gentoo/pull/43192
Closes: https://github.com/gentoo/gentoo/pull/43192
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...correct-use-of-shell-commands-in-handmade.patch | 51 ++++++++++++++++++++
 app-arch/lrzip/lrzip-0.651-r1.ebuild               | 56 ++++++++++++++++++++++
 2 files changed, 107 insertions(+)

diff --git 
a/app-arch/lrzip/files/fix-incorrect-use-of-shell-commands-in-handmade.patch 
b/app-arch/lrzip/files/fix-incorrect-use-of-shell-commands-in-handmade.patch
new file mode 100644
index 000000000000..330b5f478874
--- /dev/null
+++ b/app-arch/lrzip/files/fix-incorrect-use-of-shell-commands-in-handmade.patch
@@ -0,0 +1,51 @@
+https://github.com/ckolivas/lrzip/commit/dc6342ea6151544d1cb8d0d366a97e34ec34e9c6
+From: Eli Schwartz <[email protected]>
+Date: Thu, 6 Feb 2025 10:53:48 -0500
+Subject: [PATCH] build: fix incorrect use of shell commands in handmade
+ libtool file
+
+The "echo" command was soft-deprecated from the shell programming
+language in ~1992. There is no way to use it correctly if:
+
+- the "-e" or "-n" or "-E" or any other options are used
+- backslash escape sequences are used
+- the printed string contains shell variables containing either of the
+  above
+
+In recognition of the fact that echo was historically used in many
+scripts, some of which avoided these issues and therefore succeeded when
+run, the "echo" command was NOT marked as obsolescent, out of fear that
+marking it as obsolescent would lead to vendors removing "echo" entirely
+and breaking existing scripts (or at least, the subset of scripts which
+managed to work correctly).
+
+However, it is warned against, that after 1992 you should avoid writing
+new code that uses "echo" and instead use "printf".
+
+printf has an actual definition of its behavior, which echo did not, and
+that behavior is to interpret backslash escapes in the first parameter,
+which is necessary by this Makefile.am in order to embed newlines into
+the generated libtool file. Simply replacing "echo -e" with "printf"
+will therefore correctly and reliably do the intended functionality. We
+also add one final embedded newline to avoid producing a file without an
+end-of-line character on the last line of the file.
+
+Fixes: https://github.com/ckolivas/lrzip/issues/257
+Signed-off-by: Eli Schwartz <[email protected]>
+--- a/lzma/C/Makefile.am
++++ b/lzma/C/Makefile.am
+@@ -53,11 +53,12 @@ liblzma_la_LIBADD = $(ASM_7z).lo
+ \n\# Generated by libtool -- hack to allow asm linking\
+ \n\# Peter Hyman\
+ \npic_object='.libs/$(ASM_7z).o'\
+-\nnon_pic_object='$(ASM_7z).o'
++\nnon_pic_object='$(ASM_7z).o'\
++\n
+ 
+ $(ASM_7z).lo: $(ASM_S)
+       $(ASM_PROG) $(ASM_OPT) -o $(ASM_7z).o $(ASM_S)
+       mkdir -p .libs
+       cp $(ASM_7z).o .libs/
+-      @echo -e "$(7ZIPASMLOFILE)" > $(ASM_7z).lo
++      @printf "$(7ZIPASMLOFILE)" > $(ASM_7z).lo
+ endif

diff --git a/app-arch/lrzip/lrzip-0.651-r1.ebuild 
b/app-arch/lrzip/lrzip-0.651-r1.ebuild
new file mode 100644
index 000000000000..08d34cf163c7
--- /dev/null
+++ b/app-arch/lrzip/lrzip-0.651-r1.ebuild
@@ -0,0 +1,56 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools
+
+DESCRIPTION="Long Range ZIP or Lzma RZIP optimized for compressing large files"
+HOMEPAGE="https://github.com/ckolivas/lrzip";
+SRC_URI="https://github.com/ckolivas/lrzip/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv 
~s390 ~sparc ~x86 ~ppc-macos ~x64-macos ~x64-solaris"
+IUSE="static-libs"
+
+RDEPEND="app-arch/bzip2
+       app-arch/lz4
+       dev-libs/lzo
+       sys-libs/zlib"
+DEPEND="${RDEPEND}"
+BDEPEND="dev-perl/Pod-Parser
+       amd64? ( dev-lang/nasm )
+       x86? ( dev-lang/nasm )"
+
+PATCHES=(
+       # Bug #923990, not required in >0.651
+       "${FILESDIR}/fix-incorrect-use-of-shell-commands-in-handmade.patch"
+)
+
+src_prepare() {
+       default
+
+       eautoreconf
+}
+
+src_configure() {
+       # ASM optimizations are only available on amd64 and x86, bug #829003
+       local asm=no
+       if use amd64 || use x86; then
+               asm=yes
+       fi
+
+       econf \
+               $(use_enable static-libs static) \
+               --enable-asm=${asm}
+}
+
+src_install() {
+       default
+       # Don't collide with net-dialup/lrzsz and /usr/bin/lrz, bug #588206
+       rm -f "${ED}"/usr/bin/lrz || die
+       rm -f "${ED}"/usr/share/man/man1/lrz.* || die
+
+       find "${ED}" -name '*.la' -delete || die
+}

Reply via email to