Github messages for voidlinux
 help / color / mirror / Atom feed
From: ericonr <ericonr@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [WIP] Remove libintl dependency from some packages
Date: Wed, 24 Mar 2021 03:37:46 +0100	[thread overview]
Message-ID: <20210324023746.Xo5cTdroqpAATnitvXADqtzIbDIcpnzSVehHZJUqw1g@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-29240@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

There is an updated pull request by ericonr against master on the void-packages repository

https://github.com/ericonr/void-packages gettext
https://github.com/void-linux/void-packages/pull/29240

[WIP] Remove libintl dependency from some packages
The initial commit explains most of the situation. Basically remove unnecessary / useless libintl dependency from some musl packages, where possible. Starting with packages I use myself and can test, would appreciate testing from others as well.

A patch file from https://github.com/void-linux/void-packages/pull/29240.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gettext-29240.patch --]
[-- Type: text/x-diff, Size: 15995 bytes --]

From 2073493de15cb08e369e4c2cc1d9bc4e77fc094b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 4 Mar 2021 18:31:38 -0300
Subject: [PATCH 1/6] gettext: reorganize so gettext-libs only ships versioned
 libintl.so.

Move unrelated libraries to gettext package, since they are only used by
it and by gtranslator, which will for the most part be installed
alongside gtranslator already.

The main purpose with this PR is to stop shipping unversioned libintl.so
in gettext-libs. What happens in this case is that packages built
natively for musl with localization support will have gettext in
hostmakedepends, which will lead to gettext-libs being in the host, and,
consequently, /usr/lib/libintl.so being available.

Due to CMake's FindIntl being bad, CMake projects will assume they
should use libintl.so instead of the gettext support from libc, and link
against it unnecessarily (and sometimes innefectively: CMake points the
compiler at /usr/include/libintl.h instead of our
/usr/include/gettext/libintl.h, which means the musl header will be used
instead, and unless the main executable is linked against libintl, the
library's functions won't even be used). Leaving only the essential
libraries in gettext-libs (versioned libintl.so files) and guaranteeing
gettext doesn't pull in the unversioned one means many packages won't
depend on libintl unnecessarily any more. As a matter of fact, this is a
case where our cross builds were more "correct" than native ones, since
libintl.so in the host won't be found for the target.

Furthermore, some packages require autopoint(1) in order to run
autoreconf; to avoid depending on gettext-devel for it, and ending up
linking in libintl into the final binary, we split it into the
gettext-devel-tools subpackage as well.

Also pull in Alpine patches fixing test failures.

gettext
---
 common/shlibs                                 |  9 ++--
 srcpkgs/gettext-devel-tools                   |  1 +
 srcpkgs/gettext/patches/musl-realpath.patch   | 41 ++++++++++++++++
 .../musl-unsupported-iconv-encoding.patch     | 44 +++++++++++++++++
 srcpkgs/gettext/template                      | 48 ++++++++++++++-----
 5 files changed, 127 insertions(+), 16 deletions(-)
 create mode 120000 srcpkgs/gettext-devel-tools
 create mode 100644 srcpkgs/gettext/patches/musl-realpath.patch
 create mode 100644 srcpkgs/gettext/patches/musl-unsupported-iconv-encoding.patch

diff --git a/common/shlibs b/common/shlibs
index 4b82c3ced654..7319cc8d20cb 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -176,11 +176,10 @@ libxfce4panel-2.0.so.4 libxfce4panel-4.12.0_1
 libgdbm.so.6 gdbm-1.16_1
 libgdbm_compat.so.4 gdbm-1.10_1_1
 libintl.so.8 gettext-libs-0.19.2_1
-libgnuintl.so.8 gettext-libs-0.19.2_1
-libgettextlib-0.21.so gettext-libs-0.21_1
-libgettextsrc-0.21.so gettext-libs-0.21_1
-libgettextpo.so.0 gettext-libs-0.17_1
-libtextstyle.so.0 gettext-libs-0.20.1_1
+libgettextlib-0.21.so gettext-0.21_3
+libgettextsrc-0.21.so gettext-0.21_3
+libtextstyle.so.0 gettext-0.21_3
+libgettextpo.so.0 gettext-0.21_3
 libattr.so.1 attr-2.4.43_1
 libacl.so.1 acl-2.2.47_1
 libpython2.7.so.1.0 python-2.7.18_3
