diff --git a/Makefile-lib.am b/Makefile-lib.am index 6eb9914f..abd5b876 100644 --- a/Makefile-lib.am +++ b/Makefile-lib.am @@ -34,7 +34,7 @@ librpmostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libp -fvisibility=hidden '-D_RPMOSTREE_EXTERN=__attribute((visibility("default"))) extern' \ $(PKGDEP_RPMOSTREE_CFLAGS) librpmostree_1_la_LDFLAGS = -version-number 1:0:0 -Bsymbolic-functions -librpmostree_1_la_LIBADD = libglnx.la $(PKGDEP_RPMOSTREE_LIBS) +librpmostree_1_la_LIBADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la if BUILDOPT_INTROSPECTION RpmOstree-1.0.gir: librpmostree-1.la Makefile diff --git a/Makefile-libpriv.am b/Makefile-libpriv.am new file mode 100644 index 00000000..1a57a7be --- /dev/null +++ b/Makefile-libpriv.am @@ -0,0 +1,36 @@ +# Copyright (C) 2015 Colin Walters +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +noinst_LTLIBRARIES += librpmostreepriv.la + +librpmostreepriv_la_SOURCES = \ + src/libpriv/rpmostree-postprocess.c \ + src/libpriv/rpmostree-postprocess.h \ + src/libpriv/rpmostree-json-parsing.c \ + src/libpriv/rpmostree-json-parsing.h \ + src/libpriv/rpmostree-util.c \ + src/libpriv/rpmostree-util.h \ + src/libpriv/rpmostree-passwd-util.c \ + src/libpriv/rpmostree-passwd-util.h \ + src/libpriv/rpmostree-cleanup.h \ + src/libpriv/rpmostree-rpm-util.c \ + src/libpriv/rpmostree-rpm-util.h \ + src/libpriv/rpmostree-treepkgdiff.c \ + src/libpriv/rpmostree-treepkgdiff.h \ + $(NULL) +librpmostreepriv_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS) +librpmostreepriv_la_LIBADD = $(AM_LDFLAGS) $(PKGDEP_RPMOSTREE_LIBS) libglnx.la $(CAP_LIBS) diff --git a/Makefile-libutil.am b/Makefile-libutil.am deleted file mode 100644 index 3a7d5940..00000000 --- a/Makefile-libutil.am +++ /dev/null @@ -1,50 +0,0 @@ -# Makefile for C source code -# -# Copyright (C) 2015 Colin Walters -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -include Makefile-lib-defines.am - -privlib_LTLIBRARIES += librpmostreepriv.la - -librpmostree_1_la_SOURCES = \ - librpmostree-priv/rpmostree-cleanup.h \ - librpmostree-priv/rpmostree-cleanup.c \ - $(NULL) - -librpmostreepriv_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/librpmostree-priv \ - $(PKGDEP_RPMOSTREE_CFLAGS) -librpmostreepriv_la_LDFLAGS = -Bsymbolic-functions -export-symbols-regex '^rpmostreepriv_' -librpmostree_priv_la_LIBADD = libglnx.la $(PKGDEP_RPMOSTREE_LIBS) - -if BUILDOPT_INTROSPECTION -RpmOstree-1.0.gir: libostree-1.la Makefile -RpmOstree_1_0_gir_EXPORT_PACKAGES = rpm-ostree-1 -RpmOstree_1_0_gir_INCLUDES = OSTree-1 Gio-2.0 -RpmOstree_1_0_gir_CFLAGS = $(librpmostree_1_la_CFLAGS) -RpmOstree_1_0_gir_LIBS = librpmostree-1.la -RpmOstree_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=RpmOstree --symbol-prefix=rpmostree -RpmOstree_1_0_gir_FILES = $(librpmostreeinclude_HEADERS) $(filter-out %-private.h,$(librpmostree_1_la_SOURCES)) -INTROSPECTION_GIRS += RpmOstree-1.0.gir -gir_DATA += RpmOstree-1.0.gir -typelib_DATA += RpmOstree-1.0.typelib - -CLEANFILES += $(gir_DATA) $(typelib_DATA) -endif - -pkgconfig_DATA += librpmostree/rpm-ostree-1.pc - diff --git a/Makefile-rpm-ostree.am b/Makefile-rpm-ostree.am index 9eefc146..fbe76865 100644 --- a/Makefile-rpm-ostree.am +++ b/Makefile-rpm-ostree.am @@ -17,28 +17,6 @@ bin_PROGRAMS += rpm-ostree -noinst_LTLIBRARIES += librpmostree.la - -librpmostree_la_SOURCES = \ - src/libpriv/rpmostree-postprocess.c \ - src/libpriv/rpmostree-postprocess.h \ - src/libpriv/rpmostree-json-parsing.c \ - src/libpriv/rpmostree-json-parsing.h \ - src/libpriv/rpmostree-util.c \ - src/libpriv/rpmostree-util.h \ - src/libpriv/rpmostree-passwd-util.c \ - src/libpriv/rpmostree-passwd-util.h \ - src/libpriv/rpmostree-cleanup.h \ - src/libpriv/rpmostree-treepkgdiff.c \ - src/libpriv/rpmostree-treepkgdiff.h \ - src/libpriv/rpmostree-rpm-util.c \ - src/libpriv/rpmostree-rpm-util.h \ - src/libpriv/rpmostree-treepkgdiff.c \ - src/libpriv/rpmostree-treepkgdiff.h \ - $(NULL) -librpmostree_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS) -librpmostree_la_LIBADD = $(AM_LDFLAGS) $(PKGDEP_RPMOSTREE_LIBS) libglnx.la $(CAP_LIBS) - rpm_ostree_SOURCES = src/app/main.c \ src/app/rpmostree-builtins.h \ src/app/rpmostree-db-builtins.h \ @@ -62,7 +40,7 @@ rpm_ostree_SOURCES += \ endif rpm_ostree_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/app -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS) -rpm_ostree_LDADD = $(AM_LDFLAGS) $(PKGDEP_RPMOSTREE_LIBS) libglnx.la librpmostree.la +rpm_ostree_LDADD = $(AM_LDFLAGS) $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la privdatadir=$(pkglibdir) privdata_DATA = src/app/tmpfiles-ostree-integration.conf diff --git a/Makefile-tests.am b/Makefile-tests.am index 80ac5e60..1e34c544 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -22,7 +22,7 @@ tests/compose/test-repo.repo: tests/compose/test-repo.repo.in tests/compose/yum/ tests_jsonutil_CPPFLAGS = -I $(srcdir)/src/libpriv tests_jsonutil_CFLAGS = $(PKGDEP_RPMOSTREE_CFLAGS) -tests_jsonutil_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostree.la +tests_jsonutil_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la tests/test-compose.sh: tests/compose/test-repo.repo diff --git a/Makefile.am b/Makefile.am index 0c3c4fa9..2514ea8f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,6 +46,7 @@ TYPELIBS = $(GIRS:.gir=.typelib) include libglnx/Makefile-libglnx.am noinst_LTLIBRARIES += libglnx.la +include Makefile-libpriv.am include Makefile-lib.am include Makefile-rpm-ostree.am include Makefile-tests.am diff --git a/src/lib/rpmostree-db.c b/src/lib/rpmostree-db.c index 5cdc3825..2fea9714 100644 --- a/src/lib/rpmostree-db.c +++ b/src/lib/rpmostree-db.c @@ -25,6 +25,7 @@ #include "rpmostree-db.h" #include "rpmostree-priv.h" #include "rpmostree-cleanup.h" +#include "rpmostree-treepkgdiff.h" /** * SECTION:librpmostree-dbquery @@ -98,22 +99,10 @@ rpm_ostree_db_query (OstreeRepo *repo, { HySack hsack; -#if BUILDOPT_HAWKEY_SACK_CREATE2 - hsack = hy_sack_create (NULL, NULL, - rpmdb_tempdir, - NULL, - 0); -#else - hsack = hy_sack_create (NULL, NULL, - rpmdb_tempdir, - 0); -#endif - if (hsack == NULL) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "Failed to create sack cache"); - goto out; - } + if (!rpmostree_get_sack_for_root (tempdir_dfd, ".", + &hsack, cancellable, error)) + goto out; + sack = _rpm_ostree_refsack_new (hsack); } diff --git a/src/libpriv/rpmostree-treepkgdiff.c b/src/libpriv/rpmostree-treepkgdiff.c index 0f7d7ba4..00639d5d 100644 --- a/src/libpriv/rpmostree-treepkgdiff.c +++ b/src/libpriv/rpmostree-treepkgdiff.c @@ -26,20 +26,19 @@ #include "rpmostree-cleanup.h" gboolean -rpmostree_get_pkglist_for_root (int dfd, - const char *path, - HySack *out_sack, - HyPackageList *out_pkglist, - GCancellable *cancellable, - GError **error) +rpmostree_get_sack_for_root (int dfd, + const char *path, + HySack *out_sack, + GCancellable *cancellable, + GError **error) { gboolean ret = FALSE; int rc; _cleanup_hysack_ HySack sack = NULL; - _cleanup_hyquery_ HyQuery query = NULL; - _cleanup_hypackagelist_ HyPackageList pkglist = NULL; g_autofree char *fullpath = glnx_fdrel_abspath (dfd, path); + g_return_val_if_fail (out_sack != NULL, FALSE); + #if BUILDOPT_HAWKEY_SACK_CREATE2 sack = hy_sack_create (NULL, NULL, fullpath, @@ -63,6 +62,30 @@ rpmostree_get_pkglist_for_root (int dfd, g_prefix_error (error, "Failed to load system repo: "); goto out; } + + ret = TRUE; + *out_sack = g_steal_pointer (&sack); + out: + return ret; +} + +gboolean +rpmostree_get_pkglist_for_root (int dfd, + const char *path, + HySack *out_sack, + HyPackageList *out_pkglist, + GCancellable *cancellable, + GError **error) +{ + gboolean ret = FALSE; + _cleanup_hysack_ HySack sack = NULL; + _cleanup_hyquery_ HyQuery query = NULL; + _cleanup_hypackagelist_ HyPackageList pkglist = NULL; + g_autofree char *fullpath = glnx_fdrel_abspath (dfd, path); + + if (!rpmostree_get_sack_for_root (dfd, path, &sack, cancellable, error)) + goto out; + query = hy_query_create (sack); hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); pkglist = hy_query_run (query); diff --git a/src/libpriv/rpmostree-treepkgdiff.h b/src/libpriv/rpmostree-treepkgdiff.h index f4f0818b..12819e31 100644 --- a/src/libpriv/rpmostree-treepkgdiff.h +++ b/src/libpriv/rpmostree-treepkgdiff.h @@ -23,6 +23,13 @@ #include #include "rpmostree-cleanup.h" +gboolean +rpmostree_get_sack_for_root (int dfd, + const char *path, + HySack *out_sack, + GCancellable *cancellable, + GError **error); + gboolean rpmostree_get_pkglist_for_root (int dfd, const char *path,