public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] configure: Instead of for rpm 4.15+ version, test actual rpm/zstd support
@ 2021-12-10 16:52 Thomas Schwinge
  2021-12-17  9:28 ` Thomas Schwinge
  2021-12-17 21:16 ` Dodji Seketeli
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Schwinge @ 2021-12-10 16:52 UTC (permalink / raw)
  To: libabigail, Dodji Seketeli; +Cc: Thomas Schwinge

If no 'rpm' is available, we currently get:

    [...]
    checking for rpm... no
    ../git/configure: line 13119: rpm: command not found
    configure: detected rpm version:
    configure: rpm support in abipkgdiff is disabled
    [...]
    		Here is the configuration of the package:
    [...]
        Enable rpm support in abipkgdiff               : no
        Enable rpm 4.15 support in abipkgdiff tests    : no
    [...]

Notice intermixed error output: 'rpm: command not found'.

If Ubuntu focal 'rpm' 4.14.2.1+dfsg1-1build2 is available, we currently get:

    [...]
    checking for rpm... yes
    configure: detected rpm version: 4.14.2.1
    configure: rpm support in abipkgdiff is enabled
    configure: rpm 4.15 support in abipkgdiff tests is enabled
    [...]
    		Here is the configuration of the package:
    [...]
        Enable rpm support in abipkgdiff               : yes
        Enable rpm 4.15 support in abipkgdiff tests    : yes
    [...]

Notice wrong 4.15+ version detection (due to '[[ "$rpmversion" > "4.14.0" ]]'),
which is satisfied by '4.14.2.1'.  (Comparing versions with shell '[['
generally is fragile; instead use 'autoconf-archive/ax_compare_version.m4'
or similar?)

Also, 'configure'ing with '--disable-rpm415' doesn't work; same output as
before.  That's due to commit 26c41c060bf30750fe2cded87edaf1ae47027523
"Fix thinko in configure.ac", where either there was no thinko in fact (the
original idea, I suppose, was only if 'test x$ENABLE_RPM = xyes' to do the
4.15+ 'auto' checking?), and/or a typo: instead of 'test x$ENABLE_RPM = xyes',
the first conditional should 'test x$ENABLE_RPM415 = xyes'?

And, 'configure'ing with '--enable-rpm415' doesn't raise a hard error if 'rpm'
actually isn't 4.15+.

But all that said, we don't actually need to check for rpm 4.15+ version, but
instead may simply check for the rpm/zstd support that we need: 'rpm2cpio'.

	* configure.ac: Instead of for rpm 4.15+ version, test actual
	rpm/zstd support.
	* tests/test-diff-pkg.cc: Adjust.

Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
---
 configure.ac           | 48 +++++++++++++++++++++++++++++-------------
 tests/test-diff-pkg.cc |  5 ++---
 2 files changed, 35 insertions(+), 18 deletions(-)

diff --git configure.ac configure.ac
index 5342a269..a77ab4d8 100644
--- configure.ac
+++ configure.ac
@@ -64,11 +64,12 @@ AC_ARG_ENABLE(rpm,
 	      ENABLE_RPM=$enableval,
 	      ENABLE_RPM=auto)
 
