From 5650f376fb1824ebe7472b2bdf515d092193e8f8 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 22 Oct 2020 17:33:45 +0000 Subject: [PATCH] Add --enable-rojig, disable by default We're seeing some CI failures that I think are a bug in rojig. In the bigger picture...we never actually started using this, and I think longer term shipping os updates via containers probably makes more sense. I put a *lot* of effort into this code and it's pretty cool so it's hard to just delete it. And *maybe* someone out there is using it (but I doubt it). So rather than just deleting it entirely let's make it a build-time option. I verified that it builds at least. --- Makefile-libpriv.am | 17 +++++++++++------ Makefile-rpm-ostree.am | 11 ++++++++--- configure.ac | 10 ++++++++++ src/app/rpmostree-builtin-compose.c | 2 ++ src/app/rpmostree-builtin-ex.c | 2 ++ src/app/rpmostree-ex-builtins.h | 2 ++ src/daemon/rpmostree-sysroot-upgrader.c | 4 ++++ src/libpriv/rpmostree-importer.c | 14 +++++++++++++- tests/compose/test-rojig-e2e.sh | 6 ++++++ tests/compose/test-rojig-pure.sh | 6 ++++++ tests/vmcheck/test-rojig-client.sh | 6 ++++++ 11 files changed, 70 insertions(+), 10 deletions(-) diff --git a/Makefile-libpriv.am b/Makefile-libpriv.am index b8cb9954..11a9010e 100644 --- a/Makefile-libpriv.am +++ b/Makefile-libpriv.am @@ -46,12 +46,6 @@ librpmostreepriv_la_SOURCES = \ src/libpriv/rpmostree-rpm-util.h \ src/libpriv/rpmostree-importer.c \ src/libpriv/rpmostree-importer.h \ - src/libpriv/rpmostree-rojig-build.c \ - src/libpriv/rpmostree-rojig-build.h \ - src/libpriv/rpmostree-rojig-assembler.c \ - src/libpriv/rpmostree-rojig-assembler.h \ - src/libpriv/rpmostree-rojig-core.h \ - src/libpriv/rpmostree-rojig-client.c \ src/libpriv/rpmostree-unpacker-core.c \ src/libpriv/rpmostree-unpacker-core.h \ src/libpriv/rpmostree-output.c \ @@ -66,6 +60,17 @@ librpmostreepriv_la_SOURCES = \ src/libpriv/rpmostree-libarchive-input-stream.h \ $(NULL) +if BUILDOPT_ROJIG +librpmostreepriv_la_SOURCES += \ + src/libpriv/rpmostree-rojig-build.c \ + src/libpriv/rpmostree-rojig-build.h \ + src/libpriv/rpmostree-rojig-assembler.c \ + src/libpriv/rpmostree-rojig-assembler.h \ + src/libpriv/rpmostree-rojig-core.h \ + src/libpriv/rpmostree-rojig-client.c \ + $(NULL) +endif + librpmostreepriv_la_CFLAGS = \ $(AM_CFLAGS) \ -I$(srcdir)/src/lib \ diff --git a/Makefile-rpm-ostree.am b/Makefile-rpm-ostree.am index b1cad834..12505fa2 100644 --- a/Makefile-rpm-ostree.am +++ b/Makefile-rpm-ostree.am @@ -43,8 +43,6 @@ rpm_ostree_SOURCES = src/app/main.c \ src/app/rpmostree-builtin-coreos-rootfs.c \ src/app/rpmostree-builtin-testutils.c \ src/app/rpmostree-builtin-container.c \ - src/app/rpmostree-ex-builtin-commit2rojig.c \ - src/app/rpmostree-ex-builtin-rojig2commit.c \ src/app/rpmostree-builtin-db.c \ src/app/rpmostree-builtin-start-daemon.c \ src/app/rpmostree-builtin-finalize-deployment.c \ @@ -63,12 +61,19 @@ rpm_ostree_SOURCES = src/app/main.c \ src/app/rpmostree-polkit-agent.h \ src/app/rpmostree-builtin-kargs.c \ src/app/rpmostree-compose-builtin-tree.c \ - src/app/rpmostree-compose-builtin-rojig.c \ src/app/rpmostree-composeutil.c \ src/app/rpmostree-composeutil.h \ src/app/rpmostree-builtin-compose.c \ $(NULL) +if BUILDOPT_ROJIG +rpm_ostree_SOURCES += \ + src/app/rpmostree-ex-builtin-commit2rojig.c \ + src/app/rpmostree-ex-builtin-rojig2commit.c \ + src/app/rpmostree-compose-builtin-rojig.c \ + $(NULL) +endif + rpm_ostree_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/app -I$(srcdir)/src/daemon \ -I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) \ -fvisibility=hidden -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS) diff --git a/configure.ac b/configure.ac index 4bd611a5..95411159 100644 --- a/configure.ac +++ b/configure.ac @@ -249,6 +249,15 @@ if test "${enable_lto}" = yes; then fi fi +AC_ARG_ENABLE(rojig, + AC_HELP_STRING([--enable-rojig], + [Support for shipping ostree commits via RPMs [default=no]])) +AM_CONDITIONAL([BUILDOPT_ROJIG], test x$enable_rojig = xyes) +AM_COND_IF([BUILDOPT_ROJIG], [ + RPM_OSTREE_FEATURES="$RPM_OSTREE_FEATURES rojig" + AC_DEFINE([BUILDOPT_ROJIG], 1, [Define if rojig is enabled]) +]) + dnl And propagate the release/debug type to cmake cmake_args=-DCMAKE_BUILD_TYPE=RelWithDebugInfo if test ${debug_release} = debug; then @@ -291,6 +300,7 @@ echo " $PACKAGE $VERSION introspection: $found_introspection + rojig: ${enable_rojig:-no} bubblewrap: $with_bubblewrap gtk-doc: $enable_gtk_doc rust: $rust_debug_release (lto: ${enable_lto:-no}) diff --git a/src/app/rpmostree-builtin-compose.c b/src/app/rpmostree-builtin-compose.c index 4fb67c8a..cd1cfe9e 100644 --- a/src/app/rpmostree-builtin-compose.c +++ b/src/app/rpmostree-builtin-compose.c @@ -41,9 +41,11 @@ static RpmOstreeCommand compose_subcommands[] = { { "commit", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD | RPM_OSTREE_BUILTIN_FLAG_REQUIRES_ROOT, "Commit a target path to an OSTree repository", rpmostree_compose_builtin_commit }, +#ifdef BUILDOPT_ROJIG { "rojig", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD | RPM_OSTREE_BUILTIN_FLAG_HIDDEN, "EXPERIMENTAL: Build a rojig RPM from a treefile, output to a local rpm-md repo", rpmostree_compose_builtin_rojig }, +#endif { NULL, 0, NULL, NULL } }; diff --git a/src/app/rpmostree-builtin-ex.c b/src/app/rpmostree-builtin-ex.c index 878697b0..fef120d5 100644 --- a/src/app/rpmostree-builtin-ex.c +++ b/src/app/rpmostree-builtin-ex.c @@ -28,10 +28,12 @@ static RpmOstreeCommand ex_subcommands[] = { rpmostree_ex_builtin_livefs }, { "container", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD, "Assemble local unprivileged containers", rpmostree_builtin_container }, +#ifdef BUILDOPT_ROJIG { "commit2rojig", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD, "Convert an OSTree commit into an rpm-ostree rojig", rpmostree_ex_builtin_commit2rojig }, { "rojig2commit", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD, "Convert an rpm-ostree rojig into an OSTree commit", rpmostree_ex_builtin_rojig2commit }, +#endif { "history", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD, "Inspect rpm-ostree history of the system", rpmostree_ex_builtin_history }, { NULL, 0, NULL, NULL } diff --git a/src/app/rpmostree-ex-builtins.h b/src/app/rpmostree-ex-builtins.h index da6271eb..ae666c41 100644 --- a/src/app/rpmostree-ex-builtins.h +++ b/src/app/rpmostree-ex-builtins.h @@ -32,8 +32,10 @@ G_BEGIN_DECLS BUILTINPROTO(unpack); BUILTINPROTO(livefs); +#ifdef BUILDOPT_ROJIG BUILTINPROTO(commit2rojig); BUILTINPROTO(rojig2commit); +#endif BUILTINPROTO(history); #undef BUILTINPROTO diff --git a/src/daemon/rpmostree-sysroot-upgrader.c b/src/daemon/rpmostree-sysroot-upgrader.c index 8df2327f..32e77a0a 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.c +++ b/src/daemon/rpmostree-sysroot-upgrader.c @@ -460,6 +460,7 @@ rpmostree_sysroot_upgrader_pull_base (RpmOstreeSysrootUpgrader *self, break; case RPMOSTREE_REFSPEC_TYPE_ROJIG: { +#ifdef BUILDOPT_ROJIG // Not implemented yet, though we could do a query for the provides if (override_commit) return glnx_throw (error, "Specifying commit overrides for rojig:// is not implemented yet"); @@ -502,6 +503,9 @@ rpmostree_sysroot_upgrader_pull_base (RpmOstreeSysrootUpgrader *self, if (rojig_changed) rpmostree_origin_set_rojig_description (self->origin, rojig_pkg); +#else + return glnx_throw (error, "rojig is not supported in this build of rpm-ostree"); +#endif } } diff --git a/src/libpriv/rpmostree-importer.c b/src/libpriv/rpmostree-importer.c index aa0bb474..45954c96 100644 --- a/src/libpriv/rpmostree-importer.c +++ b/src/libpriv/rpmostree-importer.c @@ -769,6 +769,7 @@ unprivileged_filter_cb (OstreeRepo *repo, return OSTREE_REPO_COMMIT_FILTER_ALLOW; } +#ifdef BUILDOPT_ROJIG static OstreeRepoCommitFilterResult rojig_filter_cb (OstreeRepo *repo, const char *path, @@ -812,6 +813,7 @@ rojig_xattr_cb (OstreeRepo *repo, RpmOstreeImporter *self = user_data; return g_steal_pointer (&self->rojig_next_xattrs); } +#endif static GVariant* xattr_cb (OstreeRepo *repo, @@ -876,7 +878,13 @@ import_rpm_to_repo (RpmOstreeImporter *self, */ const gboolean unprivileged = ostree_repo_get_mode (repo) == OSTREE_REPO_MODE_BARE_USER_ONLY; if (self->rojig_mode) - filter = rojig_filter_cb; + { +#ifdef BUILDOPT_ROJIG + filter = rojig_filter_cb; +#else + g_assert_not_reached (); +#endif + } else if (unprivileged) filter = unprivileged_filter_cb; else @@ -891,9 +899,13 @@ import_rpm_to_repo (RpmOstreeImporter *self, ostree_repo_commit_modifier_new (modifier_flags, filter, &fdata, NULL); if (self->rojig_mode) { +#ifdef BUILDOPT_ROJIG ostree_repo_commit_modifier_set_xattr_callback (modifier, rojig_xattr_cb, NULL, self); g_assert (self->sepolicy == NULL); +#else + g_assert_not_reached (); +#endif } else { diff --git a/tests/compose/test-rojig-e2e.sh b/tests/compose/test-rojig-e2e.sh index 0ddd71ce..517f4096 100755 --- a/tests/compose/test-rojig-e2e.sh +++ b/tests/compose/test-rojig-e2e.sh @@ -5,6 +5,12 @@ dn=$(cd "$(dirname "$0")" && pwd) # shellcheck source=libcomposetest.sh . "${dn}/libcomposetest.sh" +rpm-ostree --version > version.txt +if ! grep -q rojig version.txt; then + echo "ok skip no rojig support" + exit 0 +fi + # Add a local rpm-md repo so we can mutate local test packages treefile_append "repos" '["test-repo"]' build_rpm test-pkg \ diff --git a/tests/compose/test-rojig-pure.sh b/tests/compose/test-rojig-pure.sh index c4fd4438..51688653 100755 --- a/tests/compose/test-rojig-pure.sh +++ b/tests/compose/test-rojig-pure.sh @@ -5,6 +5,12 @@ dn=$(cd "$(dirname "$0")" && pwd) # shellcheck source=libcomposetest.sh . "${dn}/libcomposetest.sh" +rpm-ostree --version > version.txt +if ! grep -q rojig version.txt; then + echo "ok skip no rojig support" + exit 0 +fi + treefile_set "automatic-version-prefix" '"42"' treefile_set "documentation" 'True' mkdir rojig-repo diff --git a/tests/vmcheck/test-rojig-client.sh b/tests/vmcheck/test-rojig-client.sh index fc7f373c..b35a773a 100755 --- a/tests/vmcheck/test-rojig-client.sh +++ b/tests/vmcheck/test-rojig-client.sh @@ -30,6 +30,12 @@ if test "${osid}" != 'ID=fedora'; then exit 0 fi +vm_rpmostree --version > version.txt +if ! grep -q rojig version.txt; then + echo "ok skip no rojig support" + exit 0 +fi + # Test rebasing to https://pagure.io/fedora-atomic-host-continuous # in rojig:// mode.