commit:     d5032f5f362d80e91d7b6f522440cbc437345a2b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 26 14:53:59 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan 26 14:55:36 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d5032f5f

configure: check for archive_entry_hardlink_is_set

Aparently Ubuntu on GitHub's action runners has a libarchive that does
not have archive_entry_hardlink_is_set yet.  Since the alternative seems
like a bit inefficient, use the function when it is available (as is on
Gentoo, the platform where this software makes most sense).

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 config.h.in  |  3 +++
 configure    | 31 +++++++++++++++++++++++++++++++
 configure.ac | 11 +++++++++++
 qmerge.c     |  9 ++++++++-
 4 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/config.h.in b/config.h.in
index 3a53d9e0..b9bf3eff 100644
--- a/config.h.in
+++ b/config.h.in
@@ -417,6 +417,9 @@
 /* Define to 1 if <alloca.h> works. */
 #undef HAVE_ALLOCA_H
 
+/* Define if you have archive_entry_hardlink_is_set */
+#undef HAVE_ARCHIVE_ENTRY_HARDLINK_IS_SET
+
 /* Define if you have blake2b */
 #undef HAVE_BLAKE2B
 

diff --git a/configure b/configure
index a94ae9e6..cb4b1ae2 100755
--- a/configure
+++ b/configure
@@ -31114,6 +31114,37 @@ printf "%s\n" "yes" >&6; }
 printf "%s\n" "#define HAVE_LIBARCHIVE 1" >>confdefs.h
 
                     LIBARCHIVE="yes"
+                    save_LIBS="$LIBS"
+                    LIBS="$LIBS $LIBARCHIVE_LIBS"
+                    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking 
whether for archive_entry_hardlink_is_set" >&5
+printf %s "checking whether for archive_entry_hardlink_is_set... " >&6; }
+                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <archive.h>
+                                 #include <archive_entry.h>
+int
+main (void)
+{
+archive_entry_hardlink_is_set(NULL);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+
+printf "%s\n" "#define HAVE_ARCHIVE_ENTRY_HARDLINK_IS_SET 1" >>confdefs.h
+
+                                 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
result: yes" >&5
+printf "%s\n" "yes" >&6; }
+else case e in #(
+  e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; } ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+                    LIBS="$save_LIBS"
 
 fi
 

diff --git a/configure.ac b/configure.ac
index e310488e..e3605529 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,17 @@ PKG_CHECK_MODULES([LIBARCHIVE], [libarchive],
                   [
                     AC_DEFINE([HAVE_LIBARCHIVE], [1], [Define if you have 
libarchive])
                     LIBARCHIVE="yes"
+                    save_LIBS="$LIBS"
+                    LIBS="$LIBS $LIBARCHIVE_LIBS"
+                    AC_MSG_CHECKING([whether for 
archive_entry_hardlink_is_set])
+                    AC_TRY_LINK([#include <archive.h>
+                                 #include <archive_entry.h>],
+                                [archive_entry_hardlink_is_set(NULL);],
+                                
[AC_DEFINE([HAVE_ARCHIVE_ENTRY_HARDLINK_IS_SET],
+                                          [1], [Define if you have 
archive_entry_hardlink_is_set])
+                                 AC_MSG_RESULT([yes])],
+                                [AC_MSG_RESULT([no])])
+                    LIBS="$save_LIBS"
                   ],
                   [
                     AS_IF([test "x${enable_gpkg}" = "xyes"],

diff --git a/qmerge.c b/qmerge.c
index 1a972552..2d35e0e0 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1354,7 +1354,14 @@ pkg_merge(int level, const depend_atom *qatom, 
tree_pkg_ctx *mpkg)
                        fname = archive_entry_pathname(entry);  /* re-retrieve 
for errors */
 
                        /* handle hardlinks offset, #968291 */
-                       if (archive_entry_hardlink_is_set(entry)) {
+#ifdef HAVE_ARCHIVE_ENTRY_HARDLINK_IS_SET
+                       if (archive_entry_hardlink_is_set(entry))
+#else
+                       /* for Ubuntu, older libarchive has no
+                        * archive_entry_hardlink_is_set */
+                       if (archive_entry_hardlink(entry) != NULL)
+#endif
+                       {
                                const char *hlinktrg = 
archive_entry_hardlink(entry);
                                /* drop image prefix like for the path */
                                hlinktrg = strchr(hlinktrg, '/');

Reply via email to