diff --git a/srcpkgs/gettext-devel-tools b/srcpkgs/gettext-devel-tools
new file mode 120000
index 000000000000..d3a6700489c5
--- /dev/null
+++ b/srcpkgs/gettext-devel-tools
@@ -0,0 +1 @@
+gettext
\ No newline at end of file
diff --git a/srcpkgs/gettext/patches/musl-realpath.patch b/srcpkgs/gettext/patches/musl-realpath.patch
new file mode 100644
index 000000000000..75a650895e07
--- /dev/null
+++ b/srcpkgs/gettext/patches/musl-realpath.patch
@@ -0,0 +1,41 @@
+https://gitlab.alpinelinux.org/alpine/aports/-/issues/12295
+This patch is necessary only with musl after 1.2.2
+
+----
+test-canonicalize.c:339: assertion 'strcmp (result1, "/") == 0' failed
+Aborted (core dumped)
+FAIL test-canonicalize (exit status: 134)
+----
+
+diff --git a/gettext-tools/gnulib-tests/test-canonicalize-lgpl.c b/gettext-tools/gnulib-tests/test-canonicalize-lgpl.c
+index ff82981..17842e8 100644
+--- a/gettext-tools/gnulib-tests/test-canonicalize-lgpl.c
++++ b/gettext-tools/gnulib-tests/test-canonicalize-lgpl.c
+@@ -208,8 +208,8 @@ main (void)
+ #ifndef __MVS__
+     if (SAME_INODE (st1, st2))
+       {
+-        ASSERT (strcmp (result1, "/") == 0);
+-        ASSERT (strcmp (result2, "/") == 0);
++        ASSERT (strcmp (result1, "/") == 0 || strcmp (result1, "//") == 0);
++        ASSERT (strcmp (result2, "/") == 0 || strcmp (result2, "//") == 0);
+       }
+     else
+ #endif
+--- a/gettext-tools/gnulib-tests/test-canonicalize.c
++++ b/gettext-tools/gnulib-tests/test-canonicalize.c
+@@ -336,10 +336,10 @@
+     ASSERT (stat ("//", &st2) == 0);
+     if (SAME_INODE (st1, st2))
+       {
+-        ASSERT (strcmp (result1, "/") == 0);
+-        ASSERT (strcmp (result2, "/") == 0);
+-        ASSERT (strcmp (result3, "/") == 0);
+-        ASSERT (strcmp (result4, "/") == 0);
++        ASSERT (strcmp (result1, "/") == 0 || strcmp (result1, "//") == 0);
++        ASSERT (strcmp (result2, "/") == 0 || strcmp (result2, "//") == 0);
++        ASSERT (strcmp (result3, "/") == 0 || strcmp (result3, "//") == 0);
++        ASSERT (strcmp (result4, "/") == 0 || strcmp (result4, "//") == 0);
+       }
+     else
+       {
diff --git a/srcpkgs/gettext/patches/musl-unsupported-iconv-encoding.patch b/srcpkgs/gettext/patches/musl-unsupported-iconv-encoding.patch
new file mode 100644
index 000000000000..de9a6b02b3a4
--- /dev/null
+++ b/srcpkgs/gettext/patches/musl-unsupported-iconv-encoding.patch
@@ -0,0 +1,44 @@
+As upstream notes:
+
+# Note: This test fails on Linux with musl libc versions that don't support
+# the BIG5 encoding in 'iconv'.
+
+diff --git a/gettext-tools/tests/msgconv-2 b/gettext-tools/tests/msgconv-2
+index d286cda..d96c487 100755
+--- a/gettext-tools/tests/msgconv-2
++++ b/gettext-tools/tests/msgconv-2
+@@ -7,6 +7,8 @@
+ # Note: This test fails on Linux with musl libc versions that don't support
+ # the BIG5 encoding in 'iconv'.
+ 
++Exit 77
++
+ cat <<\EOF > mco-test2.po
+ # Chinese translation for GNU gettext messages.
+ #
+diff --git a/gettext-tools/tests/msgmerge-compendium-6 b/gettext-tools/tests/msgmerge-compendium-6
+index 0afbe1e..1b2fe6b 100755
+--- a/gettext-tools/tests/msgmerge-compendium-6
++++ b/gettext-tools/tests/msgmerge-compendium-6
+@@ -10,6 +10,8 @@
+ # Note: This test fails on Linux with musl libc versions that don't support
+ # the EUC-KR encoding in 'iconv'.
+ 
++Exit 77
++
+ : ${MSGCONV=msgconv}
+ ${MSGCONV} --to-code=UTF-8 -o mm-ko.utf-8.pot "$wabs_srcdir"/mm-ko.ascii.pot
+ 
+diff --git a/gettext-tools/tests/xgettext-python-3 b/gettext-tools/tests/xgettext-python-3
+index ca0926d..2c49fd7 100755
+--- a/gettext-tools/tests/xgettext-python-3
++++ b/gettext-tools/tests/xgettext-python-3
+@@ -6,6 +6,8 @@
+ # Note: This test fails on Linux with musl libc versions that don't support
+ # the EUC-JP encoding in 'iconv'.
+ 
++Exit 77
++
+ cat <<\EOF > xg-py-3a.py
+ #!/usr/bin/env python
+ # TRANSLATORS: Fran«®ois Pinard is a hero.
diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template
index 06079609ba0f..a41ff09d90e2 100644
--- a/srcpkgs/gettext/template
+++ b/srcpkgs/gettext/template
@@ -1,7 +1,7 @@
 # Template file for 'gettext'
 pkgname=gettext
 version=0.21
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-java --disable-native-java --disable-csharp
  --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
@@ -22,11 +22,20 @@ homepage="https://www.gnu.org/software/gettext/"
 changelog="https://git.savannah.gnu.org/cgit/gettext.git/plain/NEWS"
 distfiles="${GNU_SITE}/${pkgname}/${pkgname}-${version}.tar.gz"
 checksum=c77d0da3102aec9c07f43671e60611ebff89a996ef159497ce8e59d075786b12
+patch_args=-Np1
 
-case "$XBPS_TARGET_MACHINE" in
+subpackages="gettext-devel-examples gettext-devel gettext-devel-tools"
+unset _intl_lib
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
 	# force libintl
-	*-musl) configure_args+=" --with-included-gettext";;
-esac
+	configure_args+=" --with-included-gettext"
+	subpackages+=" gettext-libs"
+	_intl_lib=intl
+else
+	# on glibc, old gettext-libs conflicts with new one
+	replaces="gettext-libs>=0"
+	conflicts="gettext-libs>=0"
+fi
 
 if [ "$CROSS_BUILD" ]; then
 	hostmakedepends+=" automake libtool"