+# '--enable-rpm415' option name preserved for backwards compatibility.
 AC_ARG_ENABLE(rpm415,
 	      AS_HELP_STRING([--enable-rpm415=yes|no|auto],
-			     [enable the support of rpm 4.15 or higher in abipkgdiff (default is auto)]),
-	      ENABLE_RPM415=$enableval,
-	      ENABLE_RPM415=auto)
+			     [enable rpm/zstd in abipkgdiff testing (default is auto)]),
+	      ENABLE_RPM_ZSTD=$enableval,
+	      ENABLE_RPM_ZSTD=auto)
 
 AC_ARG_ENABLE(debug-self-comparison,
 	      AS_HELP_STRING([--enable-debug-self-comparison=yes|no],
@@ -314,23 +315,40 @@ if test x$ENABLE_RPM = xyes -o x$ENABLE_RPM = xauto; then
   fi
 fi
 
-if test x$ENABLE_RPM = xyes -o x$ENABLE_RPM415 = xauto; then
-   rpmversion=$(rpm --version | sed "s/RPM version //")
-   AC_MSG_NOTICE([detected rpm version: $rpmversion])
-   if [[[ "$rpmversion" > "4.14.0" ]]]; then
-      ENABLE_RPM415=yes
-   else
-      ENABLE_RPM415=no
-   fi
+dnl Point to a rpm/zstd file, that is:
+dnl     $ rpm -qp --qf '%{PAYLOADCOMPRESSOR}\n' [rpm_zstd_file]
+dnl     zstd
+m4_define([rpm_zstd_file], [tests/data/test-diff-pkg/mesa-libGLU-9.0.1-3.fc33.x86_64.rpm])
+AC_CONFIG_SRCDIR([rpm_zstd_file])
+if test x$ENABLE_RPM_ZSTD = xyes -o x$ENABLE_RPM_ZSTD = xauto; then
+  if test x$ENABLE_RPM = xno; then
+    if test x$ENABLE_RPM_ZSTD = xyes; then
+      AC_MSG_ERROR([rpm/zstd support needs rpm support])
+    fi
+    ENABLE_RPM_ZSTD=n/a
+  else
+    AC_MSG_CHECKING([for rpm/zstd support])
+    rpm2cpio > /dev/null 2>&AS_MESSAGE_LOG_FD "$srcdir"/rpm_zstd_file
+    if test $? -eq 0; then
+      enable_rpm_zstd=yes
+    else
+      enable_rpm_zstd=no
+    fi
+    AC_MSG_RESULT([$enable_rpm_zstd])
+    if test x$ENABLE_RPM_ZSTD:$enable_rpm_zstd = xyes:no; then
+      AC_MSG_ERROR([rpm/zstd support not available])
+    fi
+    ENABLE_RPM_ZSTD=$enable_rpm_zstd
+  fi
 fi
 
 if test x$ENABLE_RPM = xyes; then
    AC_DEFINE([WITH_RPM], 1, [compile the rpm package support in abipkgdiff])
    AC_MSG_NOTICE([rpm support in abipkgdiff is enabled]);
 
-   if test x$ENABLE_RPM415 = xyes; then
-      AC_DEFINE([WITH_RPM_4_15], 1, [has RPM 4.15 at least])
-      AC_MSG_NOTICE([rpm 4.15 support in abipkgdiff tests is enabled])
+   if test x$ENABLE_RPM_ZSTD = xyes; then
+      AC_DEFINE([WITH_RPM_ZSTD], 1, [has rpm/zstd support])
+      AC_MSG_NOTICE([rpm/zstd in abipkgdiff testing is enabled])
    fi
 else
    AC_MSG_NOTICE([rpm support in abipkgdiff is disabled]);
@@ -980,7 +998,7 @@ AC_MSG_NOTICE([
     C++ standard level                             : ${CXX_STANDARD}
     libdw has the dwarf_getalt function            : ${FOUND_DWARF_GETALT_IN_LIBDW}
     Enable rpm support in abipkgdiff               : ${ENABLE_RPM}
-    Enable rpm 4.15 support in abipkgdiff tests    : ${ENABLE_RPM415}
+    Enable rpm/zstd in abipkgdiff testing          : ${ENABLE_RPM_ZSTD}
     Enable self comparison debugging               : ${ENABLE_DEBUG_SELF_COMPARISON}
     Enable type canonicalization debugging         : ${ENABLE_DEBUG_TYPE_CANONICALIZATION}
     Enable deb support in abipkgdiff               : ${ENABLE_DEB}
diff --git tests/test-diff-pkg.cc tests/test-diff-pkg.cc
index c9e221b7..bcf2e38e 100644
--- tests/test-diff-pkg.cc
+++ tests/test-diff-pkg.cc
@@ -605,8 +605,7 @@ static InOutSpec in_out_specs[] =
     "data/test-diff-pkg/PR24690/PR24690-report-0.txt",
     "output/test-diff-pkg/PR24690/PR24690-report-0.txt"
   },
-#if WITH_RPM_4_15
-  // This RPM version supports packages compressed with zstd.
+#if WITH_RPM_ZSTD
   // RPMs from Fedora 31 onwards are compressed with zstd.
   {
     "data/test-diff-pkg/mesa-libGLU-9.0.1-3.fc33.x86_64.rpm",
@@ -747,7 +746,7 @@ static InOutSpec in_out_specs[] =
     "data/test-diff-pkg/wireshark/wireshark-cli-3.4.9-1.fc36.x86_64-self-check-report.txt",
     "output/test-diff-pkg/wireshark/wireshark-cli-3.4.9-1.fc36.x86_64-self-check-report.txt"
   } ,
-#endif // WITH_RPM_4_15
+#endif // WITH_RPM_ZSTD
 #endif //WITH_RPM
 
 #ifdef WITH_DEB
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-17 21:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 16:52 [PATCH] configure: Instead of for rpm 4.15+ version, test actual rpm/zstd support Thomas Schwinge
2021-12-17  9:28 ` Thomas Schwinge
2021-12-17 21:16 ` Dodji Seketeli

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 read-only IMAP folder(s) and NNTP newsgroup(s).