commit:     78dd9b993c8006c6adbe5d6b265a64061b7a79cb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 28 19:34:02 2025 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Aug 28 19:34:02 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=78dd9b99

configure: add enable/disable for gpkg and gtree

this allows deps to be avoided for people who don't want to go down the
path of meson and all of that.

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

 config.h.in  |   6 ++
 configure    | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 configure.ac |  62 ++++++++++++++++++-
 libq/tree.c  |  12 ++--
 q.c          |   4 +-
 5 files changed, 264 insertions(+), 10 deletions(-)

diff --git a/config.h.in b/config.h.in
index 4811d0a..bb86f82 100644
--- a/config.h.in
+++ b/config.h.in
@@ -61,6 +61,12 @@
 /* Define to 1 if // is a file system root distinct from /. */
 #undef DOUBLE_SLASH_IS_DISTINCT_ROOT
 
+/* Define if gpkg should be compiled */
+#undef ENABLE_GPKG
+
+/* Define if gtree should be compiled */
+#undef ENABLE_GTREE
+
 /* Define if qmanifest should be compiled */
 #undef ENABLE_QMANIFEST
 

diff --git a/configure b/configure
index 97f2c61..c8daeb7 100755
--- a/configure
+++ b/configure
@@ -653,6 +653,10 @@ am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+GTREE_ENABLED_FALSE
+GTREE_ENABLED_TRUE
+GPKG_ENABLED_FALSE
+GPKG_ENABLED_TRUE
 QMANIFEST_ENABLED_FALSE
 QMANIFEST_ENABLED_TRUE
 LIBZ_LIBS
@@ -2144,6 +2148,8 @@ enable_cross_guesses
 with_openssl
 with_eprefix
 enable_qmanifest
+enable_gpkg
+enable_gtree
 enable_year2038
 '
       ac_precious_vars='build_alias
@@ -2807,6 +2813,8 @@ Optional Features:
   --enable-cross-guesses={conservative|risky}
                           specify policy for cross-compilation guesses
   --enable-qmanifest      support qmanifest applet
+  --enable-gpkg           support GLEP-78 gpkg packages
+  --enable-gtree          support gtree cache
   --enable-year2038       support timestamps after 2038
 
 Optional Packages:
@@ -37275,7 +37283,21 @@ then :
 fi
 
 
-# always check libb2, gpgme and libarchive, necessary for gpkg support
+# Check whether --enable-gpkg was given.
+if test ${enable_gpkg+y}
+then :
+  enableval=$enable_gpkg;
+fi
+
+# Check whether --enable-gtree was given.
+if test ${enable_gtree+y}
+then :
+  enableval=$enable_gtree;
+fi
+
+
+
+# always check libb2, gpgme and libarchive
 
 
 
@@ -37578,6 +37600,24 @@ printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
 as_fn_error $? "--enable-qmanifest was given, but gpgme.pc could not be found
 See 'config.log' for more details" "$LINENO" 5; }
 