@@ -35,10 +44,9 @@ if [ "$CROSS_BUILD" ]; then
 	}
 fi
 
-
 post_install() {
-	# Fix conflict with musl.
-	if [ -e ${DESTDIR}/usr/include/libintl.h ]; then
+	# don't overwrite musl's header
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
 		vmkdir usr/include/gettext
 		mv ${DESTDIR}/usr/include/libintl.h ${DESTDIR}/usr/include/gettext/libintl.h
 	fi
@@ -50,22 +58,40 @@ gettext-devel-examples_package() {
 		vmove usr/share/doc/gettext
 	}
 }
+
 gettext-devel_package() {
-	depends="gettext-libs>=${version}_${revision} xz tar"
+	depends="gettext-devel-tools>=${version}_${revision} xz tar"
+	if [ -n "${_intl_lib}" ]; then
+		depends+=" gettext-libs>=${version}_${revision}"
+	fi
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
-		vmove usr/lib/*.a
-		vmove usr/share/aclocal
+		vmove "usr/lib/*.a"
+		# libgettext{lib,src}-$version.so need to be in the main package
+		for _lib in ${_intl_lib} gettextlib gettextpo gettextsrc textstyle
+		do
+			vmove "usr/lib/lib${_lib}.so"
+		done
 		vmove usr/share/gettext
 		vmove usr/share/man/man3
+	}
+}
+
+gettext-devel-tools_package() {
+	short_desc+=" - development tools"
+	pkg_install() {
+		vmove usr/share/aclocal
 		vmove usr/bin/autopoint
 		vmove usr/bin/gettextize
+		vmove usr/share/man/man1/autopoint.1
+		vmove usr/share/man/man1/gettextize.1
 	}
 }
+
 gettext-libs_package() {
 	short_desc+=" - shared libraries"
 	pkg_install() {
-		vmove usr/lib/*.so*
+		vmove "usr/lib/libintl.so.*"
 	}
 }

From 35e6541d7812a8bf347a4d7c0115934e7569eef6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 4 Mar 2021 18:46:28 -0300
Subject: [PATCH 2/6] gtranslator: revbump for gettext re-org.

---
 srcpkgs/gtranslator/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtranslator/template b/srcpkgs/gtranslator/template
index d0c49d1d778b..f9f9d0e3bc13 100644
--- a/srcpkgs/gtranslator/template
+++ b/srcpkgs/gtranslator/template
@@ -1,7 +1,7 @@
 # Template file for 'gtranslator'
 pkgname=gtranslator
 version=3.38.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="gettext pkg-config glib-devel itstool"
 makedepends="gettext-devel libglib-devel libdazzle-devel libsoup-devel

From 13bff1dc89ba03b25f543fc5a2c664699aa219b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 4 Mar 2021 18:53:22 -0300
Subject: [PATCH 3/6] fish: don't link against libintl.

---
 srcpkgs/fish-shell/template | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/fish-shell/template b/srcpkgs/fish-shell/template
index c39fd784c423..800a781f214e 100644
--- a/srcpkgs/fish-shell/template
+++ b/srcpkgs/fish-shell/template
@@ -1,11 +1,11 @@
 # Template file for 'fish-shell'
 pkgname=fish-shell
 version=3.2.1
-revision=1
+revision=2
 wrksrc="fish-${version}"
 build_style=cmake
 hostmakedepends="gettext"
-makedepends="ncurses-devel pcre2-devel gettext-devel"
+makedepends="ncurses-devel pcre2-devel"
 depends="groff"
 checkdepends="python3-pexpect procps-ng"
 short_desc="User friendly shell intended mostly for interactive use"
@@ -15,6 +15,8 @@ homepage="https://fishshell.com/"
 distfiles="https://github.com/fish-shell/fish-shell/releases/download/${version}/fish-${version}.tar.xz"
 checksum=d8e49f4090d3778df17dd825e4a2a80192015682423cd9dd02b6675d65c3af5b
 register_shell="/bin/fish /usr/bin/fish"
+# tests don't work as root
+make_check=extended
 
 if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
 	makedepends+=" libatomic-devel"

From 334f7b125bf089322c342de9497b4c457e837615 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 4 Mar 2021 22:40:16 -0300
Subject: [PATCH 4/6] inkscape: don't link against libintl for native builds.

---
 srcpkgs/inkscape/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/inkscape/template b/srcpkgs/inkscape/template
index dd549fae36c6..364f229dba30 100644
--- a/srcpkgs/inkscape/template
+++ b/srcpkgs/inkscape/template
@@ -1,13 +1,13 @@
 # Template file for 'inkscape'
 pkgname=inkscape
 version=1.0.2
-revision=1
+revision=2
 wrksrc="inkscape-${version}_2021-01-15_e86c870879"
 build_style=cmake
 # builds executables then runs checks
 # FIXME: some tests still fail on musl
 make_check_target=check
-hostmakedepends="automake pkg-config libtool intltool gettext-devel
+hostmakedepends="automake pkg-config libtool intltool gettext
  glib-devel perl-XML-Parser tar which xz"
 makedepends="harfbuzz-devel libsoup-devel gsl-devel pango-devel
  double-conversion-devel gc-devel libwpd-devel libcdr-devel libvisio-devel

From 5b15088f596dcc71ba2c932e2461a8f536981e1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 4 Mar 2021 23:07:39 -0300
Subject: [PATCH 5/6] gnutls: don't link against libintl in native builds.

Also remove autoreconf, not necessary for now when configure.ac isn't
being patched.
---
 srcpkgs/gnutls/template | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/gnutls/template b/srcpkgs/gnutls/template
index 681f6c7ca8cf..69c6ebecc7d3 100644
--- a/srcpkgs/gnutls/template
+++ b/srcpkgs/gnutls/template
@@ -1,13 +1,15 @@
 # Template file for 'gnutls'
 pkgname=gnutls
 version=3.6.15
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-zlib --disable-guile --disable-static
  --disable-valgrind-tests --disable-rpath
  --with-default-trust-store-file=/etc/ssl/certs/ca-certificates.crt
  --with-trousers-lib=${XBPS_CROSS_BASE}/usr/lib"
-hostmakedepends="automake gettext-devel libtool pkg-config which"
+hostmakedepends="gettext libtool pkg-config which"
+# for autoreconf
+#hostmakedepends+=" gettext-devel-tools automake"
 makedepends="zlib-devel lzo-devel readline-devel libgpg-error-devel
  libtasn1-devel libgcrypt-devel p11-kit-devel nettle-devel libidn2-devel
  libunistring-devel unbound-devel trousers-devel"
@@ -19,10 +21,6 @@ homepage="https://gnutls.org"
 distfiles="https://www.gnupg.org/ftp/gcrypt/gnutls/v${version%.*}/gnutls-${version}.tar.xz"
 checksum=0ea8c3283de8d8335d7ae338ef27c53a916f15f382753b174c18b45ffd481558
 
-pre_configure() {
-	autoreconf -vfi
-}
-
 pre_check() {
 	# same as $PASS in tests/cert-tests/certtool
 	export GNUTLS_PIN=1234

From 3e5b1d9d48cb2b3ecf673f3430616f2b0c648e26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Thu, 4 Mar 2021 22:42:05 -0300
Subject: [PATCH 6/6] weechat: generate translations and don't link against
 libintl.

The gnutls-devels -> gnutls -> gettext-libs chain pulled in libintl.so,
which ended up unnecessarily linked into the binary.

Ironically, no localization files were generated, because gettext wasn't
in hostmakedepends.
---
 srcpkgs/weechat/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/weechat/template b/srcpkgs/weechat/template
index eaa22c6a06d4..ce42c986b260 100644
--- a/srcpkgs/weechat/template
+++ b/srcpkgs/weechat/template
@@ -1,12 +1,13 @@
 # Template file for 'weechat'
 pkgname=weechat
 version=3.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_MAN=ON -DENABLE_PERL=ON
  -DENABLE_LUA=ON -DENABLE_RUBY=ON -DENABLE_SPELL=ON
  -DENABLE_GUILE=OFF -DENABLE_PHP=OFF -DENABLE_JAVASCRIPT=OFF"
-hostmakedepends="ruby-asciidoctor libgcrypt-devel pkg-config python3 tcl-devel"
+hostmakedepends="ruby-asciidoctor libgcrypt-devel pkg-config python3 tcl-devel
+ gettext"
 makedepends="aspell-devel gnutls-devel libcurl-devel lua53-devel ncurses-devel
  perl python3-devel ruby-devel tcl-devel"
 depends="ca-certificates"

  parent reply	other threads:[~2021-03-24  2:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05  2:17 [PR PATCH] " ericonr
2021-03-18 17:33 ` [PR PATCH] [Updated] " ericonr
2021-03-24  2:10 ` ericonr
2021-03-24  2:37 ` ericonr [this message]
2021-03-24  2:45 ` ericonr
2021-03-24  3:50 ` [PR PATCH] [Updated] " ericonr
2021-03-24  3:51 ` [PR PATCH] [Merged]: " ericonr

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=20210324023746.Xo5cTdroqpAATnitvXADqtzIbDIcpnzSVehHZJUqw1g@z \
    --to=ericonr@users.noreply.github.com \
    --cc=ml@inbox.vuxu.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;
as well as URLs for NNTP newsgroup(s).