From e1091a5c5b1d878f4f6043306cfeb9316eee8a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Thu, 4 Mar 2021 18:31:38 -0300 Subject: [PATCH] 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. --- common/shlibs | 9 ++-- srcpkgs/gettext-devel-tools | 1 + srcpkgs/gettext/patches/musl-realpath.patch | 41 ++++++++++++++ .../musl-unsupported-iconv-encoding.patch | 44 +++++++++++++++ srcpkgs/gettext/template | 54 ++++++++++++++----- 5 files changed, 131 insertions(+), 18 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 4b82c3ced65..7319cc8d20c 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 00000000000..d3a6700489c --- /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 00000000000..75a650895e0 --- /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 00000000000..de9a6b02b3a --- /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: Franois Pinard is a hero. diff --git a/srcpkgs/gettext/template b/srcpkgs/gettext/template index 06079609ba0..3c8250b976b 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 gettext + 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,42 @@ gettext-devel-examples_package() { vmove usr/share/doc/gettext } } + gettext-devel_package() { - depends="gettext-libs>=${version}_${revision} xz tar" + depends="${sourcepkg}>=${version}_${revision} + 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 - vmove usr/bin/autopoint - vmove usr/bin/gettextize } } + +gettext-devel-tools_package() { + depends="${sourcepkg}>=${version}_${revision}" + 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.*" } }