lib: Don't link to libdnf

Prep for "Rust-as-main", where I want to build libdnf statically.
And this really completes the "library thinout" story because
now we avoid dragging our *private* `libdnf.so` into the caller's
address space, which can cause potential conflicts if they're
also linking the system one. (Which could easily occur with
something like gnome-software)

All we were using libdnf for (indirectly via libsolv) is comparing
version strings but librpm can already do that for us.
This commit is contained in:
Colin Walters 2021-01-27 18:57:44 +00:00 committed by OpenShift Merge Robot
parent e88a736e55
commit 1cef69cf8a
5 changed files with 15 additions and 23 deletions

View File

@ -35,16 +35,10 @@ librpmostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libp
$(PKGDEP_RPMOSTREE_CFLAGS)
librpmostree_1_la_LDFLAGS = $(AM_LDFLAGS) -version-number 1:0:0 -Bsymbolic-functions
librpmostree_1_la_LIBADD = $(PKGDEP_RPMOSTREE_LIBS) libglnx.la
EXTRA_librpmostree_1_la_DEPENDENCIES = libdnf.so.2
# The g-ir-scanner creates a stub executable (to help introspect type information) which
# links to our stuff. We want to make sure it picks up our fresh libdnf and not a possibly
# stale one from a previously installed rpm-ostree's bundled libdnf.
INTROSPECTION_SCANNER_ENV = env LD_LIBRARY_PATH=$(top_builddir)/libdnf-build/libdnf
# XXX: work around clang being passed -fstack-clash-protection which it doesn't understand
# https://github.com/projectatomic/rpm-ostree/pull/1787#issuecomment-473971585
INTROSPECTION_SCANNER_ENV += CC=gcc
INTROSPECTION_SCANNER_ENV = CC=gcc
if BUILDOPT_INTROSPECTION
RpmOstree-1.0.gir: librpmostree-1.la Makefile

View File

@ -84,9 +84,11 @@ rpmostree_common_cflags = -I$(srcdir)/src/app -I$(srcdir)/src/daemon \
-I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) \
-DG_LOG_DOMAIN=\"rpm-ostreed\" \
-DLIBDIR=\"$(libdir)\" -DPKGLIBDIR=\"$(pkglibdir)\" \
-I $(top_srcdir)/libdnf -I $(top_srcdir)/libdnf-build \
$(PKGDEP_RPMOSTREE_CFLAGS) $(PKGDEP_RPMOSTREE_RS_CFLAGS)
rpmostree_bin_common_cflags = $(rpmostree_common_cflags)
rpmostree_common_libs = $(PKGDEP_RPMOSTREE_LIBS) $(CAP_LIBS) libglnx.la librpmostree-1.la librpmostreecxxrs.la $(PKGDEP_RPMOSTREE_RS_LIBS) -lstdc++ -lrt
rpmostree_common_libs = $(PKGDEP_RPMOSTREE_LIBS) -L$(top_srcdir)/libdnf-build/libdnf -ldnf $(CAP_LIBS) libglnx.la librpmostree-1.la librpmostreecxxrs.la $(PKGDEP_RPMOSTREE_RS_LIBS) -lstdc++ -lrt
rpmostree_bin_common_libs = librpmostreeinternals.la $(librpmostree_rust_path) $(rpmostree_common_libs)
rpm_ostree_CFLAGS = $(AM_CFLAGS) $(rpmostree_bin_common_cflags)
rpm_ostree_CXXFLAGS = $(AM_CXXFLAGS) $(rpmostree_bin_common_cflags)

View File

@ -93,10 +93,6 @@ PKGDEP_RPMOSTREE_LIBS="$PKGDEP_RPMOSTREE_LIBS -Wl,--push-state,--no-as-needed,-l
# curl-rust uses it.
PKG_CHECK_MODULES(PKGDEP_RPMOSTREE_RS, [libcurl openssl])
dnl bundled libdnf
PKGDEP_RPMOSTREE_CFLAGS="-I $(pwd)/libdnf -I $(pwd)/libdnf-build $PKGDEP_RPMOSTREE_CFLAGS"
PKGDEP_RPMOSTREE_LIBS="-L$(pwd)/libdnf-build/libdnf -ldnf $PKGDEP_RPMOSTREE_LIBS"
dnl RHEL8.1 has old libarchive
AS_IF([pkg-config --atleast-version=3.3.3 libarchive],
[AC_DEFINE([HAVE_LIBARCHIVE_ZSTD], 1, [Define if we have libarchive with zstd])])

View File

@ -32,7 +32,7 @@
#include <string.h>
#include <stdlib.h>
#include <libdnf/libdnf.h>
#include <rpm/rpmver.h>
#include "libglnx.h"
#include "rpmostree-shlib-ipc-private.h"
@ -150,12 +150,11 @@ rpm_ostree_package_cmp (RpmOstreePackage *p1, RpmOstreePackage *p2)
if (ret)
return ret;
/* the NULL case is a little wasteful; it needs to allocate a pool to do the comparison.
* maybe we should also cache a DnfSack in the GVariant-based case too? OTOH, we shouldn't
* hit this case often: the pkglist is already sorted when we read it out of the commit
* metadata and we do the diff in _rpm_ostree_diff_package_lists() using a temporary sack.
* */
ret = dnf_sack_evr_cmp (NULL, p1->evr, p2->evr);
/* Note we shouldn't hit this case often: the pkglist is already sorted
* when we read it out of the commit metadata and we also sort
* the diff in_rpm_ostree_diff_package_lists().
**/
ret = rpmvercmp (p1->evr, p2->evr);
if (ret)
return ret;
@ -296,9 +295,6 @@ _rpm_ostree_diff_package_lists (GPtrArray *a,
g_autoptr(GPtrArray) modified_b = g_ptr_array_new_with_free_func (g_object_unref);
g_autoptr(GPtrArray) common = g_ptr_array_new_with_free_func (g_object_unref);
/* allocate a sack just for comparisons */
g_autoptr(DnfSack) sack = dnf_sack_new ();
guint cur_a = 0;
guint cur_b = 0;
while (cur_a < an && cur_b < bn)
@ -323,7 +319,7 @@ _rpm_ostree_diff_package_lists (GPtrArray *a,
cmp = strcmp (pkg_a->arch, pkg_b->arch);
if (cmp == 0)
{
cmp = dnf_sack_evr_cmp (sack, pkg_a->evr, pkg_b->evr);
cmp = rpmvercmp (pkg_a->evr, pkg_b->evr);
if (cmp == 0)
{
g_ptr_array_add (common, g_object_ref (pkg_a));

View File

@ -76,3 +76,7 @@ echo "ok reload"
# See rpmostree-scripts.c
grep ^DEFAULT /etc/crypto-policies/config
echo "ok crypto-policies DEFAULT backend"
ldd /usr/lib64/librpmostree-1.so.1 > rpmostree-lib-deps.txt
assert_not_file_has_content rpmostree-lib-deps.txt libdnf
echo "ok lib deps"