+fi
+                    if test "x${enable_gpkg}" = "xyes"
+then :
+
+                            { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
error: in '$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "--enable-gpkg was given, but gpgme.pc could not be found
+See 'config.log' for more details" "$LINENO" 5; }
+
+fi
+                    if test "x${enable_gtree}" = "xyes"
+then :
+
+                            { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
error: in '$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "--enable-gtree was given, but gpgme.pc could not be found
+See 'config.log' for more details" "$LINENO" 5; }
+
 fi
                     GPGME="no: missing dependencies"
 
@@ -37593,6 +37633,24 @@ printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
 as_fn_error $? "--enable-qmanifest was given, but gpgme.pc could not be found
 See 'config.log' for more details" "$LINENO" 5; }
 
+fi
+                    if test "x${enable_gpkg}" = "xyes"
+then :
+
+                            { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
error: in '$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "--enable-gpkg was given, but gpgme.pc could not be found
+See 'config.log' for more details" "$LINENO" 5; }
+
+fi
+                    if test "x${enable_gtree}" = "xyes"
+then :
+
+                            { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
error: in '$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "--enable-gtree was given, but gpgme.pc could not be found
+See 'config.log' for more details" "$LINENO" 5; }
+
 fi
                     GPGME="no: missing dependencies"
 
@@ -37669,12 +37727,48 @@ fi
         echo "$LIBARCHIVE_PKG_ERRORS" >&5
 
 
+                    if test "x${enable_gpkg}" = "xyes"
+then :
+
+                            { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
error: in '$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "--enable-gpkg was given, but libarchive.pc could not be found
+See 'config.log' for more details" "$LINENO" 5; }
+
+fi
+                    if test "x${enable_gtree}" = "xyes"
+then :
+
+                            { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
error: in '$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "--enable-gtree was given, but libarchive.pc could not be found
+See 'config.log' for more details" "$LINENO" 5; }
+
+fi
                     LIBARCHIVE="no: missing dependencies"
 
 elif test $pkg_failed = untried; then
         { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
 
+                    if test "x${enable_gpkg}" = "xyes"
+then :
+
+                            { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
error: in '$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "--enable-gpkg was given, but libarchive.pc could not be found
+See 'config.log' for more details" "$LINENO" 5; }
+
+fi
+                    if test "x${enable_gtree}" = "xyes"
+then :
+
+                            { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: 
error: in '$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "--enable-gtree was given, but libarchive.pc could not be found
+See 'config.log' for more details" "$LINENO" 5; }
+
+fi
                     LIBARCHIVE="no: missing dependencies"
 
 else
@@ -37830,6 +37924,92 @@ if test "x$enable_qmanifest" != xno ; then
 
 printf "%s\n" "#define ENABLE_QMANIFEST 1" >>confdefs.h
 
+fi
+
+if test "x${enable_gpkg}" != "xno"
+then :
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable 
gpkg" >&5
+printf %s "checking whether to enable gpkg... " >&6; }
+  if test "x${GPGME}${LIBARCHIVE}" = "xyesyes"
+then :
+
+    { 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: missing 
dependencies" >&5
+printf "%s\n" "no: missing dependencies" >&6; }
+   ;;
+esac
+fi
+
+else case e in #(
+  e)
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable 
gpkg" >&5
+printf %s "checking whether to enable gpkg... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no: disabled by 
configure argument" >&5
+printf "%s\n" "no: disabled by configure argument" >&6; }
+ ;;
+esac
+fi
+
+ if test "x$enable_gpkg" != xno; then
+  GPKG_ENABLED_TRUE=
+  GPKG_ENABLED_FALSE='#'
+else
+  GPKG_ENABLED_TRUE='#'
+  GPKG_ENABLED_FALSE=
+fi
+
+if test "x$enable_gpkg" != xno ; then
+
+printf "%s\n" "#define ENABLE_GPKG 1" >>confdefs.h
+
+fi
+
+if test "x${enable_gtree}" != "xno"
+then :
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable 
gtree" >&5
+printf %s "checking whether to enable gtree... " >&6; }
+  if test "x${GPGME}${LIBARCHIVE}" = "xyesyes"
+then :
+
+    { 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: missing 
dependencies" >&5
+printf "%s\n" "no: missing dependencies" >&6; }
+   ;;
+esac
+fi
+
+else case e in #(
+  e)
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable 
gtree" >&5
+printf %s "checking whether to enable gtree... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no: disabled by 
configure argument" >&5
+printf "%s\n" "no: disabled by configure argument" >&6; }
+ ;;
+esac
+fi
+
+ if test "x$enable_gtree" != xno; then
+  GTREE_ENABLED_TRUE=
+  GTREE_ENABLED_FALSE='#'
+else
+  GTREE_ENABLED_TRUE='#'
+  GTREE_ENABLED_FALSE=
+fi
+
+if test "x$enable_gtree" != xno ; then
+
+printf "%s\n" "#define ENABLE_GTREE 1" >>confdefs.h
+
 fi
 
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler 
vendor" >&5
@@ -39033,6 +39213,14 @@ if test -z "${QMANIFEST_ENABLED_TRUE}" && test -z 
"${QMANIFEST_ENABLED_FALSE}";
   as_fn_error $? "conditional \"QMANIFEST_ENABLED\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${GPKG_ENABLED_TRUE}" && test -z "${GPKG_ENABLED_FALSE}"; then
+  as_fn_error $? "conditional \"GPKG_ENABLED\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${GTREE_ENABLED_TRUE}" && test -z "${GTREE_ENABLED_FALSE}"; then
+  as_fn_error $? "conditional \"GTREE_ENABLED\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0

diff --git a/configure.ac b/configure.ac
index 04fe65c..04ee255 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,7 +53,15 @@ AC_SUBST([CONFIG_EPREFIX], ["$with_eprefix"])
 AC_ARG_ENABLE([qmanifest], [AS_HELP_STRING([--enable-qmanifest],
                          [support qmanifest applet])])
 
-# always check libb2, gpgme and libarchive, necessary for gpkg support
+AC_ARG_ENABLE([gpkg],
+              [AS_HELP_STRING([--enable-gpkg],
+                              [support GLEP-78 gpkg packages])])
+AC_ARG_ENABLE([gtree],
+              [AS_HELP_STRING([--enable-gtree],
+                              [support gtree cache])])
+
+
+# always check libb2, gpgme and libarchive
 PKG_CHECK_MODULES([LIBBL2], [libb2],
                   [
                     AC_DEFINE([HAVE_BLAKE2B], [1], [Define if you have 
blake2b])
@@ -77,6 +85,14 @@ PKG_CHECK_MODULES([GPGME], [gpgme],
                           [
                             AC_MSG_FAILURE([--enable-qmanifest was given, but 
gpgme.pc could not be found])
                           ])
+                    AS_IF([test "x${enable_gpkg}" = "xyes"],
+                          [
+                            AC_MSG_FAILURE([--enable-gpkg was given, but 
gpgme.pc could not be found])
+                          ])
+                    AS_IF([test "x${enable_gtree}" = "xyes"],
+                          [
+                            AC_MSG_FAILURE([--enable-gtree was given, but 
gpgme.pc could not be found])
+                          ])
                     GPGME="no: missing dependencies"
                   ])
 
@@ -86,6 +102,14 @@ PKG_CHECK_MODULES([LIBARCHIVE], [libarchive],
                     LIBARCHIVE="yes"
                   ],
                   [
+                    AS_IF([test "x${enable_gpkg}" = "xyes"],
+                          [
+                            AC_MSG_FAILURE([--enable-gpkg was given, but 
libarchive.pc could not be found])
+                          ])
+                    AS_IF([test "x${enable_gtree}" = "xyes"],
+                          [
+                            AC_MSG_FAILURE([--enable-gtree was given, but 
libarchive.pc could not be found])
+                          ])
                     LIBARCHIVE="no: missing dependencies"
                   ])
 
@@ -117,6 +141,42 @@ if test "x$enable_qmanifest" != xno ; then
                          [Define if qmanifest should be compiled])
 fi
 
+AS_IF([test "x${enable_gpkg}" != "xno"], [
+  AC_MSG_CHECKING([whether to enable gpkg])
+  AS_IF([test "x${GPGME}${LIBARCHIVE}" = "xyesyes"], [
+    AC_MSG_RESULT([yes])
+  ], [
+    AC_MSG_RESULT([no: missing dependencies])
+  ])
+], [
+  AC_MSG_CHECKING([whether to enable gpkg])
+  AC_MSG_RESULT([no: disabled by configure argument])
+])
+
+AM_CONDITIONAL([GPKG_ENABLED], [test "x$enable_gpkg" != xno])
+if test "x$enable_gpkg" != xno ; then
+       AC_DEFINE([ENABLE_GPKG], [1],
+                         [Define if gpkg should be compiled])
+fi
+
+AS_IF([test "x${enable_gtree}" != "xno"], [
+  AC_MSG_CHECKING([whether to enable gtree])
+  AS_IF([test "x${GPGME}${LIBARCHIVE}" = "xyesyes"], [
+    AC_MSG_RESULT([yes])
+  ], [
+    AC_MSG_RESULT([no: missing dependencies])
+  ])
+], [
+  AC_MSG_CHECKING([whether to enable gtree])
+  AC_MSG_RESULT([no: disabled by configure argument])
+])
+
+AM_CONDITIONAL([GTREE_ENABLED], [test "x$enable_gtree" != xno])
+if test "x$enable_gtree" != xno ; then
+       AC_DEFINE([ENABLE_GTREE], [1],
+                         [Define if gtree should be compiled])
+fi
+
 AX_CFLAGS_WARN_ALL
 AC_DEFUN([PT_CHECK_CFLAG],[AX_CHECK_COMPILER_FLAGS([$1],[CFLAGS="$CFLAGS 
$1"])])
 m4_foreach_w([flag], [

diff --git a/libq/tree.c b/libq/tree.c
index 9b65bda..0a6113f 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -15,7 +15,7 @@
 #include <ctype.h>
 #include <xalloc.h>
 
-#ifdef HAVE_LIBARCHIVE
+#if defined(ENABLE_GPKG) || defined(ENABLE_GTREE)
 # include <archive.h>
 # include <archive_entry.h>
 #endif
@@ -97,7 +97,7 @@ tree_open(const char *sroot, const char *portdir)
        }
 
        /* look for cache trees to speed things up */
-#ifdef HAVE_LIBARCHIVE
+#ifdef ENABLE_GTREE
        snprintf(buf, sizeof(buf), "%s/%s", portdir, portcachedir_gt1);
        ret->subtree = tree_open_gtree_int(sroot, buf, true);
        if (ret->subtree != NULL) {
@@ -176,7 +176,7 @@ tree_open_binpkg(const char *sroot, const char *spkg)
        return ret;
 }
 
-#ifdef HAVE_LIBARCHIVE
+#ifdef ENABLE_GTREE
 tree_ctx *
 tree_open_gtree_int(const char *sroot, const char *tar, bool quiet)
 {
@@ -1145,7 +1145,7 @@ tree_read_file_binpkg(tree_pkg_ctx *pkg_ctx)
        int newfd = -1;
 
        if (pkg_ctx->binpkg_isgpkg) {
-#ifdef HAVE_LIBARCHIVE
+#ifdef ENABLE_GPKG
                struct archive       *a     = archive_read_new();
                struct archive_entry *entry;
                size_t                len   = 0;
@@ -1822,7 +1822,7 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb 
callback, void *priv)
        return ret;
 }
 
-#ifdef HAVE_LIBARCHIVE
+#ifdef ENABLE_GTREE
 struct tree_gtree_cb_ctx {
        struct archive *archive;
 };
@@ -2056,7 +2056,7 @@ tree_foreach_pkg(tree_ctx *ctx, tree_pkg_cb callback, 
void *priv,
        if (ctx->treetype == TREE_PACKAGES)
                return tree_foreach_packages(ctx, callback, priv);
 
-#ifdef HAVE_LIBARCHIVE
+#ifdef ENABLE_GTREE
        /* similar a gtree cache can be read sequentially in one go */
        if (ctx->treetype == TREE_METADATA_GTREE)
                return tree_foreach_gtree(ctx, callback, priv);

diff --git a/q.c b/q.c
index d995d8a..de241be 100644
--- a/q.c
+++ b/q.c
@@ -19,7 +19,7 @@
 #include <libproc.h>
 #endif
 
-#ifdef HAVE_LIBARCHIVE
+#ifdef ENABLE_GPKG
 # include <archive.h>
 # include <archive_entry.h>
 #endif
@@ -106,7 +106,7 @@ int lookup_applet_idx(const char *applet)
        return 0;
 }
 
-#ifdef HAVE_LIBARCHIVE
+#ifdef ENABLE_GPKG
 struct q_cache_ctx {
        struct archive *archive;
        time_t          buildtime;

Reply via email to