diff --git a/Makefile-libpriv.am b/Makefile-libpriv.am index 1fbe45f0..5baf6a63 100644 --- a/Makefile-libpriv.am +++ b/Makefile-libpriv.am @@ -53,6 +53,7 @@ librpmostreepriv_la_SOURCES = \ librpmostreepriv_la_CFLAGS = \ $(AM_CFLAGS) \ + -I$(srcdir)/src/lib \ -I$(srcdir)/src/libpriv \ -I$(libglnx_srcpath) \ -DPKGLIBDIR=\"$(pkglibdir)\" \ diff --git a/Makefile-tests.am b/Makefile-tests.am index 9784ac67..a918d2e5 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -65,17 +65,20 @@ CLEANFILES += \ tests/common/compose/test-repo-local.repo \ $(NULL) -tests_check_jsonutil_CPPFLAGS = $(AM_CPPFLAGS) -I $(srcdir)/src/libpriv -I $(srcdir)/libglnx -tests_check_jsonutil_CFLAGS = $(AM_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS) -tests_check_jsonutil_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la +testbin_cppflags = $(AM_CPPFLAGS) -I $(srcdir)/src/libpriv -I $(srcdir)/libglnx +testbin_cflags = $(AM_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS) +testbin_ldadd = $(PKGDEP_RPMOSTREE_LIBS) librpmostree-1.la librpmostreepriv.la +tests_check_jsonutil_CPPFLAGS = $(testbin_cppflags) +tests_check_jsonutil_CFLAGS = $(testbin_cflags) +tests_check_jsonutil_LDADD = $(testbin_ldadd) -tests_check_cache_branch_to_nevra_CPPFLAGS = $(AM_CPPFLAGS) -I $(srcdir)/src/libpriv -I $(srcdir)/libglnx -tests_check_cache_branch_to_nevra_CFLAGS = $(AM_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS) -tests_check_cache_branch_to_nevra_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la +tests_check_cache_branch_to_nevra_CPPFLAGS = $(testbin_cppflags) +tests_check_cache_branch_to_nevra_CFLAGS = $(testbin_cflags) +tests_check_cache_branch_to_nevra_LDADD = $(testbin_ldadd) -tests_check_postprocess_CPPFLAGS = $(AM_CPPFLAGS) -I $(srcdir)/src/libpriv -I $(srcdir)/libglnx -tests_check_postprocess_CFLAGS = $(AM_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS) -tests_check_postprocess_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la +tests_check_postprocess_CPPFLAGS = $(testbin_cppflags) +tests_check_postprocess_CFLAGS = $(testbin_cflags) +tests_check_postprocess_LDADD = $(testbin_ldadd) tests/check/test-compose.sh: tests/common/compose/test-repo.repo diff --git a/src/app/rpmostree-libbuiltin.c b/src/app/rpmostree-libbuiltin.c index 9745481a..e9548161 100644 --- a/src/app/rpmostree-libbuiltin.c +++ b/src/app/rpmostree-libbuiltin.c @@ -24,6 +24,7 @@ #include "rpmostree-libbuiltin.h" #include "rpmostree.h" +#include "rpmostree-util.h" #include "libglnx.h" @@ -43,6 +44,7 @@ rpmostree_usage_error (GOptionContext *context, g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, message); } +/* Print the diff between the booted and pending deployments */ gboolean rpmostree_print_treepkg_diff_from_sysroot_path (const gchar *sysroot_path, GCancellable *cancellable, @@ -64,6 +66,7 @@ out: return ret; } +/* Print the diff between the booted and pending deployments */ gboolean rpmostree_print_treepkg_diff (OstreeSysroot *sysroot, GCancellable *cancellable, @@ -89,8 +92,6 @@ rpmostree_print_treepkg_diff (OstreeSysroot *sysroot, g_autoptr(GPtrArray) added = NULL; g_autoptr(GPtrArray) modified_old = NULL; g_autoptr(GPtrArray) modified_new = NULL; - gboolean first; - guint i; if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error)) goto out; @@ -100,69 +101,7 @@ rpmostree_print_treepkg_diff (OstreeSysroot *sysroot, cancellable, error)) goto out; - g_assert (modified_old->len == modified_new->len); - - first = TRUE; - for (i = 0; i < modified_old->len; i++) - { - RpmOstreePackage *oldpkg = modified_old->pdata[i]; - RpmOstreePackage *newpkg = modified_new->pdata[i]; - const char *name = rpm_ostree_package_get_name (oldpkg); - - if (rpm_ostree_package_cmp (oldpkg, newpkg) > 0) - continue; - - if (first) - { - g_print ("Upgraded:\n"); - first = FALSE; - } - - g_print (" %s %s -> %s\n", name, - rpm_ostree_package_get_evr (oldpkg), - rpm_ostree_package_get_evr (newpkg)); - } - - first = TRUE; - for (i = 0; i < modified_old->len; i++) - { - RpmOstreePackage *oldpkg = modified_old->pdata[i]; - RpmOstreePackage *newpkg = modified_new->pdata[i]; - const char *name = rpm_ostree_package_get_name (oldpkg); - - if (rpm_ostree_package_cmp (oldpkg, newpkg) < 0) - continue; - - if (first) - { - g_print ("Downgraded:\n"); - first = FALSE; - } - - g_print (" %s %s -> %s\n", name, - rpm_ostree_package_get_evr (oldpkg), - rpm_ostree_package_get_evr (newpkg)); - } - - if (removed->len > 0) - g_print ("Removed:\n"); - for (i = 0; i < removed->len; i++) - { - RpmOstreePackage *pkg = removed->pdata[i]; - const char *nevra = rpm_ostree_package_get_nevra (pkg); - - g_print (" %s\n", nevra); - } - - if (added->len > 0) - g_print ("Added:\n"); - for (i = 0; i < added->len; i++) - { - RpmOstreePackage *pkg = added->pdata[i]; - const char *nevra = rpm_ostree_package_get_nevra (pkg); - - g_print (" %s\n", nevra); - } + rpmostree_diff_print (repo, removed, added, modified_old, modified_new); } ret = TRUE; diff --git a/src/libpriv/rpmostree-util.c b/src/libpriv/rpmostree-util.c index 8952e27f..8673460a 100644 --- a/src/libpriv/rpmostree-util.c +++ b/src/libpriv/rpmostree-util.c @@ -28,6 +28,7 @@ #include "rpmostree-util.h" #include "rpmostree-origin.h" +#include "rpmostree.h" #include "libglnx.h" int @@ -613,3 +614,78 @@ rpmostree_cache_branch_to_nevra (const char *cachebranch) return g_string_free (r, FALSE); } + +/* Given the result of rpm_ostree_db_diff(), print it. */ +void +rpmostree_diff_print (OstreeRepo *repo, + GPtrArray *removed, + GPtrArray *added, + GPtrArray *modified_old, + GPtrArray *modified_new) +{ + gboolean first; + + g_assert (modified_old->len == modified_new->len); + + first = TRUE; + for (guint i = 0; i < modified_old->len; i++) + { + RpmOstreePackage *oldpkg = modified_old->pdata[i]; + RpmOstreePackage *newpkg = modified_new->pdata[i]; + const char *name = rpm_ostree_package_get_name (oldpkg); + + if (rpm_ostree_package_cmp (oldpkg, newpkg) > 0) + continue; + + if (first) + { + g_print ("Upgraded:\n"); + first = FALSE; + } + + g_print (" %s %s -> %s\n", name, + rpm_ostree_package_get_evr (oldpkg), + rpm_ostree_package_get_evr (newpkg)); + } + + first = TRUE; + for (guint i = 0; i < modified_old->len; i++) + { + RpmOstreePackage *oldpkg = modified_old->pdata[i]; + RpmOstreePackage *newpkg = modified_new->pdata[i]; + const char *name = rpm_ostree_package_get_name (oldpkg); + + if (rpm_ostree_package_cmp (oldpkg, newpkg) < 0) + continue; + + if (first) + { + g_print ("Downgraded:\n"); + first = FALSE; + } + + g_print (" %s %s -> %s\n", name, + rpm_ostree_package_get_evr (oldpkg), + rpm_ostree_package_get_evr (newpkg)); + } + + if (removed->len > 0) + g_print ("Removed:\n"); + for (guint i = 0; i < removed->len; i++) + { + RpmOstreePackage *pkg = removed->pdata[i]; + const char *nevra = rpm_ostree_package_get_nevra (pkg); + + g_print (" %s\n", nevra); + } + + if (added->len > 0) + g_print ("Added:\n"); + for (guint i = 0; i < added->len; i++) + { + RpmOstreePackage *pkg = added->pdata[i]; + const char *nevra = rpm_ostree_package_get_nevra (pkg); + + g_print (" %s\n", nevra); + } +} diff --git a/src/libpriv/rpmostree-util.h b/src/libpriv/rpmostree-util.h index 8827cf87..241f6c3a 100644 --- a/src/libpriv/rpmostree-util.h +++ b/src/libpriv/rpmostree-util.h @@ -85,6 +85,12 @@ gs_file_get_path_cached (GFile *file) return rpmostree_file_get_path_cached (file); } +void rpmostree_diff_print (OstreeRepo *repo, + GPtrArray *removed, + GPtrArray *added, + GPtrArray *modified_old, + GPtrArray *modified_new); + gboolean rpmostree_deployment_get_layered_info (OstreeRepo *repo, OstreeDeployment *deployment,