diff --git a/Makefile-libostree-defines.am b/Makefile-libostree-defines.am index e3ec3950..1531cf8c 100644 --- a/Makefile-libostree-defines.am +++ b/Makefile-libostree-defines.am @@ -37,3 +37,7 @@ libostree_public_headers = \ src/libostree/ostree-bootconfig-parser.h \ src/libostree/ostree-repo-deprecated.h \ $(NULL) + +# This one is generated via configure.ac, and the gtk-doc +# code hence needs to look in the builddir. +libostree_public_built_headers = src/libostree/ostree-version.h diff --git a/Makefile-libostree.am b/Makefile-libostree.am index 70452f1a..0a114884 100644 --- a/Makefile-libostree.am +++ b/Makefile-libostree.am @@ -24,9 +24,9 @@ noinst_LTLIBRARIES += libostree-kernel-args.la if ENABLE_RUST bupsplitpath = @abs_top_builddir@/target/@RUST_TARGET_SUBDIR@/libbupsplit_rs.a -BUPSPLIT_RUST_SOURCES = rust/src/bupsplit.rs -EXTRA_DIST += $(BUPSPLIT_RUST_SOURCES) -$(bupsplitpath): Makefile $(BUPSPLIT_RUST_SOURCES) +BUPSPLIT_RUST_SRCS = rust/src/bupsplit.rs +EXTRA_DIST += $(BUPSPLIT_RUST_SRCS) +$(bupsplitpath): Makefile $(BUPSPLIT_RUST_SRCS) cd $(top_srcdir)/rust && CARGO_TARGET_DIR=@abs_top_builddir@/target cargo build --verbose $(CARGO_RELEASE_ARGS) else bupsplitpath = libbupsplit.la @@ -44,7 +44,7 @@ libostree_kernel_args_la_LIBADD = $(OT_INTERNAL_GIO_UNIX_LIBS) lib_LTLIBRARIES += libostree-1.la libostreeincludedir = $(includedir)/ostree-1 -libostreeinclude_HEADERS = $(libostree_public_headers) +libostreeinclude_HEADERS = $(libostree_public_headers) $(libostree_public_built_headers) ENUM_TYPES = $(NULL) ENUM_TYPES += $(srcdir)/src/libostree/ostree-fetcher.h @@ -107,6 +107,7 @@ libostree_1_la_SOURCES = \ src/libostree/ostree-repo-file-enumerator.c \ src/libostree/ostree-repo-file-enumerator.h \ src/libostree/ostree-sepolicy.c \ + src/libostree/ostree-sepolicy-private.h \ src/libostree/ostree-sysroot-private.h \ src/libostree/ostree-sysroot.c \ src/libostree/ostree-sysroot-cleanup.c \ @@ -147,10 +148,11 @@ libostree_1_la_SOURCES += \ endif libostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/bsdiff -I$(srcdir)/libglnx -I$(srcdir)/src/libotutil -I$(srcdir)/src/libostree -I$(builddir)/src/libostree \ - $(OT_INTERNAL_GIO_UNIX_CFLAGS) $(OT_INTERNAL_GPGME_CFLAGS) $(OT_DEP_LZMA_CFLAGS) $(OT_DEP_ZLIB_CFLAGS) \ + $(OT_INTERNAL_GIO_UNIX_CFLAGS) $(OT_INTERNAL_GPGME_CFLAGS) $(OT_DEP_LZMA_CFLAGS) $(OT_DEP_ZLIB_CFLAGS) $(OT_DEP_OPENSSL_CFLAGS) \ -fvisibility=hidden '-D_OSTREE_PUBLIC=__attribute__((visibility("default"))) extern' libostree_1_la_LDFLAGS = -version-number 1:0:0 -Bsymbolic-functions -Wl,--version-script=$(top_srcdir)/src/libostree/libostree.sym -libostree_1_la_LIBADD = libotutil.la libglnx.la libbsdiff.la libostree-kernel-args.la $(OT_INTERNAL_GIO_UNIX_LIBS) $(OT_INTERNAL_GPGME_LIBS) $(OT_DEP_LZMA_LIBS) $(OT_DEP_ZLIB_LIBS) +libostree_1_la_LIBADD = libotutil.la libglnx.la libbsdiff.la libostree-kernel-args.la $(OT_INTERNAL_GIO_UNIX_LIBS) $(OT_INTERNAL_GPGME_LIBS) \ + $(OT_DEP_LZMA_LIBS) $(OT_DEP_ZLIB_LIBS) $(OT_DEP_OPENSSL_LIBS) libostree_1_la_LIBADD += $(bupsplitpath) EXTRA_libostree_1_la_DEPENDENCIES = $(top_srcdir)/src/libostree/libostree.sym @@ -209,7 +211,7 @@ OSTree_1_0_gir_INCLUDES = Gio-2.0 OSTree_1_0_gir_CFLAGS = $(libostree_1_la_CFLAGS) OSTree_1_0_gir_LIBS = libostree-1.la OSTree_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=Ostree --symbol-prefix=ostree -OSTree_1_0_gir_FILES = $(libostreeinclude_HEADERS) $(filter-out %-private.h,$(libostree_1_la_SOURCES)) +OSTree_1_0_gir_FILES = $(libostreeinclude_HEADERS) $(filter-out %-private.h %/ostree-soup-uri.h,$(libostree_1_la_SOURCES)) INTROSPECTION_GIRS += OSTree-1.0.gir gir_DATA += OSTree-1.0.gir typelib_DATA += OSTree-1.0.typelib @@ -225,7 +227,8 @@ EXTRA_DIST += src/libostree/README-gpg src/libostree/bupsplit.h \ src/libostree/ostree-enumtypes.h.template \ src/libostree/ostree-enumtypes.c.template \ src/libostree/ostree-deployment-private.h \ - src/libostree/ostree-repo-deprecated.h + src/libostree/ostree-repo-deprecated.h \ + src/libostree/ostree-version.h install-mkdir-remotes-d-hook: mkdir -p $(DESTDIR)$(sysconfdir)/ostree/remotes.d diff --git a/Makefile-ostree.am b/Makefile-ostree.am index 0b520c68..4bd623d7 100644 --- a/Makefile-ostree.am +++ b/Makefile-ostree.am @@ -105,7 +105,7 @@ EXTRA_DIST += src/ostree/parse-datetime.y CLEANFILES += src/ostree/parse-datetime.c ostree_bin_shared_cflags = $(AM_CFLAGS) -I$(srcdir)/src/libotutil -I$(srcdir)/src/libostree \ - -I$(srcdir)/src/ostree -I$(srcdir)/libglnx $(OT_INTERNAL_GIO_UNIX_CFLAGS) \ + -I$(builddir)/src/libostree -I$(srcdir)/src/ostree -I$(srcdir)/libglnx $(OT_INTERNAL_GIO_UNIX_CFLAGS) \ -DPKGLIBEXECDIR=\"$(pkglibexecdir)\" ostree_bin_shared_ldadd = $(AM_LDFLAGS) libglnx.la libotutil.la libostree-1.la \ $(OT_INTERNAL_GIO_UNIX_LIBS) diff --git a/Makefile-otutil.am b/Makefile-otutil.am index ee892a70..db632705 100644 --- a/Makefile-otutil.am +++ b/Makefile-otutil.am @@ -22,6 +22,8 @@ noinst_LTLIBRARIES += libotutil.la libotutil_la_SOURCES = \ src/libotutil/ot-checksum-utils.c \ src/libotutil/ot-checksum-utils.h \ + src/libotutil/ot-checksum-instream.c \ + src/libotutil/ot-checksum-instream.h \ src/libotutil/ot-fs-utils.c \ src/libotutil/ot-fs-utils.h \ src/libotutil/ot-keyfile-utils.c \ @@ -30,8 +32,6 @@ libotutil_la_SOURCES = \ src/libotutil/ot-opt-utils.h \ src/libotutil/ot-unix-utils.c \ src/libotutil/ot-unix-utils.h \ - src/libotutil/ot-spawn-utils.c \ - src/libotutil/ot-spawn-utils.h \ src/libotutil/ot-variant-utils.c \ src/libotutil/ot-variant-utils.h \ src/libotutil/ot-gio-utils.c \ diff --git a/Makefile-tests.am b/Makefile-tests.am index fd755ee1..8389331d 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -28,6 +28,7 @@ EXTRA_DIST += \ # include the builddir in $PATH so we find our just-built ostree # binary. TESTS_ENVIRONMENT += OT_TESTS_DEBUG=1 \ + OSTREE_UNINSTALLED_SRCDIR=$(abs_top_srcdir) \ OSTREE_UNINSTALLED=$(abs_top_builddir) \ G_DEBUG=fatal-warnings \ GI_TYPELIB_PATH=$$(cd $(top_builddir) && pwd)$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH} \ @@ -46,6 +47,7 @@ dist_uninstalled_test_scripts = tests/test-symbols.sh dist_test_scripts = \ tests/test-basic.sh \ tests/test-basic-user.sh \ + tests/test-basic-user-only.sh \ tests/test-pull-subpath.sh \ tests/test-archivez.sh \ tests/test-remote-add.sh \ @@ -98,6 +100,7 @@ dist_test_scripts = \ tests/test-switchroot.sh \ tests/test-pull-contenturl.sh \ tests/test-pull-mirrorlist.sh \ + tests/coccinelle.sh \ $(NULL) if BUILDOPT_FUSE diff --git a/Makefile.am b/Makefile.am index cc0e76f5..78cd6653 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ OSTREE_GITREV=$(shell if command -v git >/dev/null 2>&1 && test -d $(srcdir)/.gi ACLOCAL_AMFLAGS = -I buildutil -I libglnx ${ACLOCAL_FLAGS} AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \ -DLOCALEDIR=\"$(datadir)/locale\" -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSHORTENED_SYSCONFDIR=\"$(shortened_sysconfdir)\" \ + -DTARGET_PREFIX='"$(prefix)"' -DSHORTENED_SYSCONFDIR=\"$(shortened_sysconfdir)\" \ -DOSTREE_FEATURES='"$(OSTREE_FEATURES)"' \ -DOSTREE_COMPILATION \ -DG_LOG_DOMAIN=\"OSTree\" \ diff --git a/Makefile.in b/Makefile.in index 978121ab..d17f7720 100644 --- a/Makefile.in +++ b/Makefile.in @@ -340,14 +340,13 @@ host_triplet = @host@ bin_PROGRAMS = ostree$(EXEEXT) $(am__EXEEXT_1) sbin_PROGRAMS = libexec_PROGRAMS = -pkglibexec_PROGRAMS = $(am__EXEEXT_11) -noinst_PROGRAMS = $(am__EXEEXT_8) tests/test-rollsum-cli$(EXEEXT) -ostree_boot_PROGRAMS = $(am__EXEEXT_9) $(am__EXEEXT_10) -TESTS = $(am__EXEEXT_3) $(am__EXEEXT_13) \ - $(dist_uninstalled_test_scripts) test-libglnx-xattrs$(EXEEXT) -installed_test_PROGRAMS = $(am__EXEEXT_7) -check_PROGRAMS = $(am__EXEEXT_5) test-libglnx-xattrs$(EXEEXT) \ - $(am__EXEEXT_6) +pkglibexec_PROGRAMS = $(am__EXEEXT_12) +noinst_PROGRAMS = $(am__EXEEXT_9) tests/test-rollsum-cli$(EXEEXT) +ostree_boot_PROGRAMS = $(am__EXEEXT_10) $(am__EXEEXT_11) +TESTS = $(am__EXEEXT_3) $(am__EXEEXT_14) \ + $(dist_uninstalled_test_scripts) $(am__EXEEXT_6) +installed_test_PROGRAMS = $(am__EXEEXT_8) +check_PROGRAMS = $(am__EXEEXT_5) $(am__EXEEXT_6) $(am__EXEEXT_7) @ENABLE_ALWAYS_BUILD_TESTS_TRUE@am__append_1 = $(all_test_ltlibs) @ENABLE_ALWAYS_BUILD_TESTS_TRUE@am__append_2 = $(all_test_programs) @ENABLE_ALWAYS_BUILD_TESTS_TRUE@am__append_3 = $(all_test_scripts) @@ -375,7 +374,7 @@ check_PROGRAMS = $(am__EXEEXT_5) test-libglnx-xattrs$(EXEEXT) \ @ENABLE_INSTALLED_TESTS_TRUE@am__append_13 = $(installed_test_meta_DATA) @ENABLE_GTK_DOC_TRUE@am__append_14 = apidoc @ENABLE_RUST_TRUE@am__append_15 = $(srcdir)/rust/Cargo.toml $(srcdir)/rust/cargo-vendor-config -@ENABLE_RUST_TRUE@am__append_16 = $(BUPSPLIT_RUST_SOURCES) +@ENABLE_RUST_TRUE@am__append_16 = $(BUPSPLIT_RUST_SRCS) @ENABLE_RUST_FALSE@am__append_17 = libbupsplit.la @USE_LIBARCHIVE_TRUE@am__append_18 = src/libostree/ostree-libarchive-input-stream.h \ @USE_LIBARCHIVE_TRUE@ src/libostree/ostree-libarchive-input-stream.c \ @@ -487,7 +486,8 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = src/libostree/ostree-1.pc +CONFIG_CLEAN_FILES = src/libostree/ostree-1.pc \ + src/libostree/ostree-version.h CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ @@ -585,10 +585,10 @@ am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) libostree_1_la_DEPENDENCIES = libotutil.la libglnx.la libbsdiff.la \ libostree-kernel-args.la $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(bupsplitpath) $(am__DEPENDENCIES_4) \ - $(am__DEPENDENCIES_5) $(am__DEPENDENCIES_6) \ - $(am__DEPENDENCIES_7) $(am__DEPENDENCIES_8) \ - $(am__DEPENDENCIES_9) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(bupsplitpath) \ + $(am__DEPENDENCIES_4) $(am__DEPENDENCIES_5) \ + $(am__DEPENDENCIES_6) $(am__DEPENDENCIES_7) \ + $(am__DEPENDENCIES_8) $(am__DEPENDENCIES_9) am__libostree_1_la_SOURCES_DIST = \ src/libostree/ostree-async-progress.c \ src/libostree/ostree-cmdprivate.h \ @@ -624,6 +624,7 @@ am__libostree_1_la_SOURCES_DIST = \ src/libostree/ostree-repo-file-enumerator.c \ src/libostree/ostree-repo-file-enumerator.h \ src/libostree/ostree-sepolicy.c \ + src/libostree/ostree-sepolicy-private.h \ src/libostree/ostree-sysroot-private.h \ src/libostree/ostree-sysroot.c \ src/libostree/ostree-sysroot-cleanup.c \ @@ -755,11 +756,11 @@ libotutil_la_DEPENDENCIES = $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_1) am_libotutil_la_OBJECTS = \ src/libotutil/libotutil_la-ot-checksum-utils.lo \ + src/libotutil/libotutil_la-ot-checksum-instream.lo \ src/libotutil/libotutil_la-ot-fs-utils.lo \ src/libotutil/libotutil_la-ot-keyfile-utils.lo \ src/libotutil/libotutil_la-ot-opt-utils.lo \ src/libotutil/libotutil_la-ot-unix-utils.lo \ - src/libotutil/libotutil_la-ot-spawn-utils.lo \ src/libotutil/libotutil_la-ot-variant-utils.lo \ src/libotutil/libotutil_la-ot-gio-utils.lo \ src/libotutil/libotutil_la-ot-log-utils.lo \ @@ -799,12 +800,14 @@ am__EXEEXT_3 = tests/test-varint$(EXEEXT) \ $(am__EXEEXT_2) am__EXEEXT_4 = $(am__EXEEXT_3) @ENABLE_ALWAYS_BUILD_TESTS_FALSE@am__EXEEXT_5 = $(am__EXEEXT_4) -@BUILDOPT_SYSTEMD_FALSE@am__EXEEXT_6 = ostree-remount$(EXEEXT) -@ENABLE_INSTALLED_TESTS_TRUE@am__EXEEXT_7 = $(am__EXEEXT_3) -@ENABLE_ALWAYS_BUILD_TESTS_TRUE@am__EXEEXT_8 = $(am__EXEEXT_4) -@BUILDOPT_SYSTEMD_TRUE@am__EXEEXT_9 = ostree-remount$(EXEEXT) -@BUILDOPT_USE_STATIC_COMPILER_FALSE@am__EXEEXT_10 = ostree-prepare-root$(EXEEXT) -@USE_LIBSOUP_TRUE@am__EXEEXT_11 = ostree-trivial-httpd$(EXEEXT) +am__EXEEXT_6 = test-libglnx-xattrs$(EXEEXT) test-libglnx-fdio$(EXEEXT) \ + test-libglnx-errors$(EXEEXT) +@BUILDOPT_SYSTEMD_FALSE@am__EXEEXT_7 = ostree-remount$(EXEEXT) +@ENABLE_INSTALLED_TESTS_TRUE@am__EXEEXT_8 = $(am__EXEEXT_3) +@ENABLE_ALWAYS_BUILD_TESTS_TRUE@am__EXEEXT_9 = $(am__EXEEXT_4) +@BUILDOPT_SYSTEMD_TRUE@am__EXEEXT_10 = ostree-remount$(EXEEXT) +@BUILDOPT_USE_STATIC_COMPILER_FALSE@am__EXEEXT_11 = ostree-prepare-root$(EXEEXT) +@USE_LIBSOUP_TRUE@am__EXEEXT_12 = ostree-trivial-httpd$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(installed_test_PROGRAMS) \ $(libexec_PROGRAMS) $(noinst_PROGRAMS) $(ostree_boot_PROGRAMS) \ $(pkglibexec_PROGRAMS) $(sbin_PROGRAMS) @@ -962,6 +965,21 @@ rofiles_fuse_OBJECTS = $(am_rofiles_fuse_OBJECTS) rofiles_fuse_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(rofiles_fuse_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_test_libglnx_errors_OBJECTS = libglnx/tests/test_libglnx_errors-test-libglnx-errors.$(OBJEXT) +test_libglnx_errors_OBJECTS = $(am_test_libglnx_errors_OBJECTS) +test_libglnx_errors_DEPENDENCIES = $(am__DEPENDENCIES_2) libglnx.la +test_libglnx_errors_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(test_libglnx_errors_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +am_test_libglnx_fdio_OBJECTS = \ + libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.$(OBJEXT) +test_libglnx_fdio_OBJECTS = $(am_test_libglnx_fdio_OBJECTS) +test_libglnx_fdio_DEPENDENCIES = $(am__DEPENDENCIES_2) libglnx.la +test_libglnx_fdio_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(test_libglnx_fdio_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ am_test_libglnx_xattrs_OBJECTS = libglnx/tests/test_libglnx_xattrs-test-libglnx-xattrs.$(OBJEXT) test_libglnx_xattrs_OBJECTS = $(am_test_libglnx_xattrs_OBJECTS) test_libglnx_xattrs_DEPENDENCIES = $(am__DEPENDENCIES_2) libglnx.la @@ -1155,6 +1173,7 @@ SOURCES = $(libbsdiff_la_SOURCES) $(libbupsplit_la_SOURCES) \ $(libreaddir_rand_la_SOURCES) $(ostree_SOURCES) \ $(ostree_prepare_root_SOURCES) $(ostree_remount_SOURCES) \ $(ostree_trivial_httpd_SOURCES) $(rofiles_fuse_SOURCES) \ + $(test_libglnx_errors_SOURCES) $(test_libglnx_fdio_SOURCES) \ $(test_libglnx_xattrs_SOURCES) tests/test-basic-c.c \ tests/test-bsdiff.c $(tests_test_checksum_SOURCES) \ $(tests_test_gpg_verify_result_SOURCES) \ @@ -1175,6 +1194,7 @@ DIST_SOURCES = $(libbsdiff_la_SOURCES) \ $(ostree_prepare_root_SOURCES) $(ostree_remount_SOURCES) \ $(am__ostree_trivial_httpd_SOURCES_DIST) \ $(am__rofiles_fuse_SOURCES_DIST) \ + $(test_libglnx_errors_SOURCES) $(test_libglnx_fdio_SOURCES) \ $(test_libglnx_xattrs_SOURCES) tests/test-basic-c.c \ tests/test-bsdiff.c $(tests_test_checksum_SOURCES) \ $(tests_test_gpg_verify_result_SOURCES) \ @@ -1403,15 +1423,16 @@ am__set_TESTS_bases = \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) -am__EXEEXT_12 = -am__EXEEXT_13 = tests/test-basic.sh tests/test-basic-user.sh \ - tests/test-pull-subpath.sh tests/test-archivez.sh \ - tests/test-remote-add.sh tests/test-remote-headers.sh \ - tests/test-remote-gpg-import.sh tests/test-commit-sign.sh \ - tests/test-export.sh tests/test-help.sh \ - tests/test-libarchive.sh tests/test-parent.sh \ - tests/test-pull-archive-z.sh tests/test-pull-commit-only.sh \ - tests/test-pull-depth.sh tests/test-pull-mirror-summary.sh \ +am__EXEEXT_13 = +am__EXEEXT_14 = tests/test-basic.sh tests/test-basic-user.sh \ + tests/test-basic-user-only.sh tests/test-pull-subpath.sh \ + tests/test-archivez.sh tests/test-remote-add.sh \ + tests/test-remote-headers.sh tests/test-remote-gpg-import.sh \ + tests/test-commit-sign.sh tests/test-export.sh \ + tests/test-help.sh tests/test-libarchive.sh \ + tests/test-parent.sh tests/test-pull-archive-z.sh \ + tests/test-pull-commit-only.sh tests/test-pull-depth.sh \ + tests/test-pull-mirror-summary.sh \ tests/test-pull-large-metadata.sh tests/test-pull-metalink.sh \ tests/test-pull-summary-sigs.sh tests/test-pull-resume.sh \ tests/test-pull-repeated.sh tests/test-pull-untrusted.sh \ @@ -1437,8 +1458,9 @@ am__EXEEXT_13 = tests/test-basic.sh tests/test-basic-user.sh \ tests/test-auto-summary.sh tests/test-prune.sh \ tests/test-refs.sh tests/test-demo-buildsystem.sh \ tests/test-switchroot.sh tests/test-pull-contenturl.sh \ - tests/test-pull-mirrorlist.sh $(am__EXEEXT_12) \ - $(am__append_51) $(am__append_53) $(am__append_54) + tests/test-pull-mirrorlist.sh tests/coccinelle.sh \ + $(am__EXEEXT_13) $(am__append_51) $(am__append_53) \ + $(am__append_54) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) @@ -1478,7 +1500,8 @@ am__DIST_COMMON = $(srcdir)/Makefile-boot.am \ $(top_srcdir)/build-aux/missing \ $(top_srcdir)/build-aux/test-driver \ $(top_srcdir)/buildutil/glib-tap.mk \ - $(top_srcdir)/src/libostree/ostree-1.pc.in COPYING TODO \ + $(top_srcdir)/src/libostree/ostree-1.pc.in \ + $(top_srcdir)/src/libostree/ostree-version.h.in COPYING TODO \ build-aux/compile build-aux/config.guess build-aux/config.sub \ build-aux/depcomp build-aux/install-sh build-aux/ltmain.sh \ build-aux/missing @@ -1619,6 +1642,8 @@ OT_DEP_LIBMOUNT_CFLAGS = @OT_DEP_LIBMOUNT_CFLAGS@ OT_DEP_LIBMOUNT_LIBS = @OT_DEP_LIBMOUNT_LIBS@ OT_DEP_LZMA_CFLAGS = @OT_DEP_LZMA_CFLAGS@ OT_DEP_LZMA_LIBS = @OT_DEP_LZMA_LIBS@ +OT_DEP_OPENSSL_CFLAGS = @OT_DEP_OPENSSL_CFLAGS@ +OT_DEP_OPENSSL_LIBS = @OT_DEP_OPENSSL_LIBS@ OT_DEP_SELINUX_CFLAGS = @OT_DEP_SELINUX_CFLAGS@ OT_DEP_SELINUX_LIBS = @OT_DEP_SELINUX_LIBS@ OT_DEP_SOUP_CFLAGS = @OT_DEP_SOUP_CFLAGS@ @@ -1637,6 +1662,7 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ +RELEASE_VERSION = @RELEASE_VERSION@ RUST_TARGET_SUBDIR = @RUST_TARGET_SUBDIR@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -1647,6 +1673,7 @@ VERSION = @VERSION@ WARN_CFLAGS = @WARN_CFLAGS@ XSLTPROC = @XSLTPROC@ YACC = @YACC@ +YEAR_VERSION = @YEAR_VERSION@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ @@ -1709,7 +1736,7 @@ top_srcdir = @top_srcdir@ # Common variables AM_CPPFLAGS = -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \ -DLOCALEDIR=\"$(datadir)/locale\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DSYSCONFDIR=\"$(sysconfdir)\" -DTARGET_PREFIX='"$(prefix)"' \ -DSHORTENED_SYSCONFDIR=\"$(shortened_sysconfdir)\" \ -DOSTREE_FEATURES='"$(OSTREE_FEATURES)"' -DOSTREE_COMPILATION \ -DG_LOG_DOMAIN=\"OSTree\" -DOSTREE_GITREV='"$(OSTREE_GITREV)"' \ @@ -1743,11 +1770,11 @@ EXTRA_DIST = $(all_dist_test_scripts) $(all_dist_test_data) autogen.sh \ src/libostree/ostree-enumtypes.c.template \ src/libostree/ostree-deployment-private.h \ src/libostree/ostree-repo-deprecated.h \ - src/ostree/parse-datetime.y buildutil/tap-driver.sh \ - buildutil/tap-test tests/glib.supp tests/ostree.supp $(NULL) \ - $(am__append_52) $(am__append_55) tests/libtest.sh \ - $(am__append_56) tests/libostreetest.h tests/libtest.sh \ - tests/gpg-verify-data/README.md $(NULL) \ + src/libostree/ostree-version.h src/ostree/parse-datetime.y \ + buildutil/tap-driver.sh buildutil/tap-test tests/glib.supp \ + tests/ostree.supp $(NULL) $(am__append_52) $(am__append_55) \ + tests/libtest.sh $(am__append_56) tests/libostreetest.h \ + tests/libtest.sh tests/gpg-verify-data/README.md $(NULL) \ src/boot/dracut/module-setup.sh src/boot/dracut/ostree.conf \ src/boot/mkinitcpio/ostree \ src/boot/ostree-prepare-root.service \ @@ -1778,6 +1805,7 @@ TESTS_ENVIRONMENT = G_TEST_SRCDIR="$(abs_srcdir)" \ G_TEST_BUILDDIR="$(abs_builddir)" UNINSTALLEDTESTS=1 \ G_DEBUG=gc-friendly MALLOC_CHECK_=2 \ MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) OT_TESTS_DEBUG=1 \ + OSTREE_UNINSTALLED_SRCDIR=$(abs_top_srcdir) \ OSTREE_UNINSTALLED=$(abs_top_builddir) G_DEBUG=fatal-warnings \ GI_TYPELIB_PATH=$$(cd $(top_builddir) && \ pwd)$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH} \ @@ -1878,9 +1906,16 @@ libglnx_la_SOURCES = \ libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags) libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic libglnx_la_LIBADD = $(libglnx_libs) +libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors test_libglnx_xattrs_SOURCES = libglnx/tests/test-libglnx-xattrs.c test_libglnx_xattrs_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags) test_libglnx_xattrs_LDADD = $(libglnx_libs) libglnx.la +test_libglnx_fdio_SOURCES = libglnx/tests/test-libglnx-fdio.c +test_libglnx_fdio_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags) +test_libglnx_fdio_LDADD = $(libglnx_libs) libglnx.la +test_libglnx_errors_SOURCES = libglnx/tests/test-libglnx-errors.c +test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags) +test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la libbsdiff_srcpath := $(srcdir)/bsdiff libbsdiff_cflags := $(OT_DEP_GIO_UNIX_CFLAGS) "-I$(bsdiff_srcpath)" libbsdiff_libs := $(OT_DEP_GIO_UNIX_LIBS) @@ -1893,6 +1928,8 @@ libbsdiff_la_CFLAGS = $(AM_CFLAGS) libotutil_la_SOURCES = \ src/libotutil/ot-checksum-utils.c \ src/libotutil/ot-checksum-utils.h \ + src/libotutil/ot-checksum-instream.c \ + src/libotutil/ot-checksum-instream.h \ src/libotutil/ot-fs-utils.c \ src/libotutil/ot-fs-utils.h \ src/libotutil/ot-keyfile-utils.c \ @@ -1901,8 +1938,6 @@ libotutil_la_SOURCES = \ src/libotutil/ot-opt-utils.h \ src/libotutil/ot-unix-utils.c \ src/libotutil/ot-unix-utils.h \ - src/libotutil/ot-spawn-utils.c \ - src/libotutil/ot-spawn-utils.h \ src/libotutil/ot-variant-utils.c \ src/libotutil/ot-variant-utils.h \ src/libotutil/ot-gio-utils.c \ @@ -1939,9 +1974,13 @@ libostree_public_headers = \ src/libostree/ostree-repo-deprecated.h \ $(NULL) + +# This one is generated via configure.ac, and the gtk-doc +# code hence needs to look in the builddir. +libostree_public_built_headers = src/libostree/ostree-version.h @ENABLE_RUST_FALSE@bupsplitpath = libbupsplit.la @ENABLE_RUST_TRUE@bupsplitpath = @abs_top_builddir@/target/@RUST_TARGET_SUBDIR@/libbupsplit_rs.a -@ENABLE_RUST_TRUE@BUPSPLIT_RUST_SOURCES = rust/src/bupsplit.rs +@ENABLE_RUST_TRUE@BUPSPLIT_RUST_SRCS = rust/src/bupsplit.rs @ENABLE_RUST_FALSE@libbupsplit_la_SOURCES = src/libostree/bupsplit.h src/libostree/bupsplit.c libostree_kernel_args_la_SOURCES = \ src/libostree/ostree-kernel-args.h \ @@ -1951,7 +1990,7 @@ libostree_kernel_args_la_SOURCES = \ libostree_kernel_args_la_CFLAGS = -I$(srcdir)/libglnx $(OT_INTERNAL_GIO_UNIX_CFLAGS) libostree_kernel_args_la_LIBADD = $(OT_INTERNAL_GIO_UNIX_LIBS) libostreeincludedir = $(includedir)/ostree-1 -libostreeinclude_HEADERS = $(libostree_public_headers) +libostreeinclude_HEADERS = $(libostree_public_headers) $(libostree_public_built_headers) ENUM_TYPES = $(NULL) $(srcdir)/src/libostree/ostree-fetcher.h nodist_libostree_1_la_SOURCES = \ src/libostree/ostree-enumtypes.h \ @@ -1992,6 +2031,7 @@ libostree_1_la_SOURCES = src/libostree/ostree-async-progress.c \ src/libostree/ostree-repo-file-enumerator.c \ src/libostree/ostree-repo-file-enumerator.h \ src/libostree/ostree-sepolicy.c \ + src/libostree/ostree-sepolicy-private.h \ src/libostree/ostree-sysroot-private.h \ src/libostree/ostree-sysroot.c \ src/libostree/ostree-sysroot-cleanup.c \ @@ -2024,7 +2064,7 @@ libostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/bsdiff \ -I$(srcdir)/src/libostree -I$(builddir)/src/libostree \ $(OT_INTERNAL_GIO_UNIX_CFLAGS) $(OT_INTERNAL_GPGME_CFLAGS) \ $(OT_DEP_LZMA_CFLAGS) $(OT_DEP_ZLIB_CFLAGS) \ - -fvisibility=hidden \ + $(OT_DEP_OPENSSL_CFLAGS) -fvisibility=hidden \ '-D_OSTREE_PUBLIC=__attribute__((visibility("default"))) \ extern' $(am__append_20) $(am__append_22) $(am__append_26) \ $(am__append_29) $(am__append_31) $(am__append_33) @@ -2032,16 +2072,16 @@ libostree_1_la_LDFLAGS = -version-number 1:0:0 -Bsymbolic-functions -Wl,--versio libostree_1_la_LIBADD = libotutil.la libglnx.la libbsdiff.la \ libostree-kernel-args.la $(OT_INTERNAL_GIO_UNIX_LIBS) \ $(OT_INTERNAL_GPGME_LIBS) $(OT_DEP_LZMA_LIBS) \ - $(OT_DEP_ZLIB_LIBS) $(bupsplitpath) $(am__append_21) \ - $(am__append_23) $(am__append_27) $(am__append_30) \ - $(am__append_32) $(am__append_34) + $(OT_DEP_ZLIB_LIBS) $(OT_DEP_OPENSSL_LIBS) $(bupsplitpath) \ + $(am__append_21) $(am__append_23) $(am__append_27) \ + $(am__append_30) $(am__append_32) $(am__append_34) EXTRA_libostree_1_la_DEPENDENCIES = $(top_srcdir)/src/libostree/libostree.sym @BUILDOPT_INTROSPECTION_TRUE@OSTree_1_0_gir_EXPORT_PACKAGES = ostree-1 @BUILDOPT_INTROSPECTION_TRUE@OSTree_1_0_gir_INCLUDES = Gio-2.0 @BUILDOPT_INTROSPECTION_TRUE@OSTree_1_0_gir_CFLAGS = $(libostree_1_la_CFLAGS) @BUILDOPT_INTROSPECTION_TRUE@OSTree_1_0_gir_LIBS = libostree-1.la @BUILDOPT_INTROSPECTION_TRUE@OSTree_1_0_gir_SCANNERFLAGS = --warn-all --identifier-prefix=Ostree --symbol-prefix=ostree -@BUILDOPT_INTROSPECTION_TRUE@OSTree_1_0_gir_FILES = $(libostreeinclude_HEADERS) $(filter-out %-private.h,$(libostree_1_la_SOURCES)) +@BUILDOPT_INTROSPECTION_TRUE@OSTree_1_0_gir_FILES = $(libostreeinclude_HEADERS) $(filter-out %-private.h %/ostree-soup-uri.h,$(libostree_1_la_SOURCES)) gpgreadme_DATA = src/libostree/README-gpg gpgreadmedir = $(datadir)/ostree/trusted.gpg.d @@ -2095,7 +2135,7 @@ ostree_SOURCES = src/ostree/main.c src/ostree/ot-builtin-admin.c \ src/ostree/ot-remote-builtin-summary.c $(NULL) \ $(am__append_39) $(am__append_40) ostree_bin_shared_cflags = $(AM_CFLAGS) -I$(srcdir)/src/libotutil -I$(srcdir)/src/libostree \ - -I$(srcdir)/src/ostree -I$(srcdir)/libglnx $(OT_INTERNAL_GIO_UNIX_CFLAGS) \ + -I$(builddir)/src/libostree -I$(srcdir)/src/ostree -I$(srcdir)/libglnx $(OT_INTERNAL_GIO_UNIX_CFLAGS) \ -DPKGLIBEXECDIR=\"$(pkglibexecdir)\" ostree_bin_shared_ldadd = $(AM_LDFLAGS) libglnx.la libotutil.la libostree-1.la \ @@ -2143,13 +2183,14 @@ uninstalled_test_data = tests/ostree-symlink-stamp tests/ostree-prepare-root-sym dist_uninstalled_test_scripts = tests/test-symbols.sh dist_test_scripts = tests/test-basic.sh tests/test-basic-user.sh \ - tests/test-pull-subpath.sh tests/test-archivez.sh \ - tests/test-remote-add.sh tests/test-remote-headers.sh \ - tests/test-remote-gpg-import.sh tests/test-commit-sign.sh \ - tests/test-export.sh tests/test-help.sh \ - tests/test-libarchive.sh tests/test-parent.sh \ - tests/test-pull-archive-z.sh tests/test-pull-commit-only.sh \ - tests/test-pull-depth.sh tests/test-pull-mirror-summary.sh \ + tests/test-basic-user-only.sh tests/test-pull-subpath.sh \ + tests/test-archivez.sh tests/test-remote-add.sh \ + tests/test-remote-headers.sh tests/test-remote-gpg-import.sh \ + tests/test-commit-sign.sh tests/test-export.sh \ + tests/test-help.sh tests/test-libarchive.sh \ + tests/test-parent.sh tests/test-pull-archive-z.sh \ + tests/test-pull-commit-only.sh tests/test-pull-depth.sh \ + tests/test-pull-mirror-summary.sh \ tests/test-pull-large-metadata.sh tests/test-pull-metalink.sh \ tests/test-pull-summary-sigs.sh tests/test-pull-resume.sh \ tests/test-pull-repeated.sh tests/test-pull-untrusted.sh \ @@ -2175,8 +2216,8 @@ dist_test_scripts = tests/test-basic.sh tests/test-basic-user.sh \ tests/test-auto-summary.sh tests/test-prune.sh \ tests/test-refs.sh tests/test-demo-buildsystem.sh \ tests/test-switchroot.sh tests/test-pull-contenturl.sh \ - tests/test-pull-mirrorlist.sh $(NULL) $(am__append_51) \ - $(am__append_53) $(am__append_54) + tests/test-pull-mirrorlist.sh tests/coccinelle.sh $(NULL) \ + $(am__append_51) $(am__append_53) $(am__append_54) # These call into gjs scripts js_tests = tests/test-corruption.sh tests/test-pull-corruption.sh @@ -2390,6 +2431,8 @@ distclean-hdr: -rm -f config.h stamp-h1 src/libostree/ostree-1.pc: $(top_builddir)/config.status $(top_srcdir)/src/libostree/ostree-1.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ +src/libostree/ostree-version.h: $(top_builddir)/config.status $(top_srcdir)/src/libostree/ostree-version.h.in + cd $(top_builddir) && $(SHELL) ./config.status $@ clean-checkLTLIBRARIES: -test -z "$(check_LTLIBRARIES)" || rm -f $(check_LTLIBRARIES) @@ -2750,6 +2793,9 @@ src/libotutil/$(DEPDIR)/$(am__dirstamp): src/libotutil/libotutil_la-ot-checksum-utils.lo: \ src/libotutil/$(am__dirstamp) \ src/libotutil/$(DEPDIR)/$(am__dirstamp) +src/libotutil/libotutil_la-ot-checksum-instream.lo: \ + src/libotutil/$(am__dirstamp) \ + src/libotutil/$(DEPDIR)/$(am__dirstamp) src/libotutil/libotutil_la-ot-fs-utils.lo: \ src/libotutil/$(am__dirstamp) \ src/libotutil/$(DEPDIR)/$(am__dirstamp) @@ -2762,9 +2808,6 @@ src/libotutil/libotutil_la-ot-opt-utils.lo: \ src/libotutil/libotutil_la-ot-unix-utils.lo: \ src/libotutil/$(am__dirstamp) \ src/libotutil/$(DEPDIR)/$(am__dirstamp) -src/libotutil/libotutil_la-ot-spawn-utils.lo: \ - src/libotutil/$(am__dirstamp) \ - src/libotutil/$(DEPDIR)/$(am__dirstamp) src/libotutil/libotutil_la-ot-variant-utils.lo: \ src/libotutil/$(am__dirstamp) \ src/libotutil/$(DEPDIR)/$(am__dirstamp) @@ -3321,6 +3364,20 @@ libglnx/tests/$(am__dirstamp): libglnx/tests/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) libglnx/tests/$(DEPDIR) @: > libglnx/tests/$(DEPDIR)/$(am__dirstamp) +libglnx/tests/test_libglnx_errors-test-libglnx-errors.$(OBJEXT): \ + libglnx/tests/$(am__dirstamp) \ + libglnx/tests/$(DEPDIR)/$(am__dirstamp) + +test-libglnx-errors$(EXEEXT): $(test_libglnx_errors_OBJECTS) $(test_libglnx_errors_DEPENDENCIES) $(EXTRA_test_libglnx_errors_DEPENDENCIES) + @rm -f test-libglnx-errors$(EXEEXT) + $(AM_V_CCLD)$(test_libglnx_errors_LINK) $(test_libglnx_errors_OBJECTS) $(test_libglnx_errors_LDADD) $(LIBS) +libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.$(OBJEXT): \ + libglnx/tests/$(am__dirstamp) \ + libglnx/tests/$(DEPDIR)/$(am__dirstamp) + +test-libglnx-fdio$(EXEEXT): $(test_libglnx_fdio_OBJECTS) $(test_libglnx_fdio_DEPENDENCIES) $(EXTRA_test_libglnx_fdio_DEPENDENCIES) + @rm -f test-libglnx-fdio$(EXEEXT) + $(AM_V_CCLD)$(test_libglnx_fdio_LINK) $(test_libglnx_fdio_OBJECTS) $(test_libglnx_fdio_LDADD) $(LIBS) libglnx/tests/test_libglnx_xattrs-test-libglnx-xattrs.$(OBJEXT): \ libglnx/tests/$(am__dirstamp) \ libglnx/tests/$(DEPDIR)/$(am__dirstamp) @@ -3687,6 +3744,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@libglnx/$(DEPDIR)/libglnx_la-glnx-lockfile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libglnx/$(DEPDIR)/libglnx_la-glnx-shutil.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libglnx/$(DEPDIR)/libglnx_la-glnx-xattrs.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libglnx/tests/$(DEPDIR)/test_libglnx_errors-test-libglnx-errors.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libglnx/tests/$(DEPDIR)/test_libglnx_fdio-test-libglnx-fdio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libglnx/tests/$(DEPDIR)/test_libglnx_xattrs-test-libglnx-xattrs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libostree/$(DEPDIR)/bupsplit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libostree/$(DEPDIR)/libostree_1_la-ostree-async-progress.Plo@am__quote@ @@ -3748,6 +3807,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@src/libostree/$(DEPDIR)/tests_test_rollsum-ostree-rollsum.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libostree/$(DEPDIR)/tests_test_rollsum_cli-ostree-rollsum.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libostree/$(DEPDIR)/tests_test_varint-ostree-varint.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-checksum-instream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-checksum-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-fs-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-gio-utils.Plo@am__quote@ @@ -3755,7 +3815,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-keyfile-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-log-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-opt-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-spawn-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-tool-util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-unix-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/libotutil/$(DEPDIR)/libotutil_la-ot-variant-utils.Plo@am__quote@ @@ -4318,6 +4377,13 @@ src/libotutil/libotutil_la-ot-checksum-utils.lo: src/libotutil/ot-checksum-utils @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libotutil_la_CFLAGS) $(CFLAGS) -c -o src/libotutil/libotutil_la-ot-checksum-utils.lo `test -f 'src/libotutil/ot-checksum-utils.c' || echo '$(srcdir)/'`src/libotutil/ot-checksum-utils.c +src/libotutil/libotutil_la-ot-checksum-instream.lo: src/libotutil/ot-checksum-instream.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libotutil_la_CFLAGS) $(CFLAGS) -MT src/libotutil/libotutil_la-ot-checksum-instream.lo -MD -MP -MF src/libotutil/$(DEPDIR)/libotutil_la-ot-checksum-instream.Tpo -c -o src/libotutil/libotutil_la-ot-checksum-instream.lo `test -f 'src/libotutil/ot-checksum-instream.c' || echo '$(srcdir)/'`src/libotutil/ot-checksum-instream.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/libotutil/$(DEPDIR)/libotutil_la-ot-checksum-instream.Tpo src/libotutil/$(DEPDIR)/libotutil_la-ot-checksum-instream.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/libotutil/ot-checksum-instream.c' object='src/libotutil/libotutil_la-ot-checksum-instream.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libotutil_la_CFLAGS) $(CFLAGS) -c -o src/libotutil/libotutil_la-ot-checksum-instream.lo `test -f 'src/libotutil/ot-checksum-instream.c' || echo '$(srcdir)/'`src/libotutil/ot-checksum-instream.c + src/libotutil/libotutil_la-ot-fs-utils.lo: src/libotutil/ot-fs-utils.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libotutil_la_CFLAGS) $(CFLAGS) -MT src/libotutil/libotutil_la-ot-fs-utils.lo -MD -MP -MF src/libotutil/$(DEPDIR)/libotutil_la-ot-fs-utils.Tpo -c -o src/libotutil/libotutil_la-ot-fs-utils.lo `test -f 'src/libotutil/ot-fs-utils.c' || echo '$(srcdir)/'`src/libotutil/ot-fs-utils.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/libotutil/$(DEPDIR)/libotutil_la-ot-fs-utils.Tpo src/libotutil/$(DEPDIR)/libotutil_la-ot-fs-utils.Plo @@ -4346,13 +4412,6 @@ src/libotutil/libotutil_la-ot-unix-utils.lo: src/libotutil/ot-unix-utils.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libotutil_la_CFLAGS) $(CFLAGS) -c -o src/libotutil/libotutil_la-ot-unix-utils.lo `test -f 'src/libotutil/ot-unix-utils.c' || echo '$(srcdir)/'`src/libotutil/ot-unix-utils.c -src/libotutil/libotutil_la-ot-spawn-utils.lo: src/libotutil/ot-spawn-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libotutil_la_CFLAGS) $(CFLAGS) -MT src/libotutil/libotutil_la-ot-spawn-utils.lo -MD -MP -MF src/libotutil/$(DEPDIR)/libotutil_la-ot-spawn-utils.Tpo -c -o src/libotutil/libotutil_la-ot-spawn-utils.lo `test -f 'src/libotutil/ot-spawn-utils.c' || echo '$(srcdir)/'`src/libotutil/ot-spawn-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/libotutil/$(DEPDIR)/libotutil_la-ot-spawn-utils.Tpo src/libotutil/$(DEPDIR)/libotutil_la-ot-spawn-utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/libotutil/ot-spawn-utils.c' object='src/libotutil/libotutil_la-ot-spawn-utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libotutil_la_CFLAGS) $(CFLAGS) -c -o src/libotutil/libotutil_la-ot-spawn-utils.lo `test -f 'src/libotutil/ot-spawn-utils.c' || echo '$(srcdir)/'`src/libotutil/ot-spawn-utils.c - src/libotutil/libotutil_la-ot-variant-utils.lo: src/libotutil/ot-variant-utils.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libotutil_la_CFLAGS) $(CFLAGS) -MT src/libotutil/libotutil_la-ot-variant-utils.lo -MD -MP -MF src/libotutil/$(DEPDIR)/libotutil_la-ot-variant-utils.Tpo -c -o src/libotutil/libotutil_la-ot-variant-utils.lo `test -f 'src/libotutil/ot-variant-utils.c' || echo '$(srcdir)/'`src/libotutil/ot-variant-utils.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/libotutil/$(DEPDIR)/libotutil_la-ot-variant-utils.Tpo src/libotutil/$(DEPDIR)/libotutil_la-ot-variant-utils.Plo @@ -5242,6 +5301,34 @@ src/rofiles-fuse/rofiles_fuse-main.obj: src/rofiles-fuse/main.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rofiles_fuse_CFLAGS) $(CFLAGS) -c -o src/rofiles-fuse/rofiles_fuse-main.obj `if test -f 'src/rofiles-fuse/main.c'; then $(CYGPATH_W) 'src/rofiles-fuse/main.c'; else $(CYGPATH_W) '$(srcdir)/src/rofiles-fuse/main.c'; fi` +libglnx/tests/test_libglnx_errors-test-libglnx-errors.o: libglnx/tests/test-libglnx-errors.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_errors_CFLAGS) $(CFLAGS) -MT libglnx/tests/test_libglnx_errors-test-libglnx-errors.o -MD -MP -MF libglnx/tests/$(DEPDIR)/test_libglnx_errors-test-libglnx-errors.Tpo -c -o libglnx/tests/test_libglnx_errors-test-libglnx-errors.o `test -f 'libglnx/tests/test-libglnx-errors.c' || echo '$(srcdir)/'`libglnx/tests/test-libglnx-errors.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libglnx/tests/$(DEPDIR)/test_libglnx_errors-test-libglnx-errors.Tpo libglnx/tests/$(DEPDIR)/test_libglnx_errors-test-libglnx-errors.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libglnx/tests/test-libglnx-errors.c' object='libglnx/tests/test_libglnx_errors-test-libglnx-errors.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_errors_CFLAGS) $(CFLAGS) -c -o libglnx/tests/test_libglnx_errors-test-libglnx-errors.o `test -f 'libglnx/tests/test-libglnx-errors.c' || echo '$(srcdir)/'`libglnx/tests/test-libglnx-errors.c + +libglnx/tests/test_libglnx_errors-test-libglnx-errors.obj: libglnx/tests/test-libglnx-errors.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_errors_CFLAGS) $(CFLAGS) -MT libglnx/tests/test_libglnx_errors-test-libglnx-errors.obj -MD -MP -MF libglnx/tests/$(DEPDIR)/test_libglnx_errors-test-libglnx-errors.Tpo -c -o libglnx/tests/test_libglnx_errors-test-libglnx-errors.obj `if test -f 'libglnx/tests/test-libglnx-errors.c'; then $(CYGPATH_W) 'libglnx/tests/test-libglnx-errors.c'; else $(CYGPATH_W) '$(srcdir)/libglnx/tests/test-libglnx-errors.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libglnx/tests/$(DEPDIR)/test_libglnx_errors-test-libglnx-errors.Tpo libglnx/tests/$(DEPDIR)/test_libglnx_errors-test-libglnx-errors.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libglnx/tests/test-libglnx-errors.c' object='libglnx/tests/test_libglnx_errors-test-libglnx-errors.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_errors_CFLAGS) $(CFLAGS) -c -o libglnx/tests/test_libglnx_errors-test-libglnx-errors.obj `if test -f 'libglnx/tests/test-libglnx-errors.c'; then $(CYGPATH_W) 'libglnx/tests/test-libglnx-errors.c'; else $(CYGPATH_W) '$(srcdir)/libglnx/tests/test-libglnx-errors.c'; fi` + +libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.o: libglnx/tests/test-libglnx-fdio.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_fdio_CFLAGS) $(CFLAGS) -MT libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.o -MD -MP -MF libglnx/tests/$(DEPDIR)/test_libglnx_fdio-test-libglnx-fdio.Tpo -c -o libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.o `test -f 'libglnx/tests/test-libglnx-fdio.c' || echo '$(srcdir)/'`libglnx/tests/test-libglnx-fdio.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libglnx/tests/$(DEPDIR)/test_libglnx_fdio-test-libglnx-fdio.Tpo libglnx/tests/$(DEPDIR)/test_libglnx_fdio-test-libglnx-fdio.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libglnx/tests/test-libglnx-fdio.c' object='libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_fdio_CFLAGS) $(CFLAGS) -c -o libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.o `test -f 'libglnx/tests/test-libglnx-fdio.c' || echo '$(srcdir)/'`libglnx/tests/test-libglnx-fdio.c + +libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.obj: libglnx/tests/test-libglnx-fdio.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_fdio_CFLAGS) $(CFLAGS) -MT libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.obj -MD -MP -MF libglnx/tests/$(DEPDIR)/test_libglnx_fdio-test-libglnx-fdio.Tpo -c -o libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.obj `if test -f 'libglnx/tests/test-libglnx-fdio.c'; then $(CYGPATH_W) 'libglnx/tests/test-libglnx-fdio.c'; else $(CYGPATH_W) '$(srcdir)/libglnx/tests/test-libglnx-fdio.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libglnx/tests/$(DEPDIR)/test_libglnx_fdio-test-libglnx-fdio.Tpo libglnx/tests/$(DEPDIR)/test_libglnx_fdio-test-libglnx-fdio.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libglnx/tests/test-libglnx-fdio.c' object='libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_fdio_CFLAGS) $(CFLAGS) -c -o libglnx/tests/test_libglnx_fdio-test-libglnx-fdio.obj `if test -f 'libglnx/tests/test-libglnx-fdio.c'; then $(CYGPATH_W) 'libglnx/tests/test-libglnx-fdio.c'; else $(CYGPATH_W) '$(srcdir)/libglnx/tests/test-libglnx-fdio.c'; fi` + libglnx/tests/test_libglnx_xattrs-test-libglnx-xattrs.o: libglnx/tests/test-libglnx-xattrs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libglnx_xattrs_CFLAGS) $(CFLAGS) -MT libglnx/tests/test_libglnx_xattrs-test-libglnx-xattrs.o -MD -MP -MF libglnx/tests/$(DEPDIR)/test_libglnx_xattrs-test-libglnx-xattrs.Tpo -c -o libglnx/tests/test_libglnx_xattrs-test-libglnx-xattrs.o `test -f 'libglnx/tests/test-libglnx-xattrs.c' || echo '$(srcdir)/'`libglnx/tests/test-libglnx-xattrs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libglnx/tests/$(DEPDIR)/test_libglnx_xattrs-test-libglnx-xattrs.Tpo libglnx/tests/$(DEPDIR)/test_libglnx_xattrs-test-libglnx-xattrs.Po @@ -6337,6 +6424,13 @@ tests/test-basic-user.sh.log: tests/test-basic-user.sh --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/test-basic-user-only.sh.log: tests/test-basic-user-only.sh + @p='tests/test-basic-user-only.sh'; \ + b='tests/test-basic-user-only.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) tests/test-pull-subpath.sh.log: tests/test-pull-subpath.sh @p='tests/test-pull-subpath.sh'; \ b='tests/test-pull-subpath.sh'; \ @@ -6701,6 +6795,13 @@ tests/test-pull-mirrorlist.sh.log: tests/test-pull-mirrorlist.sh --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/coccinelle.sh.log: tests/coccinelle.sh + @p='tests/coccinelle.sh'; \ + b='tests/coccinelle.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) tests/test-rofiles-fuse.sh.log: tests/test-rofiles-fuse.sh @p='tests/test-rofiles-fuse.sh'; \ b='tests/test-rofiles-fuse.sh'; \ @@ -6743,6 +6844,20 @@ test-libglnx-xattrs.log: test-libglnx-xattrs$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +test-libglnx-fdio.log: test-libglnx-fdio$(EXEEXT) + @p='test-libglnx-fdio$(EXEEXT)'; \ + b='test-libglnx-fdio'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test-libglnx-errors.log: test-libglnx-errors$(EXEEXT) + @p='test-libglnx-errors$(EXEEXT)'; \ + b='test-libglnx-errors'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ @@ -7223,7 +7338,7 @@ all-local: $(ALL_LOCAL_RULES) @ENABLE_RUST_TRUE@ cargo vendor -q && \ @ENABLE_RUST_TRUE@ mkdir .cargo && \ @ENABLE_RUST_TRUE@ cp cargo-vendor-config .cargo/config) -@ENABLE_RUST_TRUE@$(bupsplitpath): Makefile $(BUPSPLIT_RUST_SOURCES) +@ENABLE_RUST_TRUE@$(bupsplitpath): Makefile $(BUPSPLIT_RUST_SRCS) @ENABLE_RUST_TRUE@ cd $(top_srcdir)/rust && CARGO_TARGET_DIR=@abs_top_builddir@/target cargo build --verbose $(CARGO_RELEASE_ARGS) src/libostree/ostree-enumtypes.h: src/libostree/ostree-enumtypes.h.template $(ENUM_TYPES) diff --git a/apidoc/Makefile.am b/apidoc/Makefile.am index baa7207a..730a4c33 100644 --- a/apidoc/Makefile.am +++ b/apidoc/Makefile.am @@ -60,7 +60,7 @@ FIXXREF_OPTIONS= # Used for dependencies. The docs will be rebuilt if any of these change. # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c -HFILE_GLOB=$(addprefix $(top_srcdir)/,$(libostree_public_headers)) +HFILE_GLOB=$(addprefix $(top_srcdir)/,$(libostree_public_headers)) $(addprefix $(top_builddir)/,$(libostree_public_built_headers)) CFILE_GLOB=$(top_srcdir)/src/libostree/*.c # Header files to ignore when scanning. diff --git a/apidoc/Makefile.in b/apidoc/Makefile.in index 78ddfe5f..8000f3b4 100644 --- a/apidoc/Makefile.in +++ b/apidoc/Makefile.in @@ -267,6 +267,8 @@ OT_DEP_LIBMOUNT_CFLAGS = @OT_DEP_LIBMOUNT_CFLAGS@ OT_DEP_LIBMOUNT_LIBS = @OT_DEP_LIBMOUNT_LIBS@ OT_DEP_LZMA_CFLAGS = @OT_DEP_LZMA_CFLAGS@ OT_DEP_LZMA_LIBS = @OT_DEP_LZMA_LIBS@ +OT_DEP_OPENSSL_CFLAGS = @OT_DEP_OPENSSL_CFLAGS@ +OT_DEP_OPENSSL_LIBS = @OT_DEP_OPENSSL_LIBS@ OT_DEP_SELINUX_CFLAGS = @OT_DEP_SELINUX_CFLAGS@ OT_DEP_SELINUX_LIBS = @OT_DEP_SELINUX_LIBS@ OT_DEP_SOUP_CFLAGS = @OT_DEP_SOUP_CFLAGS@ @@ -285,6 +287,7 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ +RELEASE_VERSION = @RELEASE_VERSION@ RUST_TARGET_SUBDIR = @RUST_TARGET_SUBDIR@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -295,6 +298,7 @@ VERSION = @VERSION@ WARN_CFLAGS = @WARN_CFLAGS@ XSLTPROC = @XSLTPROC@ YACC = @YACC@ +YEAR_VERSION = @YEAR_VERSION@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ @@ -373,6 +377,10 @@ libostree_public_headers = \ src/libostree/ostree-repo-deprecated.h \ $(NULL) + +# This one is generated via configure.ac, and the gtk-doc +# code hence needs to look in the builddir. +libostree_public_built_headers = src/libostree/ostree-version.h NULL = # We require automake 1.6 at least. @@ -414,7 +422,7 @@ FIXXREF_OPTIONS = # Used for dependencies. The docs will be rebuilt if any of these change. # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c -HFILE_GLOB = $(addprefix $(top_srcdir)/,$(libostree_public_headers)) +HFILE_GLOB = $(addprefix $(top_srcdir)/,$(libostree_public_headers)) $(addprefix $(top_builddir)/,$(libostree_public_built_headers)) CFILE_GLOB = $(top_srcdir)/src/libostree/*.c # Header files to ignore when scanning. diff --git a/apidoc/html/index.html b/apidoc/html/index.html index ac902f05..e8784b1e 100644 --- a/apidoc/html/index.html +++ b/apidoc/html/index.html @@ -14,7 +14,7 @@
OSTree API references |
|---|
for OSTree 2017.3
for OSTree 2017.4
GError **error);
This function is deprecated, sign the summary file instead. Add a GPG signature to a static delta.
+self |
+Self |
++ |
from_commit |
+From commit |
++ |
to_commit |
+To commit |
++ |
key_id |
+key id |
++ |
homedir |
+homedir |
++ |
cancellable |
+cancellable |
++ |
error |
+error |
++ |
Same as BARE_USER, but all metadata is not stored, so it can only be used for user checkouts. Does not need xattrs.
+Add a remote
+Like above, but do nothing if the remote exists
+Delete a remote
+Delete a remote, do nothing if the remote does not exist
+Canonicalize permissions for bare-user-only mode.
+Emit an error if configured SELinux policy does not provide a label
+guint64
ostree_commit_get_timestamp (GVariant *commit_variant);
+gboolean +ostree_check_version (+ + +guint required_year, +guint required_release);
cancellable
Cancellable
error
Error
GPtrArray *new_deployments,
GCancellable *cancellable,
GError **error);
-Assuming new_deployments
- have already been deployed in place on
-disk, atomically update bootloader configuration.
Older version of ostree_sysroot_write_deployments_with_options(). This
+version will perform post-deployment cleanup by default.
self |
+Sysroot |
++ |
new_deployments |
+List of new deployments. |
+[element-type OstreeDeployment] | +
opts |
+Options |
++ |
cancellable |
+Cancellable |
++ |
error |
+Error |
++ |
gboolean ostree_sysroot_write_origin_file (OstreeSysroot *sysroot, @@ -1405,11 +1473,18 @@ ostree_sysroot_origin_new_from_refspec- + ++ ++ self
+ Sysroot
+ + + refspec
A refspec
-
GFile
-
+
+
path
Path to a root directory
-
+cancellable
Cancellable
error
Error
GFile
OstreeSePolicy * +ostree_sepolicy_new_at (+int rootfs_dfd, +GCancellable *cancellable, +GError **error);
rootfs_dfd |
+Directory fd for rootfs (will not be cloned) |
++ |
cancellable |
+Cancellable |
++ |
error |
+Error |
++ |
GFile *
ostree_sepolicy_get_path (OstreeSePolicy *self);
@@ -365,6 +426,21 @@ ostree_sepolicy_setfscreatecon (void
ostree_sepolicy_fscreatecon_cleanup (void **unused);
Cleanup function for ostree_sepolicy_setfscreatecon().
+
-
+
+
sysroot
-
+
+
+cancellable
+Cancellable
+
+
+
+error
+Error
+
+
+
Operating system name.
[allow-none]
+
+cancellable
+Cancellable
+
+
+
+error
+Error
+
+
Flags
cancellable
Cancellable
error
Error
ostree_sysroot_upgrader_pull(), but allows retrieving just a
subpath of the tree. This can be used to download metadata files
from inside the tree such as package databases.
+
+Parameters
+
+
+
+
+
+
+
+
+self
+Upgrader
+
+
+
+dir_to_pull
+Subdirectory path (should include a leading /)
+
+
+
+flags
+Flags controlling pull behavior
+
+
+
+upgrader_flags
+Flags controlling upgrader behavior
+
+
+
+progress
+ Progress.
+[allow-none]
+
+
+out_changed
+ Whether or not the origin changed.
+[out]
+
+
+cancellable
+Cancellable
+
+
+
+error
+Error
+
+
+
+
+
diff --git a/apidoc/html/ostree-ostree-diff.html b/apidoc/html/ostree-ostree-diff.html
index 7145d121..ca5dad0a 100644
--- a/apidoc/html/ostree-ostree-diff.html
+++ b/apidoc/html/ostree-ostree-diff.html
@@ -65,6 +65,14 @@
+gboolean
+
+
+ostree_diff_dirs_with_options ()
+
+
+
+
void
@@ -183,6 +191,84 @@ sets of
+ostree_diff_dirs_with_options ()
+gboolean
+ostree_diff_dirs_with_options (OstreeDiffFlags flags,
+ GFile *a,
+ GFile *b,
+ GPtrArray *modified,
+ GPtrArray *removed,
+ GPtrArray *added,
+ OstreeDiffDirsOptions *options,
+ GCancellable *cancellable,
+ GError **error);
+Compute the difference between directory a
+ and b
+ as 3 separate
+sets of OstreeDiffItem in modified
+, removed
+, and added
+.
+
+Parameters
+
+
+
+
+
+
+
+
+flags
+Flags
+
+
+
+a
+First directory path, or NULL
+
+
+
+b
+First directory path
+
+
+
+modified
+ Modified files.
+[element-type OstreeDiffItem]
+
+
+removed
+ Removed files.
+[element-type Gio.File]
+
+
+added
+ Added files.
+[element-type Gio.File]
+
+
+cancellable
+Cancellable
+
+
+
+options
+ Options.
+[allow-none]
+
+
+error
+Error
+
+
+
+
+
+
+
+
ostree_diff_print ()
void
ostree_diff_print (GFile *a,
diff --git a/apidoc/html/ostree.devhelp2 b/apidoc/html/ostree.devhelp2
index d1f68ddb..5cbabaca 100644
--- a/apidoc/html/ostree.devhelp2
+++ b/apidoc/html/ostree.devhelp2
@@ -65,6 +65,7 @@
+
@@ -257,6 +258,7 @@
+
@@ -275,6 +277,7 @@
+
@@ -345,6 +348,7 @@
+
@@ -370,6 +374,7 @@
+
@@ -379,6 +384,8 @@
+
+
diff --git a/apidoc/html/reference.html b/apidoc/html/reference.html
index f6d727a3..d0e784be 100644
--- a/apidoc/html/reference.html
+++ b/apidoc/html/reference.html
@@ -230,6 +230,14 @@
+OSTREE_CHECK_VERSION, macro in ostree-version
+
+
+
+ostree_check_version, function in Core repository-independent functions
+
+
+
ostree_cmp_checksum_bytes, function in Core repository-independent functions
@@ -359,6 +367,10 @@
+ostree_diff_dirs_with_options, function in ostree-diff
+
+
+
ostree_diff_item_ref, function in ostree-diff
@@ -562,6 +574,10 @@
+OSTREE_RELEASE_VERSION, macro in ostree-version
+
+
+
OstreeRepo, typedef in Content-addressed object store
@@ -1187,6 +1203,10 @@
+ostree_sepolicy_new_at, function in SELinux policy management
+
+
+
ostree_sepolicy_restorecon, function in SELinux policy management
@@ -1399,6 +1419,10 @@
+ostree_sysroot_write_deployments_with_options, function in Root partition mount point
+
+
+
ostree_sysroot_write_origin_file, function in Root partition mount point
@@ -1448,6 +1472,23 @@
ostree_validate_structureof_objtype, function in Core repository-independent functions
+
+OSTREE_VERSION, macro in ostree-version
+
+
+
+OSTREE_VERSION_HEX, macro in ostree-version
+
+
+
+OSTREE_VERSION_S, macro in ostree-version
+
+
+Y
+
+OSTREE_YEAR_VERSION, macro in ostree-version
+
+
diff --git a/apidoc/ostree-sections.txt b/apidoc/ostree-sections.txt
index 787664b3..07dbaf1f 100644
--- a/apidoc/ostree-sections.txt
+++ b/apidoc/ostree-sections.txt
@@ -71,6 +71,16 @@ OstreeChecksumInputStreamPrivate
ostree_checksum_input_stream_get_type
+
+ostree-version
+OSTREE_CHECK_VERSION
+OSTREE_YEAR_VERSION
+OSTREE_RELEASE_VERSION
+OSTREE_VERSION
+OSTREE_VERSION_S
+OSTREE_VERSION_HEX
+
+
ostree-core
OSTREE_MAX_METADATA_SIZE
@@ -133,6 +143,7 @@ ostree_validate_structureof_dirtree
ostree_validate_structureof_dirmeta
ostree_commit_get_parent
ostree_commit_get_timestamp
+ostree_check_version
@@ -171,6 +182,7 @@ OstreeDiffItem
ostree_diff_item_ref
ostree_diff_item_unref
ostree_diff_dirs
+ostree_diff_dirs_with_options
ostree_diff_print
ostree_diff_item_get_type
@@ -424,6 +436,7 @@ ostree_repo_file_get_type
ostree-sepolicy
OstreeSePolicy
ostree_sepolicy_new
+ostree_sepolicy_new_at
ostree_sepolicy_get_path
ostree_sepolicy_get_name
ostree_sepolicy_get_label
@@ -470,6 +483,7 @@ ostree_sysroot_deployment_set_kargs
ostree_sysroot_deployment_set_mutable
ostree_sysroot_deployment_unlock
ostree_sysroot_write_deployments
+ostree_sysroot_write_deployments_with_options
ostree_sysroot_write_origin_file
ostree_sysroot_deploy_tree
ostree_sysroot_get_merge_deployment
diff --git a/apidoc/version.xml b/apidoc/version.xml
index 30d5aa75..719d04cc 100644
--- a/apidoc/version.xml
+++ b/apidoc/version.xml
@@ -1 +1 @@
-2017.3
\ No newline at end of file
+2017.4
\ No newline at end of file
diff --git a/config.h.in b/config.h.in
index 0122bd29..72d72cda 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,5 +1,8 @@
/* config.h.in. Generated from configure.ac by autoheader. */
+/* Define if we are enabling ostree trivial-httpd entrypoint */
+#undef BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE
+
/* Define if we should avoid using O_TMPFILE */
#undef DISABLE_OTMPFILE
@@ -52,6 +55,9 @@
/* Define to 1 if you have the `mnt_unref_cache' function. */
#undef HAVE_MNT_UNREF_CACHE
+/* Define if we have openssl */
+#undef HAVE_OPENSSL
+
/* Define if we have libselinux.pc */
#undef HAVE_SELINUX
diff --git a/configure b/configure
index 90c2f68e..8adb4d44 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libostree 2017.3.
+# Generated by GNU Autoconf 2.69 for libostree 2017.4.
#
# Report bugs to .
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libostree'
PACKAGE_TARNAME='libostree'
-PACKAGE_VERSION='2017.3'
-PACKAGE_STRING='libostree 2017.3'
+PACKAGE_VERSION='2017.4'
+PACKAGE_STRING='libostree 2017.4'
PACKAGE_BUGREPORT='walters@verbum.org'
PACKAGE_URL=''
@@ -665,6 +665,10 @@ USE_LIBMOUNT_FALSE
USE_LIBMOUNT_TRUE
OT_DEP_LIBMOUNT_LIBS
OT_DEP_LIBMOUNT_CFLAGS
+USE_OPENSSL_FALSE
+USE_OPENSSL_TRUE
+OT_DEP_OPENSSL_LIBS
+OT_DEP_OPENSSL_CFLAGS
USE_SMACK_FALSE
USE_SMACK_TRUE
USE_SELINUX_FALSE
@@ -788,6 +792,8 @@ LIBTOOL
BUILDOPT_ASAN_FALSE
BUILDOPT_ASAN_TRUE
WARN_CFLAGS
+RELEASE_VERSION
+YEAR_VERSION
YFLAGS
YACC
EGREP
@@ -901,6 +907,7 @@ enable_glibtest
with_curl
with_soup
enable_libsoup_client_certs
+enable_trivial_httpd_cmdline
enable_introspection
with_gpgme_prefix
with_html_dir
@@ -913,6 +920,7 @@ enable_rust_debug
with_libarchive
with_selinux
with_smack
+with_openssl
with_libmount
enable_rofiles_fuse
with_dracut
@@ -957,6 +965,8 @@ OT_DEP_LIBARCHIVE_CFLAGS
OT_DEP_LIBARCHIVE_LIBS
OT_DEP_SELINUX_CFLAGS
OT_DEP_SELINUX_LIBS
+OT_DEP_OPENSSL_CFLAGS
+OT_DEP_OPENSSL_LIBS
OT_DEP_LIBMOUNT_CFLAGS
OT_DEP_LIBMOUNT_LIBS
BUILDOPT_FUSE_CFLAGS
@@ -1503,7 +1513,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libostree 2017.3 to adapt to many kinds of systems.
+\`configure' configures libostree 2017.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1573,7 +1583,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libostree 2017.3:";;
+ short | recursive ) echo "Configuration of libostree 2017.4:";;
esac
cat <<\_ACEOF
@@ -1608,6 +1618,9 @@ Optional Features:
--enable-libsoup-client-certs
Require availability of new enough libsoup TLS
client cert API (default: auto)
+ --enable-trivial-httpd-cmdline
+ Continue to support "ostree trivial-httpd"
+ [default=no]
--enable-introspection=[no/auto/yes]
Enable introspection for this build
--enable-gtk-doc use gtk-doc to build documentation [[default=no]]
@@ -1637,6 +1650,7 @@ Optional Packages:
--without-libarchive Do not use libarchive
--without-selinux Do not use SELinux
--with-smack Enable smack
+ --with-openssl Enable use of OpenSSL libcrypto (checksums)
--without-libmount Do not use libmount
--with-dracut Install dracut module (default: no)
--with-mkinitcpio Install mkinitcpio module (default: no)
@@ -1712,6 +1726,10 @@ Some influential environment variables:
C compiler flags for OT_DEP_SELINUX, overriding pkg-config
OT_DEP_SELINUX_LIBS
linker flags for OT_DEP_SELINUX, overriding pkg-config
+ OT_DEP_OPENSSL_CFLAGS
+ C compiler flags for OT_DEP_OPENSSL, overriding pkg-config
+ OT_DEP_OPENSSL_LIBS
+ linker flags for OT_DEP_OPENSSL, overriding pkg-config
OT_DEP_LIBMOUNT_CFLAGS
C compiler flags for OT_DEP_LIBMOUNT, overriding pkg-config
OT_DEP_LIBMOUNT_LIBS
@@ -1791,7 +1809,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libostree configure 2017.3
+libostree configure 2017.4
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2206,7 +2224,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libostree $as_me 2017.3, which was
+It was created by libostree $as_me 2017.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3073,7 +3091,7 @@ fi
# Define the identity of the package.
PACKAGE='libostree'
- VERSION='2017.3'
+ VERSION='2017.4'
# Some tools Automake needs.
@@ -5805,6 +5823,13 @@ done
test -n "$YACC" || YACC="yacc"
+YEAR_VERSION=2017
+
+RELEASE_VERSION=4
+
+PACKAGE_VERSION=2017.4
+
+
for flag in \
-pipe \
@@ -5823,6 +5848,7 @@ test -n "$YACC" || YACC="yacc"
-Werror=incompatible-pointer-types \
-Werror=misleading-indentation \
-Werror=missing-include-dirs -Werror=aggregate-return \
+ -Werror=unused-result \
; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports flag $flag in envvar CFLAGS" >&5
@@ -14832,6 +14858,20 @@ else
fi
+# Check whether --enable-trivial-httpd-cmdline was given.
+if test "${enable_trivial_httpd_cmdline+set}" = set; then :
+ enableval=$enable_trivial_httpd_cmdline;
+else
+ enable_trivial_httpd_cmdline=no
+fi
+
+if test x$enable_trivial_httpd_cmdline = xyes; then :
+
+$as_echo "#define BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE 1" >>confdefs.h
+
+
+fi
+
if test x$with_curl = xyes && test x$with_soup = xno; then :
as_fn_error $? "Curl enabled, but libsoup is not; libsoup is needed for tests" "$LINENO" 5
@@ -16231,6 +16271,129 @@ else
fi
+OPENSSL_DEPENDENCY="libcrypto >= 1.0.1"
+
+# Check whether --with-openssl was given.
+if test "${with_openssl+set}" = set; then :
+ withval=$with_openssl; :
+else
+ with_openssl=no
+fi
+
+
+if test x$with_openssl != xno ; then :
+
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OT_DEP_OPENSSL" >&5
+$as_echo_n "checking for OT_DEP_OPENSSL... " >&6; }
+
+if test -n "$OT_DEP_OPENSSL_CFLAGS"; then
+ pkg_cv_OT_DEP_OPENSSL_CFLAGS="$OT_DEP_OPENSSL_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$OPENSSL_DEPENDENCY\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "$OPENSSL_DEPENDENCY") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_OT_DEP_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "$OPENSSL_DEPENDENCY" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+if test -n "$OT_DEP_OPENSSL_LIBS"; then
+ pkg_cv_OT_DEP_OPENSSL_LIBS="$OT_DEP_OPENSSL_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$OPENSSL_DEPENDENCY\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "$OPENSSL_DEPENDENCY") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_OT_DEP_OPENSSL_LIBS=`$PKG_CONFIG --libs "$OPENSSL_DEPENDENCY" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ OT_DEP_OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$OPENSSL_DEPENDENCY" 2>&1`
+ else
+ OT_DEP_OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$OPENSSL_DEPENDENCY" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$OT_DEP_OPENSSL_PKG_ERRORS" >&5
+
+ as_fn_error $? "Package requirements ($OPENSSL_DEPENDENCY) were not met:
+
+$OT_DEP_OPENSSL_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+Alternatively, you may set the environment variables OT_DEP_OPENSSL_CFLAGS
+and OT_DEP_OPENSSL_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+elif test $pkg_failed = untried; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+Alternatively, you may set the environment variables OT_DEP_OPENSSL_CFLAGS
+and OT_DEP_OPENSSL_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
+
+To get pkg-config, see .
+See \`config.log' for more details" "$LINENO" 5; }
+else
+ OT_DEP_OPENSSL_CFLAGS=$pkg_cv_OT_DEP_OPENSSL_CFLAGS
+ OT_DEP_OPENSSL_LIBS=$pkg_cv_OT_DEP_OPENSSL_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+fi
+
+$as_echo "#define HAVE_OPENSSL 1" >>confdefs.h
+
+ with_openssl=yes
+
+else
+
+ with_openssl=no
+
+fi
+if test x$with_openssl != xno; then OSTREE_FEATURES="$OSTREE_FEATURES openssl"; fi
+ if test $with_openssl != no; then
+ USE_OPENSSL_TRUE=
+ USE_OPENSSL_FALSE='#'
+else
+ USE_OPENSSL_TRUE='#'
+ USE_OPENSSL_FALSE=
+fi
+
+
LIBMOUNT_DEPENDENCY="mount >= 2.23.0"
@@ -16830,7 +16993,7 @@ else
fi
-ac_config_files="$ac_config_files Makefile apidoc/Makefile src/libostree/ostree-1.pc"
+ac_config_files="$ac_config_files Makefile apidoc/Makefile src/libostree/ostree-1.pc src/libostree/ostree-version.h"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -17057,6 +17220,10 @@ if test -z "${USE_SMACK_TRUE}" && test -z "${USE_SMACK_FALSE}"; then
as_fn_error $? "conditional \"USE_SMACK\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${USE_OPENSSL_TRUE}" && test -z "${USE_OPENSSL_FALSE}"; then
+ as_fn_error $? "conditional \"USE_OPENSSL\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${USE_LIBMOUNT_TRUE}" && test -z "${USE_LIBMOUNT_FALSE}"; then
as_fn_error $? "conditional \"USE_LIBMOUNT\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -17494,7 +17661,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libostree $as_me 2017.3, which was
+This file was extended by libostree $as_me 2017.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -17560,7 +17727,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-libostree config.status 2017.3
+libostree config.status 2017.4
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@@ -17978,6 +18145,7 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"apidoc/Makefile") CONFIG_FILES="$CONFIG_FILES apidoc/Makefile" ;;
"src/libostree/ostree-1.pc") CONFIG_FILES="$CONFIG_FILES src/libostree/ostree-1.pc" ;;
+ "src/libostree/ostree-version.h") CONFIG_FILES="$CONFIG_FILES src/libostree/ostree-version.h" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
@@ -19257,7 +19425,9 @@ echo "
Rust (internal oxidation): $rust_debug_release
rofiles-fuse: $enable_rofiles_fuse
HTTP backend: $fetcher_backend
+ \"ostree trivial-httpd\": $enable_trivial_httpd_cmdline
SELinux: $with_selinux
+ OpenSSL libcrypto (checksums): $with_openssl
systemd: $have_libsystemd
libmount: $with_libmount
libarchive (parse tar files directly): $with_libarchive
diff --git a/configure.ac b/configure.ac
index 08894480..f6512c1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,10 @@
AC_PREREQ([2.63])
dnl If incrementing the version here, remember to update libostree.sym too
-AC_INIT([libostree], [2017.3], [walters@verbum.org])
+m4_define([year_version], [2017])
+m4_define([release_version], [4])
+m4_define([package_version], [year_version.release_version])
+
+AC_INIT([libostree], [package_version], [walters@verbum.org])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([buildutil])
AC_CONFIG_AUX_DIR([build-aux])
@@ -16,6 +20,11 @@ AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_YACC
+dnl Versioning information
+AC_SUBST([YEAR_VERSION], [year_version])
+AC_SUBST([RELEASE_VERSION], [release_version])
+AC_SUBST([PACKAGE_VERSION], [package_version])
+
CC_CHECK_FLAGS_APPEND([WARN_CFLAGS], [CFLAGS], [\
-pipe \
-Wall \
@@ -33,6 +42,7 @@ CC_CHECK_FLAGS_APPEND([WARN_CFLAGS], [CFLAGS], [\
-Werror=incompatible-pointer-types \
-Werror=misleading-indentation \
-Werror=missing-include-dirs -Werror=aggregate-return \
+ -Werror=unused-result \
])
AC_SUBST(WARN_CFLAGS)
@@ -134,6 +144,14 @@ if test x$with_soup != xno; then OSTREE_FEATURES="$OSTREE_FEATURES libsoup"; fi
AM_CONDITIONAL(USE_LIBSOUP, test x$with_soup != xno)
AM_CONDITIONAL(HAVE_LIBSOUP_CLIENT_CERTS, test x$have_libsoup_client_certs = xyes)
+AC_ARG_ENABLE(trivial-httpd-cmdline,
+ [AS_HELP_STRING([--enable-trivial-httpd-cmdline],
+ [Continue to support "ostree trivial-httpd" [default=no]])],,
+ enable_trivial_httpd_cmdline=no)
+AS_IF([test x$enable_trivial_httpd_cmdline = xyes],
+ [AC_DEFINE([BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE], 1, [Define if we are enabling ostree trivial-httpd entrypoint])]
+)
+
AS_IF([test x$with_curl = xyes && test x$with_soup = xno], [
AC_MSG_ERROR([Curl enabled, but libsoup is not; libsoup is needed for tests])
])
@@ -281,6 +299,23 @@ AS_IF([ test x$with_smack = xyes], [
])
AM_CONDITIONAL(USE_SMACK, test $with_smack != no)
+dnl begin openssl (really just libcrypto right now)
+OPENSSL_DEPENDENCY="libcrypto >= 1.0.1"
+AC_ARG_WITH(openssl,
+AS_HELP_STRING([--with-openssl], [Enable use of OpenSSL libcrypto (checksums)]),
+:, with_openssl=no)
+
+AS_IF([ test x$with_openssl != xno ], [
+ PKG_CHECK_MODULES(OT_DEP_OPENSSL, $OPENSSL_DEPENDENCY)
+ AC_DEFINE([HAVE_OPENSSL], 1, [Define if we have openssl])
+ with_openssl=yes
+], [
+ with_openssl=no
+])
+if test x$with_openssl != xno; then OSTREE_FEATURES="$OSTREE_FEATURES openssl"; fi
+AM_CONDITIONAL(USE_OPENSSL, test $with_openssl != no)
+dnl end openssl
+
dnl This is what is in RHEL7.2 right now, picking it arbitrarily
LIBMOUNT_DEPENDENCY="mount >= 2.23.0"
@@ -398,6 +433,7 @@ AC_CONFIG_FILES([
Makefile
apidoc/Makefile
src/libostree/ostree-1.pc
+src/libostree/ostree-version.h
])
AC_OUTPUT
@@ -410,7 +446,9 @@ echo "
Rust (internal oxidation): $rust_debug_release
rofiles-fuse: $enable_rofiles_fuse
HTTP backend: $fetcher_backend
+ \"ostree trivial-httpd\": $enable_trivial_httpd_cmdline
SELinux: $with_selinux
+ OpenSSL libcrypto (checksums): $with_openssl
systemd: $have_libsystemd
libmount: $with_libmount
libarchive (parse tar files directly): $with_libarchive
diff --git a/libglnx/Makefile-libglnx.am b/libglnx/Makefile-libglnx.am
index d3a46e55..805a9d04 100644
--- a/libglnx/Makefile-libglnx.am
+++ b/libglnx/Makefile-libglnx.am
@@ -52,9 +52,18 @@ libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic
libglnx_la_LIBADD = $(libglnx_libs)
-TESTS += test-libglnx-xattrs
+libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors
+TESTS += $(libglnx_tests)
-check_PROGRAMS += test-libglnx-xattrs
+check_PROGRAMS += $(libglnx_tests)
test_libglnx_xattrs_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-xattrs.c
test_libglnx_xattrs_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_xattrs_LDADD = $(libglnx_libs) libglnx.la
+
+test_libglnx_fdio_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-fdio.c
+test_libglnx_fdio_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
+test_libglnx_fdio_LDADD = $(libglnx_libs) libglnx.la
+
+test_libglnx_errors_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-errors.c
+test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
+test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la
diff --git a/libglnx/Makefile-libglnx.am.inc b/libglnx/Makefile-libglnx.am.inc
index 9bd96e20..daaae9ec 100644
--- a/libglnx/Makefile-libglnx.am.inc
+++ b/libglnx/Makefile-libglnx.am.inc
@@ -52,9 +52,18 @@ libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic
libglnx_la_LIBADD = $(libglnx_libs)
-TESTS += test-libglnx-xattrs
+libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors
+TESTS += $(libglnx_tests)
-check_PROGRAMS += test-libglnx-xattrs
+check_PROGRAMS += $(libglnx_tests)
test_libglnx_xattrs_SOURCES = libglnx/tests/test-libglnx-xattrs.c
test_libglnx_xattrs_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_xattrs_LDADD = $(libglnx_libs) libglnx.la
+
+test_libglnx_fdio_SOURCES = libglnx/tests/test-libglnx-fdio.c
+test_libglnx_fdio_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
+test_libglnx_fdio_LDADD = $(libglnx_libs) libglnx.la
+
+test_libglnx_errors_SOURCES = libglnx/tests/test-libglnx-errors.c
+test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
+test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la
diff --git a/libglnx/glnx-dirfd.c b/libglnx/glnx-dirfd.c
index 11388c18..08d90071 100644
--- a/libglnx/glnx-dirfd.c
+++ b/libglnx/glnx-dirfd.c
@@ -68,8 +68,7 @@ glnx_opendirat (int dfd,
int ret = glnx_opendirat_with_errno (dfd, path, follow);
if (ret == -1)
{
- glnx_set_prefix_error_from_errno (error, "%s", "openat");
- return FALSE;
+ return glnx_throw_errno_prefix (error, "openat");
}
*out_fd = ret;
return TRUE;
@@ -339,8 +338,7 @@ glnx_mkdtempat (int dfd,
/* Any other error will apply also to other names we might
* try, and there are 2^32 or so of them, so give up now.
*/
- glnx_set_prefix_error_from_errno (error, "%s", "mkdirat");
- return FALSE;
+ return glnx_throw_errno_prefix (error, "mkdirat");
}
return TRUE;
diff --git a/libglnx/glnx-errors.c b/libglnx/glnx-errors.c
index ab7bc0aa..edbce205 100644
--- a/libglnx/glnx-errors.c
+++ b/libglnx/glnx-errors.c
@@ -24,30 +24,21 @@
#include
void
-glnx_real_set_prefix_error_from_errno (GError **error,
- gint errsv,
- const char *format,
- ...)
+glnx_real_set_prefix_error_from_errno_va (GError **error,
+ gint errsv,
+ const char *format,
+ va_list args)
{
if (!error)
return;
- else
- {
- GString *buf = g_string_new ("");
- va_list args;
-
- va_start (args, format);
- g_string_append_vprintf (buf, format, args);
- va_end (args);
- g_string_append (buf, ": ");
- g_string_append (buf, g_strerror (errsv));
-
- g_set_error_literal (error,
- G_IO_ERROR,
- g_io_error_from_errno (errsv),
- buf->str);
- g_string_free (buf, TRUE);
- errno = errsv;
- }
+ /* TODO - enhance GError to have a "set and take ownership" API */
+ g_autoptr(GString) buf = g_string_new ("");
+ g_string_append_vprintf (buf, format, args);
+ g_string_append (buf, ": ");
+ g_string_append (buf, g_strerror (errsv));
+ g_set_error_literal (error,
+ G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ buf->str);
}
diff --git a/libglnx/glnx-errors.h b/libglnx/glnx-errors.h
index fffef6c9..8f9cad81 100644
--- a/libglnx/glnx-errors.h
+++ b/libglnx/glnx-errors.h
@@ -25,25 +25,101 @@
G_BEGIN_DECLS
+/* Set @error with G_IO_ERROR/G_IO_ERROR_FAILED.
+ *
+ * This function returns %FALSE so it can be used conveniently in a single
+ * statement:
+ *
+ * ``
+ * if (strcmp (foo, "somevalue") != 0)
+ * return glnx_throw (error, "key must be somevalue, not '%s'", foo);
+ * ```
+ */
+static inline gboolean G_GNUC_PRINTF (2,3)
+glnx_throw (GError **error, const char *fmt, ...)
+{
+ if (error == NULL)
+ return FALSE;
+
+ va_list args;
+ va_start (args, fmt);
+ GError *new = g_error_new_valist (G_IO_ERROR, G_IO_ERROR_FAILED, fmt, args);
+ va_end (args);
+ g_propagate_error (error, g_steal_pointer (&new));
+ return FALSE;
+}
+
+
+/* Set @error using the value of `g_strerror (errno)`.
+ *
+ * This function returns %FALSE so it can be used conveniently in a single
+ * statement:
+ *
+ * ``
+ * if (unlinkat (fd, somepathname) < 0)
+ * return glnx_throw_errno (error);
+ * ```
+ */
+static inline gboolean
+glnx_throw_errno (GError **error)
+{
+ /* Save the value of errno, in case one of the
+ * intermediate function calls happens to set it.
+ */
+ int errsv = errno;
+ g_set_error_literal (error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ g_strerror (errsv));
+ /* We also restore the value of errno, since that's
+ * what was done in a long-ago libgsystem commit
+ * https://git.gnome.org/browse/libgsystem/commit/?id=ed106741f7a0596dc8b960b31fdae671d31d666d
+ * but I certainly can't remember now why I did that.
+ */
+ errno = errsv;
+ return FALSE;
+}
+
+/* Implementation detail of glnx_throw_errno_prefix() */
+void glnx_real_set_prefix_error_from_errno_va (GError **error,
+ gint errsv,
+ const char *format,
+ va_list args) G_GNUC_PRINTF (3,0);
+
+/* Set @error using the value of `$prefix: g_strerror (errno)` where `$prefix`
+ * is computed via printf @fmt.
+ *
+ * This function returns %FALSE so it can be used conveniently in a single
+ * statement:
+ *
+ * ```
+ * return glnx_throw_errno_prefix (error, "unlinking %s", pathname);
+ * ```
+ */
+static inline gboolean G_GNUC_PRINTF (2,3)
+glnx_throw_errno_prefix (GError **error, const char *fmt, ...)
+{
+ int errsv = errno;
+ va_list args;
+ va_start (args, fmt);
+ glnx_real_set_prefix_error_from_errno_va (error, errsv, fmt, args);
+ va_end (args);
+ /* See comment above about preserving errno */
+ errno = errsv;
+ return FALSE;
+}
+
+/* BEGIN LEGACY APIS */
+
#define glnx_set_error_from_errno(error) \
do { \
- int errsv = errno; \
- g_set_error_literal (error, G_IO_ERROR, \
- g_io_error_from_errno (errsv), \
- g_strerror (errsv)); \
- errno = errsv; \
+ glnx_throw_errno (error); \
} while (0);
-#define glnx_set_prefix_error_from_errno(error, format, args...) \
- do { \
- int errsv = errno; \
- glnx_real_set_prefix_error_from_errno (error, errsv, format, args); \
- errno = errsv; \
+#define glnx_set_prefix_error_from_errno(error, format, args...) \
+ do { \
+ glnx_set_error_from_errno (error); \
+ g_prefix_error (error, format, args); \
} while (0);
-void glnx_real_set_prefix_error_from_errno (GError **error,
- gint errsv,
- const char *format,
- ...) G_GNUC_PRINTF (3,4);
G_END_DECLS
diff --git a/libglnx/glnx-fdio.c b/libglnx/glnx-fdio.c
index 7ee57cd6..68704cb1 100644
--- a/libglnx/glnx-fdio.c
+++ b/libglnx/glnx-fdio.c
@@ -54,11 +54,13 @@
sizeof(type) <= 4 ? 10 : \
sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)])))
-static gboolean
-rename_file_noreplace_at (int olddirfd, const char *oldpath,
- int newdirfd, const char *newpath,
- gboolean ignore_eexist,
- GError **error)
+
+/* An implementation of renameat2(..., RENAME_NOREPLACE)
+ * with fallback to a non-atomic version.
+ */
+int
+glnx_renameat2_noreplace (int olddirfd, const char *oldpath,
+ int newdirfd, const char *newpath)
{
#ifndef ENABLE_WRPSEUDO_COMPAT
if (renameat2 (olddirfd, oldpath, newdirfd, newpath, RENAME_NOREPLACE) < 0)
@@ -66,9 +68,35 @@ rename_file_noreplace_at (int olddirfd, const char *oldpath,
if (errno == EINVAL || errno == ENOSYS)
{
/* Fall through */
- ;
}
- else if (errno == EEXIST && ignore_eexist)
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ return TRUE;
+#endif
+
+ if (linkat (olddirfd, oldpath, newdirfd, newpath, 0) < 0)
+ return -1;
+
+ if (unlinkat (olddirfd, oldpath, 0) < 0)
+ return -1;
+
+ return 0;
+}
+
+static gboolean
+rename_file_noreplace_at (int olddirfd, const char *oldpath,
+ int newdirfd, const char *newpath,
+ gboolean ignore_eexist,
+ GError **error)
+{
+ if (glnx_renameat2_noreplace (olddirfd, oldpath,
+ newdirfd, newpath) < 0)
+ {
+ if (errno == EEXIST && ignore_eexist)
{
(void) unlinkat (olddirfd, oldpath, 0);
return TRUE;
@@ -79,29 +107,46 @@ rename_file_noreplace_at (int olddirfd, const char *oldpath,
return FALSE;
}
}
- else
- return TRUE;
-#endif
+ return TRUE;
+}
- if (linkat (olddirfd, oldpath, newdirfd, newpath, 0) < 0)
+/* An implementation of renameat2(..., RENAME_EXCHANGE)
+ * with fallback to a non-atomic version.
+ */
+int
+glnx_renameat2_exchange (int olddirfd, const char *oldpath,
+ int newdirfd, const char *newpath)
+{
+#ifndef ENABLE_WRPSEUDO_COMPAT
+ if (renameat2 (olddirfd, oldpath, newdirfd, newpath, RENAME_EXCHANGE) == 0)
+ return 0;
+ else
{
- if (errno == EEXIST && ignore_eexist)
- /* Fall through */
- ;
+ if (errno == ENOSYS || errno == EINVAL)
+ {
+ /* Fall through */
+ }
else
{
- glnx_set_error_from_errno (error);
- return FALSE;
+ return -1;
}
}
-
- if (unlinkat (olddirfd, oldpath, 0) < 0)
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+#endif
- return TRUE;
+ /* Fallback */
+ { const char *old_tmp_name = glnx_strjoina (oldpath, ".XXXXXX");
+
+ /* Move old out of the way */
+ if (renameat (olddirfd, oldpath, olddirfd, old_tmp_name) < 0)
+ return -1;
+ /* Now move new into its place */
+ if (renameat (newdirfd, newpath, olddirfd, oldpath) < 0)
+ return -1;
+ /* And finally old(tmp) into new */
+ if (renameat (olddirfd, old_tmp_name, newdirfd, newpath) < 0)
+ return -1;
+ }
+ return 0;
}
gboolean
diff --git a/libglnx/glnx-fdio.h b/libglnx/glnx-fdio.h
index 111df9d5..c3e7573c 100644
--- a/libglnx/glnx-fdio.h
+++ b/libglnx/glnx-fdio.h
@@ -150,4 +150,10 @@ glnx_stream_fstat (GFileDescriptorBased *stream,
struct stat *stbuf,
GError **error);
+int glnx_renameat2_noreplace (int olddirfd, const char *oldpath,
+ int newdirfd, const char *newpath);
+int glnx_renameat2_exchange (int olddirfd, const char *oldpath,
+ int newdirfd, const char *newpath);
+
+
G_END_DECLS
diff --git a/libglnx/glnx-missing.h b/libglnx/glnx-missing.h
index fa80d3e8..a60705a1 100644
--- a/libglnx/glnx-missing.h
+++ b/libglnx/glnx-missing.h
@@ -48,5 +48,8 @@
#ifndef RENAME_NOREPLACE
#define RENAME_NOREPLACE (1 << 0)
#endif
+#ifndef RENAME_EXCHANGE
+#define RENAME_EXCHANGE (1 << 1)
+#endif
#include "glnx-missing-syscall.h"
diff --git a/libglnx/tests/test-libglnx-errors.c b/libglnx/tests/test-libglnx-errors.c
new file mode 100644
index 00000000..8d109cd1
--- /dev/null
+++ b/libglnx/tests/test-libglnx-errors.c
@@ -0,0 +1,79 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * 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 "config.h"
+#include "libglnx.h"
+#include
+#include
+#include
+#include
+
+static void
+test_error_throw (void)
+{
+ g_autoptr(GError) error = NULL;
+
+ g_assert (!glnx_throw (&error, "foo: %s %d", "hello", 42));
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
+ g_assert_cmpstr (error->message, ==, "foo: hello 42");
+}
+
+static void
+test_error_errno (void)
+{
+ g_autoptr(GError) error = NULL;
+ const char noent_path[] = "/enoent-this-should-not-exist";
+ int fd;
+
+ fd = open (noent_path, O_RDONLY);
+ if (fd < 0)
+ {
+ g_assert (!glnx_throw_errno (&error));
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
+ g_clear_error (&error);
+ }
+ else
+ g_assert_cmpint (fd, ==, -1);
+
+ fd = open (noent_path, O_RDONLY);
+ if (fd < 0)
+ {
+ g_assert (!glnx_throw_errno_prefix (&error, "Failed to open %s", noent_path));
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
+ g_assert (g_str_has_prefix (error->message, glnx_strjoina ("Failed to open ", noent_path)));
+ g_clear_error (&error);
+ }
+ else
+ g_assert_cmpint (fd, ==, -1);
+}
+
+int main (int argc, char **argv)
+{
+ int ret;
+
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/error-throw", test_error_throw);
+ g_test_add_func ("/error-errno", test_error_errno);
+
+ ret = g_test_run();
+
+ return ret;
+}
diff --git a/libglnx/tests/test-libglnx-fdio.c b/libglnx/tests/test-libglnx-fdio.c
new file mode 100644
index 00000000..9830c107
--- /dev/null
+++ b/libglnx/tests/test-libglnx-fdio.c
@@ -0,0 +1,155 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * 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 "config.h"
+#include "libglnx.h"
+#include
+#include
+#include
+#include
+#include
+
+static gboolean
+renameat_test_setup (int *out_srcfd, int *out_destfd,
+ GError **error)
+{
+ glnx_fd_close int srcfd = -1;
+ glnx_fd_close int destfd = -1;
+
+ (void) glnx_shutil_rm_rf_at (AT_FDCWD, "srcdir", NULL, NULL);
+ if (mkdir ("srcdir", 0755) < 0)
+ err (1, "mkdir");
+ if (!glnx_opendirat (AT_FDCWD, "srcdir", TRUE, &srcfd, error))
+ return FALSE;
+ (void) glnx_shutil_rm_rf_at (AT_FDCWD, "destdir", NULL, NULL);
+ if (mkdir ("destdir", 0755) < 0)
+ err (1, "mkdir");
+ if (!glnx_opendirat (AT_FDCWD, "destdir", TRUE, &destfd, error))
+ return FALSE;
+
+ if (!glnx_file_replace_contents_at (srcfd, "foo", (guint8*)"foo contents", strlen ("foo contents"),
+ GLNX_FILE_REPLACE_NODATASYNC, NULL, error))
+ return FALSE;
+ if (!glnx_file_replace_contents_at (destfd, "bar", (guint8*)"bar contents", strlen ("bar contents"),
+ GLNX_FILE_REPLACE_NODATASYNC, NULL, error))
+ return FALSE;
+
+ *out_srcfd = srcfd; srcfd = -1;
+ *out_destfd = destfd; destfd = -1;
+ return TRUE;
+}
+
+static void
+test_renameat2_noreplace (void)
+{
+ g_autoptr(GError) local_error = NULL;
+ GError **error = &local_error;
+ glnx_fd_close int srcfd = -1;
+ glnx_fd_close int destfd = -1;
+ struct stat stbuf;
+
+ if (!renameat_test_setup (&srcfd, &destfd, error))
+ goto out;
+
+ if (glnx_renameat2_noreplace (srcfd, "foo", destfd, "bar") == 0)
+ g_assert_not_reached ();
+ else
+ {
+ g_assert_cmpint (errno, ==, EEXIST);
+ }
+
+ if (glnx_renameat2_noreplace (srcfd, "foo", destfd, "baz") < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+ if (fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+
+ if (fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW) == 0)
+ g_assert_not_reached ();
+ else
+ g_assert_cmpint (errno, ==, ENOENT);
+
+ out:
+ g_assert_no_error (local_error);
+}
+
+static void
+test_renameat2_exchange (void)
+{
+ g_autoptr(GError) local_error = NULL;
+ GError **error = &local_error;
+ glnx_fd_close int srcfd = -1;
+ glnx_fd_close int destfd = -1;
+ struct stat stbuf;
+
+ if (!renameat_test_setup (&srcfd, &destfd, error))
+ goto out;
+
+ if (glnx_renameat2_exchange (AT_FDCWD, "srcdir", AT_FDCWD, "destdir") < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+
+ /* Ensure the dir fds are the same */
+ if (fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+ if (fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+ /* But the dirs should be swapped */
+ if (fstatat (AT_FDCWD, "destdir/foo", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+ if (fstatat (AT_FDCWD, "srcdir/bar", &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+
+ out:
+ g_assert_no_error (local_error);
+}
+
+int main (int argc, char **argv)
+{
+ int ret;
+
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/renameat2-noreplace", test_renameat2_noreplace);
+ g_test_add_func ("/renameat2-exchange", test_renameat2_exchange);
+
+ ret = g_test_run();
+
+ return ret;
+}
diff --git a/man/ostree-admin-cleanup.1 b/man/ostree-admin-cleanup.1
index e56eb258..4fb7bd71 100644
--- a/man/ostree-admin-cleanup.1
+++ b/man/ostree-admin-cleanup.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin cleanup
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin cleanup
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-config-diff.1 b/man/ostree-admin-config-diff.1
index bd90eeda..d94c1693 100644
--- a/man/ostree-admin-config-diff.1
+++ b/man/ostree-admin-config-diff.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin config-diff
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin config-diff
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-deploy.1 b/man/ostree-admin-deploy.1
index 8286872d..669449b1 100644
--- a/man/ostree-admin-deploy.1
+++ b/man/ostree-admin-deploy.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin deploy
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin deploy
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-init-fs.1 b/man/ostree-admin-init-fs.1
index bdd9e4bf..785f55ef 100644
--- a/man/ostree-admin-init-fs.1
+++ b/man/ostree-admin-init-fs.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin init-fs
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin init-fs
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-instutil.1 b/man/ostree-admin-instutil.1
index 106badf8..f6c90952 100644
--- a/man/ostree-admin-instutil.1
+++ b/man/ostree-admin-instutil.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin instutil
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin instutil
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-os-init.1 b/man/ostree-admin-os-init.1
index 3eb9ae51..17775557 100644
--- a/man/ostree-admin-os-init.1
+++ b/man/ostree-admin-os-init.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin os-init
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin os-init
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-set-origin.1 b/man/ostree-admin-set-origin.1
index 9ed4a5ad..fe1db02d 100644
--- a/man/ostree-admin-set-origin.1
+++ b/man/ostree-admin-set-origin.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin set-origin
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin set-origin
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-status.1 b/man/ostree-admin-status.1
index 1f7f35cf..5a14d3e5 100644
--- a/man/ostree-admin-status.1
+++ b/man/ostree-admin-status.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin status
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin status
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-switch.1 b/man/ostree-admin-switch.1
index 07bc8ecc..d783ae28 100644
--- a/man/ostree-admin-switch.1
+++ b/man/ostree-admin-switch.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin switch
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin switch
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-undeploy.1 b/man/ostree-admin-undeploy.1
index 62581b7c..88a7ba41 100644
--- a/man/ostree-admin-undeploy.1
+++ b/man/ostree-admin-undeploy.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin undeploy
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin undeploy
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-unlock.1 b/man/ostree-admin-unlock.1
index 55692e0e..68145e27 100644
--- a/man/ostree-admin-unlock.1
+++ b/man/ostree-admin-unlock.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin unlock
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin unlock
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin-upgrade.1 b/man/ostree-admin-upgrade.1
index c5fb18c5..3ccd85dd 100644
--- a/man/ostree-admin-upgrade.1
+++ b/man/ostree-admin-upgrade.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin upgrade
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin upgrade
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-admin.1 b/man/ostree-admin.1
index ad6197c4..2de6a630 100644
--- a/man/ostree-admin.1
+++ b/man/ostree-admin.1
@@ -2,7 +2,7 @@
.\" Title: ostree admin
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree admin
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-cat.1 b/man/ostree-cat.1
index ac4d68ce..c068668a 100644
--- a/man/ostree-cat.1
+++ b/man/ostree-cat.1
@@ -2,7 +2,7 @@
.\" Title: ostree cat
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree cat
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-checkout.1 b/man/ostree-checkout.1
index 1c0fe556..80420983 100644
--- a/man/ostree-checkout.1
+++ b/man/ostree-checkout.1
@@ -2,7 +2,7 @@
.\" Title: ostree checkout
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree checkout
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-checksum.1 b/man/ostree-checksum.1
index 0760c66f..7d2d56bc 100644
--- a/man/ostree-checksum.1
+++ b/man/ostree-checksum.1
@@ -2,7 +2,7 @@
.\" Title: ostree checksum
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree checksum
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-commit.1 b/man/ostree-commit.1
index 4cb81b77..d3ce3286 100644
--- a/man/ostree-commit.1
+++ b/man/ostree-commit.1
@@ -2,7 +2,7 @@
.\" Title: ostree commit
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree commit
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-config.1 b/man/ostree-config.1
index f712532f..2a820647 100644
--- a/man/ostree-config.1
+++ b/man/ostree-config.1
@@ -2,7 +2,7 @@
.\" Title: ostree config
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree config
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-diff.1 b/man/ostree-diff.1
index 10d7f82a..d91442ab 100644
--- a/man/ostree-diff.1
+++ b/man/ostree-diff.1
@@ -2,7 +2,7 @@
.\" Title: ostree diff
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/11/2017
.\" Manual: ostree diff
.\" Source: OSTree
.\" Language: English
@@ -46,6 +46,16 @@ Print various statistics\&.
.RS 4
Print filesystem diff\&.
.RE
+.PP
+\fB\-\-owner\-uid\fR
+.RS 4
+Use file ownership user id for local files\&.
+.RE
+.PP
+\fB\-\-owner\-gid\fR
+.RS 4
+Use file ownership group id for local files\&.
+.RE
.SH "EXAMPLE"
.PP
\fB$ ostree diff my\-branch^ my\-branch\fR
diff --git a/man/ostree-diff.xml b/man/ostree-diff.xml
index aaa76b13..906374b4 100644
--- a/man/ostree-diff.xml
+++ b/man/ostree-diff.xml
@@ -78,6 +78,20 @@ Boston, MA 02111-1307, USA.
Print filesystem diff.
+
+
+
+
+ Use file ownership user id for local files.
+
+
+
+
+
+
+ Use file ownership group id for local files.
+
+
diff --git a/man/ostree-export.1 b/man/ostree-export.1
index 520a43f3..b642a026 100644
--- a/man/ostree-export.1
+++ b/man/ostree-export.1
@@ -2,7 +2,7 @@
.\" Title: ostree export
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree export
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-fsck.1 b/man/ostree-fsck.1
index fea14ae4..c7cf826b 100644
--- a/man/ostree-fsck.1
+++ b/man/ostree-fsck.1
@@ -2,7 +2,7 @@
.\" Title: ostree fsck
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree fsck
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-gpg-sign.1 b/man/ostree-gpg-sign.1
index 93b1799f..150e488a 100644
--- a/man/ostree-gpg-sign.1
+++ b/man/ostree-gpg-sign.1
@@ -2,7 +2,7 @@
.\" Title: ostree gpg-sign
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree gpg-sign
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-init.1 b/man/ostree-init.1
index 18f5de61..303f9ebe 100644
--- a/man/ostree-init.1
+++ b/man/ostree-init.1
@@ -2,7 +2,7 @@
.\" Title: ostree init
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree init
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-log.1 b/man/ostree-log.1
index 885abb3c..8b6bbb50 100644
--- a/man/ostree-log.1
+++ b/man/ostree-log.1
@@ -2,7 +2,7 @@
.\" Title: ostree log
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree log
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-ls.1 b/man/ostree-ls.1
index 64827242..9488f2a4 100644
--- a/man/ostree-ls.1
+++ b/man/ostree-ls.1
@@ -2,7 +2,7 @@
.\" Title: ostree ls
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree ls
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-prune.1 b/man/ostree-prune.1
index ebcadc48..d474c1cf 100644
--- a/man/ostree-prune.1
+++ b/man/ostree-prune.1
@@ -2,7 +2,7 @@
.\" Title: ostree prune
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree prune
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-pull-local.1 b/man/ostree-pull-local.1
index 6012d143..af5e740c 100644
--- a/man/ostree-pull-local.1
+++ b/man/ostree-pull-local.1
@@ -2,7 +2,7 @@
.\" Title: ostree pull-local
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree pull-local
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-pull.1 b/man/ostree-pull.1
index 3ff0ce7a..17d9fcbd 100644
--- a/man/ostree-pull.1
+++ b/man/ostree-pull.1
@@ -2,7 +2,7 @@
.\" Title: ostree pull
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree pull
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-refs.1 b/man/ostree-refs.1
index b1fd6d18..0734d0f2 100644
--- a/man/ostree-refs.1
+++ b/man/ostree-refs.1
@@ -2,7 +2,7 @@
.\" Title: ostree refs
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree refs
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-remote.1 b/man/ostree-remote.1
index 7414a2a4..20278e44 100644
--- a/man/ostree-remote.1
+++ b/man/ostree-remote.1
@@ -2,7 +2,7 @@
.\" Title: ostree remote
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree remote
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-reset.1 b/man/ostree-reset.1
index 58af17e4..b009d9e9 100644
--- a/man/ostree-reset.1
+++ b/man/ostree-reset.1
@@ -2,7 +2,7 @@
.\" Title: ostree reset
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree reset
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-rev-parse.1 b/man/ostree-rev-parse.1
index 5612fd54..3da7374b 100644
--- a/man/ostree-rev-parse.1
+++ b/man/ostree-rev-parse.1
@@ -2,7 +2,7 @@
.\" Title: ostree rev-parse
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree rev-parse
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-show.1 b/man/ostree-show.1
index f7354442..5fb6c675 100644
--- a/man/ostree-show.1
+++ b/man/ostree-show.1
@@ -2,7 +2,7 @@
.\" Title: ostree show
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree show
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-static-delta.1 b/man/ostree-static-delta.1
index 20a92b01..5d2ed8e9 100644
--- a/man/ostree-static-delta.1
+++ b/man/ostree-static-delta.1
@@ -2,7 +2,7 @@
.\" Title: ostree static-delta
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree static-delta
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-summary.1 b/man/ostree-summary.1
index a2d89e6c..6e258f0b 100644
--- a/man/ostree-summary.1
+++ b/man/ostree-summary.1
@@ -2,7 +2,7 @@
.\" Title: ostree summary
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree summary
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree-trivial-httpd.1 b/man/ostree-trivial-httpd.1
index d3ceb2a9..a6a7cafe 100644
--- a/man/ostree-trivial-httpd.1
+++ b/man/ostree-trivial-httpd.1
@@ -2,7 +2,7 @@
.\" Title: ostree trivial-httpd
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree trivial-httpd
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree.1 b/man/ostree.1
index 2bf2f880..63be4b08 100644
--- a/man/ostree.1
+++ b/man/ostree.1
@@ -2,7 +2,7 @@
.\" Title: ostree
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree.repo-config.5 b/man/ostree.repo-config.5
index 56dc33f2..7d84d39b 100644
--- a/man/ostree.repo-config.5
+++ b/man/ostree.repo-config.5
@@ -2,7 +2,7 @@
.\" Title: ostree.repo-config
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree.repo-config
.\" Source: OSTree
.\" Language: English
diff --git a/man/ostree.repo.5 b/man/ostree.repo.5
index e8693d73..9d630fa1 100644
--- a/man/ostree.repo.5
+++ b/man/ostree.repo.5
@@ -2,7 +2,7 @@
.\" Title: ostree.repo
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: ostree.repo
.\" Source: OSTree
.\" Language: English
diff --git a/man/rofiles-fuse.1 b/man/rofiles-fuse.1
index 6839844d..4c6de299 100644
--- a/man/rofiles-fuse.1
+++ b/man/rofiles-fuse.1
@@ -2,7 +2,7 @@
.\" Title: rofiles-fuse
.\" Author: Colin Walters
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 03/10/2017
+.\" Date: 04/05/2017
.\" Manual: rofiles-fuse
.\" Source: rofiles-fuse
.\" Language: English
diff --git a/src/libostree/libostree.sym b/src/libostree/libostree.sym
index b7cfc454..d9339bf2 100644
--- a/src/libostree/libostree.sym
+++ b/src/libostree/libostree.sym
@@ -381,16 +381,25 @@ global:
ostree_raw_file_to_archive_z2_stream_with_options;
} LIBOSTREE_2017.2;
+LIBOSTREE_2017.4 {
+global:
+ ostree_check_version;
+ ostree_diff_dirs_with_options;
+ ostree_sepolicy_new_at;
+ ostree_sysroot_write_deployments_with_options;
+} LIBOSTREE_2017.3;
+
/* NOTE NOTE NOTE
* Versions above here are released. Only add symbols below this line.
* NOTE NOTE NOTE
*/
-/* Stub section for new version, uncomment when the first symbol is added
+/* Uncomment when adding the first new symbol */
+/*
LIBOSTREE_2017.$NEWVERSION {
global:
someostree_symbol_deleteme;
-} LIBOSTREE_2017.2;
+} LIBOSTREE_2017.4;
*/
/* Stub section for the stable release *after* this development one; don't
diff --git a/src/libostree/ostree-autocleanups.h b/src/libostree/ostree-autocleanups.h
index 7301ef1d..f030b50e 100644
--- a/src/libostree/ostree-autocleanups.h
+++ b/src/libostree/ostree-autocleanups.h
@@ -26,14 +26,10 @@
G_BEGIN_DECLS
-#ifndef OSTREE_WITH_AUTOCLEANUPS
-#define OSTREE_WITH_AUTOCLEANUPS 0
-#endif
-
/* ostree can use g_autoptr backports from libglnx when glib is too
* old, but still avoid exposing them to users that also have an old
* glib */
-#if defined(OSTREE_COMPILATION) || (OSTREE_WITH_AUTOCLEANUPS && GLIB_CHECK_VERSION(2, 44, 0))
+#if defined(OSTREE_COMPILATION) || GLIB_CHECK_VERSION(2, 44, 0)
/*
* The following types have no specific clear/free/unref functions, so
diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c
index 6f245fb7..2cd02287 100644
--- a/src/libostree/ostree-bootloader-grub2.c
+++ b/src/libostree/ostree-bootloader-grub2.c
@@ -353,7 +353,7 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader,
use_system_grub2_mkconfig = FALSE;
}
else
- grub_exec = use_system_grub2_mkconfig ? GRUB2_MKCONFIG_PATH : "/usr/lib/ostree/ostree-grub-generator";
+ grub_exec = use_system_grub2_mkconfig ? GRUB2_MKCONFIG_PATH : TARGET_PREFIX "/lib/ostree/ostree-grub-generator";
if (use_system_grub2_mkconfig && ostree_sysroot_get_booted_deployment (self->sysroot) == NULL
&& g_file_has_parent (self->sysroot->path, NULL))
diff --git a/src/libostree/ostree-core-private.h b/src/libostree/ostree-core-private.h
index cfd8a998..a66a068f 100644
--- a/src/libostree/ostree-core-private.h
+++ b/src/libostree/ostree-core-private.h
@@ -139,6 +139,15 @@ _ostree_loose_path (char *buf,
#define _OSTREE_METADATA_GPGSIGS_NAME "ostree.gpgsigs"
#define _OSTREE_METADATA_GPGSIGS_TYPE G_VARIANT_TYPE ("aay")
+static inline gboolean
+_ostree_repo_mode_is_bare (OstreeRepoMode mode)
+{
+ return
+ mode == OSTREE_REPO_MODE_BARE ||
+ mode == OSTREE_REPO_MODE_BARE_USER ||
+ mode == OSTREE_REPO_MODE_BARE_USER_ONLY;
+}
+
GVariant *
_ostree_detached_metadata_append_gpg_sig (GVariant *existing_metadata,
GBytes *signature_bytes);
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index cf238b41..bab2ab33 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -121,13 +121,8 @@ ostree_parse_refspec (const char *refspec,
char **out_ref,
GError **error)
{
- gboolean ret = FALSE;
- GMatchInfo *match = NULL;
- g_autofree char *remote = NULL;
-
- static gsize regex_initialized;
static GRegex *regex;
-
+ static gsize regex_initialized;
if (g_once_init_enter (®ex_initialized))
{
regex = g_regex_new ("^(" OSTREE_REF_FRAGMENT_REGEXP ":)?(" OSTREE_REF_REGEXP ")$", 0, 0, NULL);
@@ -135,14 +130,11 @@ ostree_parse_refspec (const char *refspec,
g_once_init_leave (®ex_initialized, 1);
}
+ g_autoptr(GMatchInfo) match = NULL;
if (!g_regex_match (regex, refspec, 0, &match))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid refspec %s", refspec);
- goto out;
- }
+ return glnx_throw (error, "Invalid refspec %s", refspec);
- remote = g_match_info_fetch (match, 1);
+ g_autofree char *remote = g_match_info_fetch (match, 1);
if (*remote == '\0')
{
g_clear_pointer (&remote, g_free);
@@ -153,16 +145,11 @@ ostree_parse_refspec (const char *refspec,
remote[strlen(remote)-1] = '\0';
}
- ret = TRUE;
-
if (out_remote)
*out_remote = g_steal_pointer (&remote);
if (out_ref != NULL)
*out_ref = g_match_info_fetch (match, 2);
- out:
- if (match)
- g_match_info_unref (match);
- return ret;
+ return TRUE;
}
/**
@@ -176,12 +163,10 @@ gboolean
ostree_validate_rev (const char *rev,
GError **error)
{
- gboolean ret = FALSE;
- GMatchInfo *match = NULL;
+ g_autoptr(GMatchInfo) match = NULL;
static gsize regex_initialized;
static GRegex *regex;
-
if (g_once_init_enter (®ex_initialized))
{
regex = g_regex_new ("^" OSTREE_REF_REGEXP "$", 0, 0, NULL);
@@ -190,17 +175,9 @@ ostree_validate_rev (const char *rev,
}
if (!g_regex_match (regex, rev, 0, &match))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid ref name %s", rev);
- goto out;
- }
+ return glnx_throw (error, "Invalid ref name %s", rev);
- ret = TRUE;
- out:
- if (match)
- g_match_info_unref (match);
- return ret;
+ return TRUE;
}
GVariant *
@@ -282,7 +259,6 @@ write_padding (GOutputStream *output,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
guint bits;
guint padding_len;
guchar padding_nuls[8] = {0, 0, 0, 0, 0, 0, 0, 0};
@@ -298,12 +274,10 @@ write_padding (GOutputStream *output,
if (!ot_gio_write_update_checksum (output, (guchar*)padding_nuls, padding_len,
out_bytes_written, checksum,
cancellable, error))
- goto out;
+ return FALSE;
}
-
- ret = TRUE;
- out:
- return ret;
+
+ return TRUE;
}
/*
@@ -330,7 +304,6 @@ _ostree_write_variant_with_size (GOutputStream *output,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
guint64 variant_size;
guint32 variant_size_u32_be;
gsize bytes_written;
@@ -345,7 +318,7 @@ _ostree_write_variant_with_size (GOutputStream *output,
if (!ot_gio_write_update_checksum (output, &variant_size_u32_be, 4,
&bytes_written, checksum,
cancellable, error))
- goto out;
+ return FALSE;
ret_bytes_written += bytes_written;
alignment_offset += bytes_written;
@@ -353,21 +326,19 @@ _ostree_write_variant_with_size (GOutputStream *output,
/* Pad to offset of 8, write variant */
if (!write_padding (output, 8, alignment_offset, &bytes_written, checksum,
cancellable, error))
- goto out;
+ return FALSE;
ret_bytes_written += bytes_written;
bytes_written = 0;
if (!ot_gio_write_update_checksum (output, g_variant_get_data (variant),
variant_size, &bytes_written, checksum,
cancellable, error))
- goto out;
+ return FALSE;
ret_bytes_written += bytes_written;
- ret = TRUE;
if (out_bytes_written)
*out_bytes_written = ret_bytes_written;
- out:
- return ret;
+ return TRUE;
}
/*
@@ -388,16 +359,13 @@ write_file_header_update_checksum (GOutputStream *out,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
gsize bytes_written;
if (!_ostree_write_variant_with_size (out, header, 0, &bytes_written, checksum,
cancellable, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/*
@@ -724,32 +692,28 @@ ostree_content_file_parse_at (gboolean compressed,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- struct stat stbuf;
g_autoptr(GInputStream) file_input = NULL;
- g_autoptr(GInputStream) ret_input = NULL;
- g_autoptr(GFileInfo) ret_file_info = NULL;
- g_autoptr(GVariant) ret_xattrs = NULL;
-
if (!ot_openat_read_stream (parent_dfd, path, TRUE, &file_input,
cancellable, error))
- goto out;
-
+ return FALSE;
+
+ struct stat stbuf;
if (!glnx_stream_fstat ((GFileDescriptorBased*)file_input, &stbuf, error))
- goto out;
-
+ return FALSE;
+
+ g_autoptr(GFileInfo) ret_file_info = NULL;
+ g_autoptr(GVariant) ret_xattrs = NULL;
+ g_autoptr(GInputStream) ret_input = NULL;
if (!ostree_content_stream_parse (compressed, file_input, stbuf.st_size, trusted,
out_input ? &ret_input : NULL,
&ret_file_info, &ret_xattrs,
cancellable, error))
- goto out;
-
- ret = TRUE;
+ return FALSE;
+
ot_transfer_out_value (out_input, &ret_input);
ot_transfer_out_value (out_file_info, &ret_file_info);
ot_transfer_out_value (out_xattrs, &ret_xattrs);
- out:
- return ret;
+ return TRUE;
}
/**
@@ -804,23 +768,19 @@ ostree_checksum_file_from_input (GFileInfo *file_info,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autofree guchar *ret_csum = NULL;
- GChecksum *checksum = NULL;
- checksum = g_checksum_new (G_CHECKSUM_SHA256);
+ g_autoptr(GChecksum) checksum = g_checksum_new (G_CHECKSUM_SHA256);
if (OSTREE_OBJECT_TYPE_IS_META (objtype))
{
if (!ot_gio_splice_update_checksum (NULL, in, checksum, cancellable, error))
- goto out;
+ return FALSE;
}
else if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
{
g_autoptr(GVariant) dirmeta = ostree_create_directory_metadata (file_info, xattrs);
g_checksum_update (checksum, g_variant_get_data (dirmeta),
g_variant_get_size (dirmeta));
-
}
else
{
@@ -830,22 +790,17 @@ ostree_checksum_file_from_input (GFileInfo *file_info,
if (!write_file_header_update_checksum (NULL, file_header, checksum,
cancellable, error))
- goto out;
+ return FALSE;
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
{
if (!ot_gio_splice_update_checksum (NULL, in, checksum, cancellable, error))
- goto out;
+ return FALSE;
}
}
- ret_csum = ot_csum_from_gchecksum (checksum);
-
- ret = TRUE;
- ot_transfer_out_value (out_csum, &ret_csum);
- out:
- g_clear_pointer (&checksum, (GDestroyNotify)g_checksum_free);
- return ret;
+ *out_csum = ot_csum_from_gchecksum (checksum);
+ return TRUE;
}
/**
@@ -1042,10 +997,9 @@ _ostree_make_temporary_symlink_at (int tmp_dirfd,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- char *tmpname = g_strdup ("tmplink.XXXXXX");
- guint i;
+ g_autofree char *tmpname = g_strdup ("tmplink.XXXXXX");
const int max_attempts = 128;
+ guint i;
for (i = 0; i < max_attempts; i++)
{
@@ -1055,28 +1009,17 @@ _ostree_make_temporary_symlink_at (int tmp_dirfd,
if (errno == EEXIST)
continue;
else
- {
- int errsv = errno;
- g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errsv),
- g_strerror (errsv));
- goto out;
- }
+ return glnx_throw_errno (error);
}
else
break;
}
if (i == max_attempts)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Exhausted attempts to open temporary file");
- goto out;
- }
+ return glnx_throw (error, "Exhausted attempts to open temporary file");
- ret = TRUE;
if (out_name)
*out_name = g_steal_pointer (&tmpname);
- out:
- return ret;
+ return TRUE;
}
@@ -1351,16 +1294,7 @@ void
ostree_checksum_inplace_from_bytes (const guchar *csum,
char *buf)
{
- static const gchar hexchars[] = "0123456789abcdef";
- guint i, j;
-
- for (i = 0, j = 0; i < OSTREE_SHA256_DIGEST_LEN; i++, j += 2)
- {
- guchar byte = csum[i];
- buf[j] = hexchars[byte >> 4];
- buf[j+1] = hexchars[byte & 0xF];
- }
- buf[j] = '\0';
+ ot_bin2hex (buf, csum, OSTREE_SHA256_DIGEST_LEN);
}
/**
@@ -1807,13 +1741,9 @@ ostree_validate_structureof_objtype (guchar objtype,
GError **error)
{
OstreeObjectType objtype_v = (OstreeObjectType) objtype;
- if (objtype_v < OSTREE_OBJECT_TYPE_FILE
+ if (objtype_v < OSTREE_OBJECT_TYPE_FILE
|| objtype_v > OSTREE_OBJECT_TYPE_COMMIT)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid object type '%u'", objtype);
- return FALSE;
- }
+ return glnx_throw (error, "Invalid object type '%u'", objtype);
return TRUE;
}
@@ -1846,11 +1776,7 @@ ostree_validate_structureof_checksum_string (const char *checksum,
size_t len = strlen (checksum);
if (len != OSTREE_SHA256_STRING_LEN)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid rev '%s'", checksum);
- return FALSE;
- }
+ return glnx_throw (error, "Invalid rev '%s'", checksum);
for (i = 0; i < len; i++)
{
@@ -2153,3 +2079,16 @@ _ostree_get_default_sysroot_path (void)
return default_sysroot_path;
}
+
+/**
+ * ostree_check_version:
+ * @required_year: Major/year required
+ * @required_release: Release version required
+ *
+ * Returns: %TRUE if current libostree has at least the requested version, %FALSE otherwise
+ */
+gboolean
+ostree_check_version (guint required_year, guint required_release)
+{
+ return OSTREE_CHECK_VERSION(required_year, required_release);
+}
diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h
index bd3d5f2c..b25112db 100644
--- a/src/libostree/ostree-core.h
+++ b/src/libostree/ostree-core.h
@@ -179,6 +179,7 @@ typedef enum {
* @OSTREE_REPO_MODE_BARE: Files are stored as themselves; checkouts are hardlinks; can only be written as root
* @OSTREE_REPO_MODE_ARCHIVE_Z2: Files are compressed, should be owned by non-root. Can be served via HTTP
* @OSTREE_REPO_MODE_BARE_USER: Files are stored as themselves, except ownership; can be written by user. Hardlinks work only in user checkouts.
+ * @OSTREE_REPO_MODE_BARE_USER_ONLY: Same as BARE_USER, but all metadata is not stored, so it can only be used for user checkouts. Does not need xattrs.
*
* See the documentation of #OstreeRepo for more information about the
* possible modes.
@@ -186,7 +187,8 @@ typedef enum {
typedef enum {
OSTREE_REPO_MODE_BARE,
OSTREE_REPO_MODE_ARCHIVE_Z2,
- OSTREE_REPO_MODE_BARE_USER
+ OSTREE_REPO_MODE_BARE_USER,
+ OSTREE_REPO_MODE_BARE_USER_ONLY,
} OstreeRepoMode;
_OSTREE_PUBLIC
@@ -399,4 +401,7 @@ gchar * ostree_commit_get_parent (GVariant *commit_variant);
_OSTREE_PUBLIC
guint64 ostree_commit_get_timestamp (GVariant *commit_variant);
+_OSTREE_PUBLIC
+gboolean ostree_check_version (guint required_year, guint required_release);
+
G_END_DECLS
diff --git a/src/libostree/ostree-diff.c b/src/libostree/ostree-diff.c
index 69a67b76..b428fb44 100644
--- a/src/libostree/ostree-diff.c
+++ b/src/libostree/ostree-diff.c
@@ -24,6 +24,7 @@
#include "libglnx.h"
#include "ostree.h"
+#include "ostree-repo-private.h"
#include "otutil.h"
static gboolean
@@ -225,6 +226,37 @@ ostree_diff_dirs (OstreeDiffFlags flags,
GPtrArray *added,
GCancellable *cancellable,
GError **error)
+{
+ return ostree_diff_dirs_with_options (flags, a, b, modified,
+ removed, added, NULL,
+ cancellable, error);
+}
+
+/**
+ * ostree_diff_dirs_with_options:
+ * @flags: Flags
+ * @a: First directory path, or %NULL
+ * @b: First directory path
+ * @modified: (element-type OstreeDiffItem): Modified files
+ * @removed: (element-type Gio.File): Removed files
+ * @added: (element-type Gio.File): Added files
+ * @cancellable: Cancellable
+ * @options: (allow-none): Options
+ * @error: Error
+ *
+ * Compute the difference between directory @a and @b as 3 separate
+ * sets of #OstreeDiffItem in @modified, @removed, and @added.
+ */
+gboolean
+ostree_diff_dirs_with_options (OstreeDiffFlags flags,
+ GFile *a,
+ GFile *b,
+ GPtrArray *modified,
+ GPtrArray *removed,
+ GPtrArray *added,
+ OstreeDiffDirsOptions *options,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
GError *temp_error = NULL;
@@ -233,6 +265,23 @@ ostree_diff_dirs (OstreeDiffFlags flags,
g_autoptr(GFile) child_b = NULL;
g_autoptr(GFileInfo) child_a_info = NULL;
g_autoptr(GFileInfo) child_b_info = NULL;
+ OstreeDiffDirsOptions default_opts = OSTREE_DIFF_DIRS_OPTIONS_INIT;
+
+ if (!options)
+ options = &default_opts;
+
+ /* If we're diffing versus a repo, and either of them have xattrs disabled,
+ * then disable for both.
+ */
+ OstreeRepo *repo;
+ if (OSTREE_IS_REPO_FILE (a))
+ repo = ostree_repo_file_get_repo ((OstreeRepoFile*)a);
+ else if (OSTREE_IS_REPO_FILE (b))
+ repo = ostree_repo_file_get_repo ((OstreeRepoFile*)b);
+ else
+ repo = NULL;
+ if (repo != NULL && repo->disable_xattrs)
+ flags |= OSTREE_DIFF_FLAGS_IGNORE_XATTRS;
if (a == NULL)
{
@@ -316,6 +365,11 @@ ostree_diff_dirs (OstreeDiffFlags flags,
}
else
{
+ if (options->owner_uid >= 0)
+ g_file_info_set_attribute_uint32 (child_b_info, "unix::uid", options->owner_uid);
+ if (options->owner_gid >= 0)
+ g_file_info_set_attribute_uint32 (child_b_info, "unix::gid", options->owner_gid);
+
child_b_type = g_file_info_get_file_type (child_b_info);
if (child_a_type != child_b_type)
{
@@ -337,8 +391,9 @@ ostree_diff_dirs (OstreeDiffFlags flags,
if (child_a_type == G_FILE_TYPE_DIRECTORY)
{
- if (!ostree_diff_dirs (flags, child_a, child_b, modified,
- removed, added, cancellable, error))
+ if (!ostree_diff_dirs_with_options (flags, child_a, child_b, modified,
+ removed, added, options,
+ cancellable, error))
goto out;
}
}
diff --git a/src/libostree/ostree-diff.h b/src/libostree/ostree-diff.h
index 781bf768..b33bd63a 100644
--- a/src/libostree/ostree-diff.h
+++ b/src/libostree/ostree-diff.h
@@ -71,6 +71,42 @@ gboolean ostree_diff_dirs (OstreeDiffFlags flags,
GCancellable *cancellable,
GError **error);
+/**
+ * OstreeDiffDirsOptions:
+ *
+ * An extensible options structure controlling diff dirs. Make sure
+ * that owner_uid/gid is set to -1 when not used. This is used by
+ * ostree_diff_dirs_with_options().
+ */
+typedef struct {
+ gint owner_uid;
+ gint owner_gid;
+
+ OstreeRepoDevInoCache *devino_to_csum_cache;
+
+ gboolean unused_bools[7];
+ int unused_ints[6];
+ gpointer unused_ptrs[7];
+} OstreeDiffDirsOptions;
+
+/**
+ * OSTREE_DIFF_DIRS_OPTIONS_INIT:
+ *
+ * Use this to initialize an `OstreeDiffDirsOptions` structure.
+ */
+#define OSTREE_DIFF_DIRS_OPTIONS_INIT { .owner_uid = -1, .owner_gid = -1, }
+
+_OSTREE_PUBLIC
+gboolean ostree_diff_dirs_with_options (OstreeDiffFlags flags,
+ GFile *a,
+ GFile *b,
+ GPtrArray *modified,
+ GPtrArray *removed,
+ GPtrArray *added,
+ OstreeDiffDirsOptions *options,
+ GCancellable *cancellable,
+ GError **error);
+
_OSTREE_PUBLIC
void ostree_diff_print (GFile *a,
GFile *b,
diff --git a/src/libostree/ostree-fetcher-curl.c b/src/libostree/ostree-fetcher-curl.c
index be0e4b41..829f4447 100644
--- a/src/libostree/ostree-fetcher-curl.c
+++ b/src/libostree/ostree-fetcher-curl.c
@@ -36,6 +36,14 @@
#define CURL_AT_LEAST_VERSION(x,y,z) (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
#endif
+/* Cargo culted from https://github.com/curl/curl/blob/curl-7_53_0/docs/examples/http2-download.c */
+#ifndef CURLPIPE_MULTIPLEX
+/* This little trick will just make sure that we don't enable pipelining for
+ libcurls old enough to not have this symbol. It is _not_ defined to zero in
+ a recent libcurl header. */
+#define CURLPIPE_MULTIPLEX 0
+#endif
+
#include "ostree-fetcher.h"
#include "ostree-fetcher-util.h"
#include "ostree-enumtypes.h"
@@ -219,6 +227,12 @@ _ostree_fetcher_init (OstreeFetcher *self)
#if CURL_AT_LEAST_VERSION(7, 30, 0)
/* Let's do something reasonable here. */
curl_multi_setopt (self->multi, CURLMOPT_MAX_TOTAL_CONNECTIONS, 8);
+#endif
+ /* This version mirrors the version at which we're enabling HTTP2 support.
+ * See also https://github.com/curl/curl/blob/curl-7_53_0/docs/examples/http2-download.c
+ */
+#if CURL_AT_LEAST_VERSION(7, 51, 0)
+ curl_multi_setopt (self->multi, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
#endif
}
@@ -764,6 +778,11 @@ initiate_next_curl_request (FetcherRequest *req,
*/
#if CURL_AT_LEAST_VERSION(7, 51, 0)
curl_easy_setopt (req->easy, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
+#endif
+ /* https://github.com/curl/curl/blob/curl-7_53_0/docs/examples/http2-download.c */
+#if (CURLPIPE_MULTIPLEX > 0)
+ /* wait for pipe connection to confirm */
+ curl_easy_setopt (req->easy, CURLOPT_PIPEWAIT, 1L);
#endif
curl_easy_setopt (req->easy, CURLOPT_WRITEFUNCTION, write_cb);
if (g_getenv ("OSTREE_DEBUG_HTTP"))
diff --git a/src/libostree/ostree-fetcher-soup.c b/src/libostree/ostree-fetcher-soup.c
index b130b48c..fdcbea52 100644
--- a/src/libostree/ostree-fetcher-soup.c
+++ b/src/libostree/ostree-fetcher-soup.c
@@ -1040,21 +1040,21 @@ on_request_sent (GObject *object,
gpointer user_data)
{
GTask *task = G_TASK (user_data);
- OstreeFetcherPendingURI *pending;
- GCancellable *cancellable;
+ /* Hold a ref to the pending across this function, since we remove
+ * it from the hash early in some cases, not in others. */
+ OstreeFetcherPendingURI *pending = pending_uri_ref (g_task_get_task_data (task));
+ GCancellable *cancellable = g_task_get_cancellable (task);
GError *local_error = NULL;
glnx_unref_object SoupMessage *msg = NULL;
- pending = g_task_get_task_data (task);
- cancellable = g_task_get_cancellable (task);
-
pending->state = OSTREE_FETCHER_STATE_COMPLETE;
pending->request_body = soup_request_send_finish ((SoupRequest*) object,
result, &local_error);
if (!pending->request_body)
goto out;
-
+ g_assert_no_error (local_error);
+
if (SOUP_IS_REQUEST_HTTP (object))
{
msg = soup_request_http_get_message ((SoupRequestHTTP*) object);
@@ -1183,6 +1183,7 @@ on_request_sent (GObject *object,
remove_pending (pending);
}
+ pending_uri_unref (pending);
g_object_unref (task);
}
diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c
index 7ae7cd55..392e16fd 100644
--- a/src/libostree/ostree-repo-checkout.c
+++ b/src/libostree/ostree-repo-checkout.c
@@ -363,7 +363,7 @@ checkout_file_hardlink (OstreeRepo *self,
GError **error)
{
HardlinkResult ret_result = HARDLINK_RESULT_NOT_SUPPORTED;
- int srcfd = (self->mode == OSTREE_REPO_MODE_BARE || self->mode == OSTREE_REPO_MODE_BARE_USER) ?
+ int srcfd = _ostree_repo_mode_is_bare (self->mode) ?
self->objects_dir_fd : self->uncompressed_objects_dir_fd;
again:
@@ -423,6 +423,7 @@ checkout_one_file_at (OstreeRepo *repo,
gboolean ret = FALSE;
const char *checksum;
gboolean is_symlink;
+ gboolean is_bare_user_symlink = FALSE;
gboolean can_cache;
gboolean need_copy = TRUE;
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
@@ -431,7 +432,6 @@ checkout_one_file_at (OstreeRepo *repo,
gboolean is_whiteout;
is_symlink = g_file_info_get_file_type (source_info) == G_FILE_TYPE_SYMBOLIC_LINK;
-
checksum = ostree_repo_file_get_checksum ((OstreeRepoFile*)source);
is_whiteout = !is_symlink && options->process_whiteouts &&
@@ -468,18 +468,42 @@ checkout_one_file_at (OstreeRepo *repo,
while (current_repo)
{
- gboolean is_bare = ((current_repo->mode == OSTREE_REPO_MODE_BARE
- && options->mode == OSTREE_REPO_CHECKOUT_MODE_NONE) ||
- (current_repo->mode == OSTREE_REPO_MODE_BARE_USER
- && options->mode == OSTREE_REPO_CHECKOUT_MODE_USER
- /* NOTE: bare-user symlinks are not stored as symlinks */
- && !is_symlink));
+ /* TODO - Hoist this up to the toplevel at least for checking out from
+ * !parent; don't need to compute it for each file.
+ */
+ gboolean repo_is_usermode =
+ current_repo->mode == OSTREE_REPO_MODE_BARE_USER ||
+ current_repo->mode == OSTREE_REPO_MODE_BARE_USER_ONLY;
+ /* We're hardlinkable if the checkout mode matches the repo mode */
+ gboolean is_hardlinkable =
+ (current_repo->mode == OSTREE_REPO_MODE_BARE
+ && options->mode == OSTREE_REPO_CHECKOUT_MODE_NONE) ||
+ (repo_is_usermode && options->mode == OSTREE_REPO_CHECKOUT_MODE_USER);
+ gboolean is_bare = is_hardlinkable && !is_bare_user_symlink;
gboolean current_can_cache = (options->enable_uncompressed_cache
&& current_repo->enable_uncompressed_cache);
gboolean is_archive_z2_with_cache = (current_repo->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
&& options->mode == OSTREE_REPO_CHECKOUT_MODE_USER
&& current_can_cache);
+ /* NOTE: bare-user symlinks are not stored as symlinks; see
+ * https://github.com/ostreedev/ostree/commit/47c612e5a0688c3452a125655a245e8f4f01b2b0
+ * as well as write_object().
+ */
+ is_bare_user_symlink = (repo_is_usermode && is_symlink);
+
+ /* Verify if no_copy_fallback is set that we can hardlink, with a
+ * special exception for bare-user symlinks.
+ */
+ if (options->no_copy_fallback && !is_hardlinkable && !is_bare_user_symlink)
+ {
+ glnx_throw (error,
+ repo_is_usermode ?
+ "User repository mode requires user checkout mode to hardlink" :
+ "Bare repository mode cannot hardlink in user checkout mode");
+ goto out;
+ }
+
/* But only under these conditions */
if (is_bare || is_archive_z2_with_cache)
{
@@ -594,7 +618,13 @@ checkout_one_file_at (OstreeRepo *repo,
/* Fall back to copy if we couldn't hardlink */
if (need_copy)
{
- g_assert (!options->no_copy_fallback);
+ /* Bare user mode can't hardlink symlinks, so we need to do a copy for
+ * those. (Although in the future we could hardlink inside checkouts) This
+ * assertion is intended to ensure that for regular files at least, we
+ * succeeded at hardlinking above.
+ */
+ if (options->no_copy_fallback)
+ g_assert (is_bare_user_symlink);
if (!ostree_repo_load_file (repo, checksum, &input, NULL, &xattrs,
cancellable, error))
goto out;
@@ -862,6 +892,9 @@ ostree_repo_checkout_tree (OstreeRepo *self,
{
OstreeRepoCheckoutAtOptions options = { 0, };
+ if (ostree_repo_get_mode (self) == OSTREE_REPO_MODE_BARE_USER_ONLY)
+ mode = OSTREE_REPO_CHECKOUT_MODE_USER;
+
options.mode = mode;
options.overwrite_mode = overwrite_mode;
/* Backwards compatibility */
@@ -948,6 +981,7 @@ ostree_repo_checkout_at (OstreeRepo *self,
GError **error)
{
OstreeRepoCheckoutAtOptions default_options = { 0, };
+ OstreeRepoCheckoutAtOptions real_options;
if (!options)
{
@@ -955,6 +989,13 @@ ostree_repo_checkout_at (OstreeRepo *self,
options = &default_options;
}
+ /* Make a copy so we can modify the options */
+ real_options = *options;
+ options = &real_options;
+
+ if (ostree_repo_get_mode (self) == OSTREE_REPO_MODE_BARE_USER_ONLY)
+ options->mode = OSTREE_REPO_CHECKOUT_MODE_USER;
+
g_autoptr(GFile) commit_root = (GFile*) _ostree_repo_file_new_for_commit (self, commit, error);
if (!commit_root)
return FALSE;
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c
index f6129ca6..45577373 100644
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -144,7 +144,6 @@ _ostree_repo_commit_loose_final (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
int dest_dfd;
char tmpbuf[_OSTREE_LOOSE_PATH_MAX];
@@ -157,13 +156,13 @@ _ostree_repo_commit_loose_final (OstreeRepo *self,
if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, tmpbuf,
cancellable, error))
- goto out;
+ return FALSE;
if (fd != -1)
{
if (!glnx_link_tmpfile_at (temp_dfd, GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST,
fd, temp_filename, dest_dfd, tmpbuf, error))
- goto out;
+ return FALSE;
}
else
{
@@ -171,19 +170,13 @@ _ostree_repo_commit_loose_final (OstreeRepo *self,
dest_dfd, tmpbuf) == -1))
{
if (errno != EEXIST)
- {
- glnx_set_error_from_errno (error);
- g_prefix_error (error, "Storing file '%s': ", temp_filename);
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "Storing file '%s'", temp_filename);
else
(void) unlinkat (temp_dfd, temp_filename, 0);
}
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -227,7 +220,11 @@ commit_loose_object_trusted (OstreeRepo *self,
}
/* Special handling for symlinks in bare repositories */
- if (object_is_symlink && self->mode == OSTREE_REPO_MODE_BARE)
+ if (object_is_symlink && self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY)
+ {
+ /* We don't store the metadata in bare-user-only, so we're done. */
+ }
+ else if (object_is_symlink && self->mode == OSTREE_REPO_MODE_BARE)
{
/* Now that we know the checksum is valid, apply uid/gid, mode bits,
* and extended attributes.
@@ -283,7 +280,8 @@ commit_loose_object_trusted (OstreeRepo *self,
}
}
- if (objtype == OSTREE_OBJECT_TYPE_FILE && self->mode == OSTREE_REPO_MODE_BARE_USER)
+ if (objtype == OSTREE_OBJECT_TYPE_FILE &&
+ (self->mode == OSTREE_REPO_MODE_BARE_USER || self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY))
{
if (!object_is_symlink)
{
@@ -292,22 +290,16 @@ commit_loose_object_trusted (OstreeRepo *self,
checkout. To make this work we apply all user bits and the read bits for
group/other. Furthermore, setting user xattrs requires write access, so
this makes sure it's at least writable by us. (O_TMPFILE uses mode 0 by default) */
- do
- res = fchmod (fd, mode | 0744);
- while (G_UNLIKELY (res == -1 && errno == EINTR));
- if (G_UNLIKELY (res == -1))
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ if (fchmod (fd, mode | 0744) < 0)
+ return glnx_throw_errno (error);
}
- if (!write_file_metadata_to_xattr (fd, uid, gid, mode, xattrs, error))
- goto out;
+ if (self->mode == OSTREE_REPO_MODE_BARE_USER &&
+ !write_file_metadata_to_xattr (fd, uid, gid, mode, xattrs, error))
+ return FALSE;
}
- if (objtype == OSTREE_OBJECT_TYPE_FILE && (self->mode == OSTREE_REPO_MODE_BARE ||
- self->mode == OSTREE_REPO_MODE_BARE_USER))
+ if (objtype == OSTREE_OBJECT_TYPE_FILE && _ostree_repo_mode_is_bare (self->mode))
{
/* To satisfy tools such as guile which compare mtimes
* to determine whether or not source files need to be compiled,
@@ -344,6 +336,8 @@ commit_loose_object_trusted (OstreeRepo *self,
ret = TRUE;
out:
+ if (G_UNLIKELY (error && *error))
+ g_prefix_error (error, "Writing object %s.%s: ", checksum, ostree_object_type_to_string (objtype));
return ret;
}
@@ -619,12 +613,11 @@ write_object (OstreeRepo *self,
OstreeRepoMode repo_mode;
g_autofree char *temp_filename = NULL;
g_autofree guchar *ret_csum = NULL;
- glnx_unref_object OstreeChecksumInputStream *checksum_input = NULL;
+ glnx_unref_object OtChecksumInstream *checksum_input = NULL;
g_autoptr(GInputStream) file_input = NULL;
g_autoptr(GFileInfo) file_info = NULL;
g_autoptr(GVariant) xattrs = NULL;
gboolean have_obj;
- GChecksum *checksum = NULL;
gboolean temp_file_is_regular;
gboolean temp_file_is_symlink;
glnx_fd_close int temp_fd = -1;
@@ -654,11 +647,7 @@ write_object (OstreeRepo *self,
repo_mode = ostree_repo_get_mode (self);
if (out_csum)
- {
- checksum = g_checksum_new (G_CHECKSUM_SHA256);
- if (input)
- checksum_input = ostree_checksum_input_stream_new (input, checksum);
- }
+ checksum_input = ot_checksum_instream_new (input, G_CHECKSUM_SHA256);
if (objtype == OSTREE_OBJECT_TYPE_FILE)
{
@@ -703,7 +692,7 @@ write_object (OstreeRepo *self,
* binary with trailing garbage, creating a window on the local
* system where a malicious setuid binary exists.
*/
- if ((repo_mode == OSTREE_REPO_MODE_BARE || repo_mode == OSTREE_REPO_MODE_BARE_USER) && temp_file_is_regular)
+ if ((_ostree_repo_mode_is_bare (repo_mode)) && temp_file_is_regular)
{
guint64 size = g_file_info_get_size (file_info);
@@ -712,8 +701,10 @@ write_object (OstreeRepo *self,
cancellable, error))
goto out;
}
- else if (repo_mode == OSTREE_REPO_MODE_BARE && temp_file_is_symlink)
+ else if (_ostree_repo_mode_is_bare (repo_mode) && temp_file_is_symlink)
{
+ /* Note: This will not be hit for bare-user mode because its converted to a
+ regular file and take the branch above */
if (!_ostree_make_temporary_symlink_at (self->tmp_dir_fd,
g_file_info_get_symlink_target (file_info),
&temp_filename,
@@ -778,11 +769,11 @@ write_object (OstreeRepo *self,
temp_file_is_regular = TRUE;
}
- if (!checksum)
+ if (!checksum_input)
actual_checksum = expected_checksum;
else
{
- actual_checksum = g_checksum_get_string (checksum);
+ actual_checksum = ot_checksum_instream_get_string (checksum_input);
if (expected_checksum && strcmp (actual_checksum, expected_checksum) != 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -892,16 +883,18 @@ write_object (OstreeRepo *self,
else
self->txn_stats.content_objects_total++;
g_mutex_unlock (&self->txn_stats_lock);
-
- if (checksum)
- ret_csum = ot_csum_from_gchecksum (checksum);
+
+ if (checksum_input)
+ {
+ g_assert (actual_checksum);
+ ret_csum = ostree_checksum_to_bytes (actual_checksum);
+ }
ret = TRUE;
ot_transfer_out_value(out_csum, &ret_csum);
out:
if (temp_filename)
(void) unlinkat (self->tmp_dir_fd, temp_filename, 0);
- g_clear_pointer (&checksum, (GDestroyNotify) g_checksum_free);
return ret;
}
@@ -961,6 +954,7 @@ scan_one_loose_devino (OstreeRepo *self,
case OSTREE_REPO_MODE_ARCHIVE_Z2:
case OSTREE_REPO_MODE_BARE:
case OSTREE_REPO_MODE_BARE_USER:
+ case OSTREE_REPO_MODE_BARE_USER_ONLY:
skip = !g_str_has_suffix (name, ".file");
break;
default:
@@ -1116,8 +1110,6 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- gboolean ret_transaction_resume = FALSE;
g_return_val_if_fail (self->in_transaction == FALSE, FALSE);
@@ -1125,6 +1117,7 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
self->in_transaction = TRUE;
+ gboolean ret_transaction_resume = FALSE;
if (!_ostree_repo_allocate_tmpdir (self->tmp_dir_fd,
self->stagedir_prefix,
&self->commit_stagedir_name,
@@ -1132,13 +1125,11 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
&self->commit_stagedir_lock,
&ret_transaction_resume,
cancellable, error))
- goto out;
+ return FALSE;
- ret = TRUE;
if (out_transaction_resume)
*out_transaction_resume = ret_transaction_resume;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -1146,11 +1137,10 @@ rename_pending_loose_objects (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
if (!glnx_dirfd_iterator_init_at (self->commit_stagedir_fd, ".", FALSE, &dfd_iter, error))
- goto out;
+ return FALSE;
/* Iterate over the outer checksum dir */
while (TRUE)
@@ -1159,7 +1149,7 @@ rename_pending_loose_objects (OstreeRepo *self,
g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, };
if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dfd_iter, &dent, cancellable, error))
- goto out;
+ return FALSE;
if (dent == NULL)
break;
@@ -1172,7 +1162,7 @@ rename_pending_loose_objects (OstreeRepo *self,
if (!glnx_dirfd_iterator_init_at (dfd_iter.fd, dent->d_name, FALSE,
&child_dfd_iter, error))
- goto out;
+ return FALSE;
/* Iterate over inner checksum dir */
while (TRUE)
@@ -1181,7 +1171,7 @@ rename_pending_loose_objects (OstreeRepo *self,
char loose_objpath[_OSTREE_LOOSE_PATH_MAX];
if (!glnx_dirfd_iterator_next_dent (&child_dfd_iter, &child_dent, cancellable, error))
- goto out;
+ return FALSE;
if (child_dent == NULL)
break;
@@ -1193,24 +1183,19 @@ rename_pending_loose_objects (OstreeRepo *self,
if (!_ostree_repo_ensure_loose_objdir_at (self->objects_dir_fd, loose_objpath,
cancellable, error))
- goto out;
+ return FALSE;
if (G_UNLIKELY (renameat (child_dfd_iter.fd, loose_objpath + 3,
self->objects_dir_fd, loose_objpath) < 0))
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
}
}
if (!glnx_shutil_rm_rf_at (self->tmp_dir_fd, self->commit_stagedir_name,
cancellable, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -1218,14 +1203,13 @@ cleanup_tmpdir (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
guint64 curtime_secs;
curtime_secs = g_get_real_time () / 1000000;
if (!glnx_dirfd_iterator_init_at (self->tmp_dir_fd, ".", TRUE, &dfd_iter, error))
- goto out;
+ return FALSE;
while (TRUE)
{
@@ -1236,7 +1220,7 @@ cleanup_tmpdir (OstreeRepo *self,
gboolean did_lock;
if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error))
- goto out;
+ return FALSE;
if (dent == NULL)
break;
@@ -1251,8 +1235,7 @@ cleanup_tmpdir (OstreeRepo *self,
{
if (errno == ENOENT) /* Did another cleanup win? */
continue;
- glnx_set_error_from_errno (error);
- goto out;
+ return glnx_throw_errno (error);
}
/* First, if it's a directory which needs locking, but it's
@@ -1262,7 +1245,7 @@ cleanup_tmpdir (OstreeRepo *self,
{
if (!_ostree_repo_try_lock_tmpdir (dfd_iter.fd, dent->d_name,
&lockfile, &did_lock, error))
- goto out;
+ return FALSE;
if (!did_lock)
continue;
}
@@ -1279,7 +1262,7 @@ cleanup_tmpdir (OstreeRepo *self,
* from *other* boots
*/
if (!glnx_shutil_rm_rf_at (dfd_iter.fd, dent->d_name, cancellable, error))
- goto out;
+ return FALSE;
}
/* FIXME - move OSTREE_REPO_TMPDIR_FETCHER underneath the
* staging/boot-id scheme as well, since all of the "did it get
@@ -1304,14 +1287,12 @@ cleanup_tmpdir (OstreeRepo *self,
if (delta > self->tmp_expiry_seconds)
{
if (!glnx_shutil_rm_rf_at (dfd_iter.fd, dent->d_name, cancellable, error))
- goto out;
+ return FALSE;
}
}
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static void
@@ -1425,16 +1406,10 @@ ostree_repo_commit_transaction (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
-
g_return_val_if_fail (self->in_transaction == TRUE, FALSE);
if ((self->test_error_flags & OSTREE_REPO_TEST_ERROR_PRE_COMMIT) > 0)
- {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "OSTREE_REPO_TEST_ERROR_PRE_COMMIT specified");
- goto out;
- }
+ return glnx_throw (error, "OSTREE_REPO_TEST_ERROR_PRE_COMMIT specified");
/* FIXME: Added since valgrind in el7 doesn't know about
* `syncfs`...we should delete this later.
@@ -1442,24 +1417,21 @@ ostree_repo_commit_transaction (OstreeRepo *self,
if (g_getenv ("OSTREE_SUPPRESS_SYNCFS") == NULL)
{
if (syncfs (self->tmp_dir_fd) < 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
}
if (!rename_pending_loose_objects (self, cancellable, error))
- goto out;
+ return FALSE;
if (!cleanup_tmpdir (self, cancellable, error))
- goto out;
+ return FALSE;
if (self->loose_object_devino_hash)
g_hash_table_remove_all (self->loose_object_devino_hash);
if (self->txn_refs)
if (!_ostree_repo_update_refs (self, self->txn_refs, cancellable, error))
- goto out;
+ return FALSE;
g_clear_pointer (&self->txn_refs, g_hash_table_destroy);
if (self->commit_stagedir_fd != -1)
@@ -1475,14 +1447,12 @@ ostree_repo_commit_transaction (OstreeRepo *self,
self->in_transaction = FALSE;
if (!ot_ensure_unlinked_at (self->repo_dir_fd, "transaction", 0))
- goto out;
+ return FALSE;
if (out_stats)
*out_stats = self->txn_stats;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
gboolean
@@ -1490,13 +1460,12 @@ ostree_repo_abort_transaction (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
-
+ /* Note early return */
if (!self->in_transaction)
return TRUE;
if (!cleanup_tmpdir (self, cancellable, error))
- goto out;
+ return FALSE;
if (self->loose_object_devino_hash)
g_hash_table_remove_all (self->loose_object_devino_hash);
@@ -1514,9 +1483,7 @@ ostree_repo_abort_transaction (OstreeRepo *self,
self->in_transaction = FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -1544,8 +1511,6 @@ ostree_repo_write_metadata (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GInputStream) input = NULL;
g_autoptr(GVariant) normalized = NULL;
normalized = g_variant_get_normal_form (object);
@@ -1554,25 +1519,19 @@ ostree_repo_write_metadata (OstreeRepo *self,
{
g_autofree char *input_bytes = g_format_size (g_variant_get_size (normalized));
g_autofree char *max_bytes = g_format_size (OSTREE_MAX_METADATA_SIZE);
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Metadata object of type '%s' is %s; maximum metadata size is %s",
- ostree_object_type_to_string (objtype),
- input_bytes,
- max_bytes);
- goto out;
+ return glnx_throw (error, "Metadata object of type '%s' is %s; maximum metadata size is %s",
+ ostree_object_type_to_string (objtype), input_bytes, max_bytes);
}
- input = ot_variant_read (normalized);
+ g_autoptr(GInputStream) input = ot_variant_read (normalized);
if (!write_object (self, objtype, expected_checksum,
input, g_variant_get_size (normalized),
out_csum,
cancellable, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -1999,38 +1958,33 @@ ostree_repo_write_commit_with_time (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autofree char *ret_commit = NULL;
- g_autoptr(GVariant) commit = NULL;
- g_autoptr(GVariant) new_metadata = NULL;
- g_autofree guchar *commit_csum = NULL;
OstreeRepoFile *repo_root = OSTREE_REPO_FILE (root);
/* Add sizes information to our metadata object */
+ g_autoptr(GVariant) new_metadata = NULL;
if (!add_size_index_to_metadata (self, metadata, &new_metadata,
cancellable, error))
- goto out;
+ return FALSE;
- commit = g_variant_new ("(@a{sv}@ay@a(say)sst@ay@ay)",
- new_metadata ? new_metadata : create_empty_gvariant_dict (),
- parent ? ostree_checksum_to_bytes_v (parent) : ot_gvariant_new_bytearray (NULL, 0),
- g_variant_new_array (G_VARIANT_TYPE ("(say)"), NULL, 0),
- subject ? subject : "", body ? body : "",
- GUINT64_TO_BE (time),
- ostree_checksum_to_bytes_v (ostree_repo_file_tree_get_contents_checksum (repo_root)),
- ostree_checksum_to_bytes_v (ostree_repo_file_tree_get_metadata_checksum (repo_root)));
+ g_autoptr(GVariant) commit =
+ g_variant_new ("(@a{sv}@ay@a(say)sst@ay@ay)",
+ new_metadata ? new_metadata : create_empty_gvariant_dict (),
+ parent ? ostree_checksum_to_bytes_v (parent) : ot_gvariant_new_bytearray (NULL, 0),
+ g_variant_new_array (G_VARIANT_TYPE ("(say)"), NULL, 0),
+ subject ? subject : "", body ? body : "",
+ GUINT64_TO_BE (time),
+ ostree_checksum_to_bytes_v (ostree_repo_file_tree_get_contents_checksum (repo_root)),
+ ostree_checksum_to_bytes_v (ostree_repo_file_tree_get_metadata_checksum (repo_root)));
g_variant_ref_sink (commit);
+ g_autofree guchar *commit_csum = NULL;
if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_COMMIT, NULL,
commit, &commit_csum,
cancellable, error))
- goto out;
+ return FALSE;
- ret_commit = ostree_checksum_from_bytes (commit_csum);
-
- ret = TRUE;
+ g_autofree char *ret_commit = ostree_checksum_from_bytes (commit_csum);
ot_transfer_out_value(out_commit, &ret_commit);
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2052,29 +2006,21 @@ ostree_repo_read_commit_detached_metadata (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
char buf[_OSTREE_LOOSE_PATH_MAX];
- g_autoptr(GVariant) ret_metadata = NULL;
-
_ostree_loose_path (buf, checksum, OSTREE_OBJECT_TYPE_COMMIT_META, self->mode);
+ g_autoptr(GVariant) ret_metadata = NULL;
if (self->commit_stagedir_fd != -1 &&
!ot_util_variant_map_at (self->commit_stagedir_fd, buf,
G_VARIANT_TYPE ("a{sv}"),
OT_VARIANT_MAP_ALLOW_NOENT | OT_VARIANT_MAP_TRUSTED, &ret_metadata, error))
- {
- g_prefix_error (error, "Unable to read existing detached metadata: ");
- goto out;
- }
+ return g_prefix_error (error, "Unable to read existing detached metadata: "), FALSE;
if (ret_metadata == NULL &&
!ot_util_variant_map_at (self->objects_dir_fd, buf,
G_VARIANT_TYPE ("a{sv}"),
OT_VARIANT_MAP_ALLOW_NOENT | OT_VARIANT_MAP_TRUSTED, &ret_metadata, error))
- {
- g_prefix_error (error, "Unable to read existing detached metadata: ");
- goto out;
- }
+ return g_prefix_error (error, "Unable to read existing detached metadata: "), FALSE;
if (ret_metadata == NULL && self->parent_repo)
return ostree_repo_read_commit_detached_metadata (self->parent_repo,
@@ -2082,10 +2028,8 @@ ostree_repo_read_commit_detached_metadata (OstreeRepo *self,
out_metadata,
cancellable,
error);
- ret = TRUE;
ot_transfer_out_value (out_metadata, &ret_metadata);
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2229,17 +2173,33 @@ _ostree_repo_commit_modifier_apply (OstreeRepo *self,
GFileInfo *file_info,
GFileInfo **out_modified_info)
{
- OstreeRepoCommitFilterResult result;
+ OstreeRepoCommitFilterResult result = OSTREE_REPO_COMMIT_FILTER_ALLOW;
GFileInfo *modified_info;
- if (modifier == NULL || modifier->filter == NULL)
+ if (modifier == NULL ||
+ (modifier->filter == NULL &&
+ (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) == 0))
{
*out_modified_info = g_object_ref (file_info);
return OSTREE_REPO_COMMIT_FILTER_ALLOW;
}
modified_info = g_file_info_dup (file_info);
- result = modifier->filter (self, path, modified_info, modifier->user_data);
+ if (modifier->filter)
+ result = modifier->filter (self, path, modified_info, modifier->user_data);
+
+ if ((modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) != 0)
+ {
+
+ if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
+ {
+ guint current_mode = g_file_info_get_attribute_uint32 (modified_info, "unix::mode");
+ g_file_info_set_attribute_uint32 (modified_info, "unix::mode", current_mode | 0744);
+ }
+ g_file_info_set_attribute_uint32 (modified_info, "unix::uid", 0);
+ g_file_info_set_attribute_uint32 (modified_info, "unix::gid", 0);
+ }
+
*out_modified_info = modified_info;
return result;
@@ -2276,7 +2236,9 @@ apply_commit_filter (OstreeRepo *self,
GFileInfo *file_info,
GFileInfo **out_modified_info)
{
- if (modifier == NULL || modifier->filter == NULL)
+ if (modifier == NULL ||
+ (modifier->filter == NULL &&
+ (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) == 0))
{
*out_modified_info = g_object_ref (file_info);
return OSTREE_REPO_COMMIT_FILTER_ALLOW;
@@ -2297,7 +2259,6 @@ get_modified_xattrs (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_autoptr(GVariant) ret_xattrs = NULL;
if (modifier && modifier->xattr_callback)
@@ -2305,7 +2266,9 @@ get_modified_xattrs (OstreeRepo *self,
ret_xattrs = modifier->xattr_callback (self, relpath, file_info,
modifier->xattr_user_data);
}
- else if (!(modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS) > 0))
+ else if (!(modifier && (modifier->flags & (OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS |
+ OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS)) > 0)
+ && !self->disable_xattrs)
{
if (path && OSTREE_IS_REPO_FILE (path))
{
@@ -2313,27 +2276,27 @@ get_modified_xattrs (OstreeRepo *self,
&ret_xattrs,
cancellable,
error))
- goto out;
+ return FALSE;
}
else if (path)
{
if (!glnx_dfd_name_get_all_xattrs (AT_FDCWD, gs_file_get_path_cached (path),
&ret_xattrs, cancellable, error))
- goto out;
+ return FALSE;
}
else if (dfd_subpath == NULL)
{
g_assert (dfd != -1);
if (!glnx_fd_get_all_xattrs (dfd, &ret_xattrs,
cancellable, error))
- goto out;
+ return FALSE;
}
else
{
g_assert (dfd != -1);
if (!glnx_dfd_name_get_all_xattrs (dfd, dfd_subpath, &ret_xattrs,
cancellable, error))
- goto out;
+ return FALSE;
}
}
@@ -2344,9 +2307,13 @@ get_modified_xattrs (OstreeRepo *self,
if (!ostree_sepolicy_get_label (modifier->sepolicy, relpath,
g_file_info_get_attribute_uint32 (file_info, "unix::mode"),
&label, cancellable, error))
- goto out;
+ return FALSE;
- if (label)
+ if (!label && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED) > 0)
+ {
+ return glnx_throw (error, "Failed to look up SELinux label for '%s'", relpath);
+ }
+ else if (label)
{
g_autoptr(GVariantBuilder) builder = NULL;
@@ -2365,12 +2332,10 @@ get_modified_xattrs (OstreeRepo *self,
g_variant_ref_sink (ret_xattrs);
}
}
-
- ret = TRUE;
+
if (out_xattrs)
*out_xattrs = g_steal_pointer (&ret_xattrs);
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -2402,7 +2367,6 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_autoptr(GFile) child = NULL;
g_autoptr(GFileInfo) modified_info = NULL;
glnx_unref_object OstreeMutableTree *child_mtree = NULL;
@@ -2424,8 +2388,8 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
if (filter_result != OSTREE_REPO_COMMIT_FILTER_ALLOW)
{
g_ptr_array_remove_index (path, path->len - 1);
- ret = TRUE;
- goto out;
+ /* Note: early return */
+ return TRUE;
}
file_type = g_file_info_get_file_type (child_info);
@@ -2436,10 +2400,8 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
case G_FILE_TYPE_REGULAR:
break;
default:
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unsupported file type: '%s'",
- gs_file_get_path_cached (child));
- goto out;
+ return glnx_throw (error, "Unsupported file type: '%s'",
+ gs_file_get_path_cached (child));
}
if (dir_enum != NULL)
@@ -2448,26 +2410,26 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
if (file_type == G_FILE_TYPE_DIRECTORY)
{
if (!ostree_mutable_tree_ensure_dir (mtree, name, &child_mtree, error))
- goto out;
+ return FALSE;
if (dir_enum != NULL)
{
if (!write_directory_to_mtree_internal (self, child, child_mtree,
modifier, path,
cancellable, error))
- goto out;
+ return FALSE;
}
else
{
g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, };
if (!glnx_dirfd_iterator_init_at (dfd_iter->fd, name, FALSE, &child_dfd_iter, error))
- goto out;
+ return FALSE;
if (!write_dfd_iter_to_mtree_internal (self, &child_dfd_iter, child_mtree,
modifier, path,
cancellable, error))
- goto out;
+ return FALSE;
}
}
else if (repo_dir)
@@ -2477,7 +2439,7 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
if (!ostree_mutable_tree_replace_file (mtree, name,
ostree_repo_file_get_checksum ((OstreeRepoFile*) child),
error))
- goto out;
+ return FALSE;
}
else
{
@@ -2497,7 +2459,7 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
{
if (!ostree_mutable_tree_replace_file (mtree, name, loose_checksum,
error))
- goto out;
+ return FALSE;
}
else
{
@@ -2507,13 +2469,13 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
{
file_input = (GInputStream*)g_file_read (child, cancellable, error);
if (!file_input)
- goto out;
+ return FALSE;
}
else
{
if (!ot_openat_read_stream (dfd_iter->fd, name, FALSE,
&file_input, cancellable, error))
- goto out;
+ return FALSE;
}
}
@@ -2521,30 +2483,28 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
child_relpath, child_info, child, dfd_iter != NULL ? dfd_iter->fd : -1, name,
&xattrs,
cancellable, error))
- goto out;
+ return FALSE;
if (!ostree_raw_file_to_content_stream (file_input,
modified_info, xattrs,
&file_object_input, &file_obj_length,
cancellable, error))
- goto out;
+ return FALSE;
if (!ostree_repo_write_content (self, NULL, file_object_input, file_obj_length,
&child_file_csum, cancellable, error))
- goto out;
+ return FALSE;
g_free (tmp_checksum);
tmp_checksum = ostree_checksum_from_bytes (child_file_csum);
if (!ostree_mutable_tree_replace_file (mtree, name, tmp_checksum,
error))
- goto out;
+ return FALSE;
}
}
g_ptr_array_remove_index (path, path->len - 1);
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -2556,10 +2516,8 @@ write_directory_to_mtree_internal (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
OstreeRepoCommitFilterResult filter_result;
OstreeRepoFile *repo_dir = NULL;
- g_autoptr(GFileInfo) child_info = NULL;
if (dir)
g_debug ("Examining: %s", gs_file_get_path_cached (dir));
@@ -2572,7 +2530,7 @@ write_directory_to_mtree_internal (OstreeRepo *self,
if (repo_dir)
{
if (!ostree_repo_file_ensure_resolved (repo_dir, error))
- goto out;
+ return FALSE;
ostree_mutable_tree_set_metadata_checksum (mtree, ostree_repo_file_tree_get_metadata_checksum (repo_dir));
@@ -2580,21 +2538,20 @@ write_directory_to_mtree_internal (OstreeRepo *self,
}
else
{
- g_autoptr(GFileInfo) modified_info = NULL;
g_autoptr(GVariant) xattrs = NULL;
- g_autofree guchar *child_file_csum = NULL;
- g_autofree char *tmp_checksum = NULL;
- g_autofree char *relpath = NULL;
- child_info = g_file_query_info (dir, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, error);
+ g_autoptr(GFileInfo) child_info =
+ g_file_query_info (dir, OSTREE_GIO_FAST_QUERYINFO,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ cancellable, error);
if (!child_info)
- goto out;
+ return FALSE;
+ g_autofree char *relpath = NULL;
if (modifier != NULL)
relpath = ptrarray_path_join (path);
+ g_autoptr(GFileInfo) modified_info = NULL;
filter_result = apply_commit_filter (self, modifier, relpath, child_info, &modified_info);
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
@@ -2603,18 +2560,16 @@ write_directory_to_mtree_internal (OstreeRepo *self,
dir, -1, NULL,
&xattrs,
cancellable, error))
- goto out;
+ return FALSE;
+ g_autofree guchar *child_file_csum = NULL;
if (!_ostree_repo_write_directory_meta (self, modified_info, xattrs, &child_file_csum,
cancellable, error))
- goto out;
+ return FALSE;
- g_free (tmp_checksum);
- tmp_checksum = ostree_checksum_from_bytes (child_file_csum);
+ g_autofree char *tmp_checksum = ostree_checksum_from_bytes (child_file_csum);
ostree_mutable_tree_set_metadata_checksum (mtree, tmp_checksum);
}
-
- g_clear_object (&child_info);
}
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
@@ -2626,15 +2581,15 @@ write_directory_to_mtree_internal (OstreeRepo *self,
cancellable,
error);
if (!dir_enum)
- goto out;
+ return FALSE;
while (TRUE)
{
GFileInfo *child_info;
-
+
if (!g_file_enumerator_iterate (dir_enum, &child_info, NULL,
cancellable, error))
- goto out;
+ return FALSE;
if (child_info == NULL)
break;
@@ -2642,13 +2597,11 @@ write_directory_to_mtree_internal (OstreeRepo *self,
child_info,
mtree, modifier, path,
cancellable, error))
- goto out;
+ return FALSE;
}
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -2660,7 +2613,6 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_autoptr(GFileInfo) child_info = NULL;
g_autoptr(GFileInfo) modified_info = NULL;
g_autoptr(GVariant) xattrs = NULL;
@@ -2671,17 +2623,14 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
struct stat dir_stbuf;
if (fstat (src_dfd_iter->fd, &dir_stbuf) != 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
child_info = _ostree_header_gfile_info_new (dir_stbuf.st_mode, dir_stbuf.st_uid, dir_stbuf.st_gid);
if (modifier != NULL)
{
relpath = ptrarray_path_join (path);
-
+
filter_result = apply_commit_filter (self, modifier, relpath, child_info, &modified_info);
}
else
@@ -2696,11 +2645,11 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
NULL, src_dfd_iter->fd, NULL,
&xattrs,
cancellable, error))
- goto out;
+ return FALSE;
if (!_ostree_repo_write_directory_meta (self, modified_info, xattrs, &child_file_csum,
cancellable, error))
- goto out;
+ return FALSE;
g_free (tmp_checksum);
tmp_checksum = ostree_checksum_from_bytes (child_file_csum);
@@ -2709,8 +2658,8 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
if (filter_result != OSTREE_REPO_COMMIT_FILTER_ALLOW)
{
- ret = TRUE;
- goto out;
+ /* Note - early return */
+ return TRUE;
}
while (TRUE)
@@ -2719,24 +2668,20 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
struct stat stbuf;
g_autoptr(GFileInfo) child_info = NULL;
const char *loose_checksum;
-
if (!glnx_dirfd_iterator_next_dent (src_dfd_iter, &dent, cancellable, error))
- goto out;
+ return FALSE;
if (dent == NULL)
break;
if (fstatat (src_dfd_iter->fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) == -1)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
loose_checksum = devino_cache_lookup (self, modifier, stbuf.st_dev, stbuf.st_ino);
if (loose_checksum)
{
if (!ostree_mutable_tree_replace_file (mtree, dent->d_name, loose_checksum,
error))
- goto out;
+ return FALSE;
continue;
}
@@ -2752,28 +2697,24 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
{
if (!ot_readlinkat_gfile_info (src_dfd_iter->fd, dent->d_name,
child_info, cancellable, error))
- goto out;
+ return FALSE;
}
else if (S_ISDIR (stbuf.st_mode))
;
else
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Not a regular file or symlink: %s",
- dent->d_name);
- goto out;
+ return glnx_throw (error, "Not a regular file or symlink: %s",
+ dent->d_name);
}
if (!write_directory_content_to_mtree_internal (self, NULL, NULL, src_dfd_iter,
child_info,
mtree, modifier, path,
cancellable, error))
- goto out;
+ return FALSE;
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2796,30 +2737,26 @@ ostree_repo_write_directory_to_mtree (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GPtrArray) path = NULL;
/* Short cut local files */
if (g_file_is_native (dir))
{
if (!ostree_repo_write_dfd_to_mtree (self, AT_FDCWD, gs_file_get_path_cached (dir),
mtree, modifier, cancellable, error))
- goto out;
+ return FALSE;
}
else
{
if (modifier && modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES)
self->generate_sizes = TRUE;
-
- path = g_ptr_array_new ();
+
+ g_autoptr(GPtrArray) path = g_ptr_array_new ();
if (!write_directory_to_mtree_internal (self, dir, mtree, modifier, path,
cancellable, error))
- goto out;
+ return FALSE;
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2845,25 +2782,19 @@ ostree_repo_write_dfd_to_mtree (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GPtrArray) pathbuilder = NULL;
- g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
-
if (modifier && modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES)
self->generate_sizes = TRUE;
- pathbuilder = g_ptr_array_new ();
-
+ g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
if (!glnx_dirfd_iterator_init_at (dfd, path, FALSE, &dfd_iter, error))
- goto out;
+ return FALSE;
+ g_autoptr(GPtrArray) pathbuilder = g_ptr_array_new ();
if (!write_dfd_iter_to_mtree_internal (self, &dfd_iter, mtree, modifier, pathbuilder,
cancellable, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2885,19 +2816,12 @@ ostree_repo_write_mtree (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- GHashTableIter hash_iter;
- gpointer key, value;
const char *contents_checksum, *metadata_checksum;
g_autoptr(GFile) ret_file = NULL;
metadata_checksum = ostree_mutable_tree_get_metadata_checksum (mtree);
if (!metadata_checksum)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Can't commit an empty tree");
- goto out;
- }
+ return glnx_throw (error, "Can't commit an empty tree");
contents_checksum = ostree_mutable_tree_get_contents_checksum (mtree);
if (contents_checksum)
@@ -2917,6 +2841,8 @@ ostree_repo_write_mtree (OstreeRepo *self,
dir_metadata_checksums = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free, (GDestroyNotify)g_free);
+ GHashTableIter hash_iter;
+ gpointer key, value;
g_hash_table_iter_init (&hash_iter, ostree_mutable_tree_get_subdirs (mtree));
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
@@ -2926,7 +2852,7 @@ ostree_repo_write_mtree (OstreeRepo *self,
if (!ostree_repo_write_mtree (self, child_dir, &child_file,
cancellable, error))
- goto out;
+ return FALSE;
g_hash_table_replace (dir_contents_checksums, g_strdup (name),
g_strdup (ostree_repo_file_tree_get_contents_checksum (OSTREE_REPO_FILE (child_file))));
@@ -2941,7 +2867,7 @@ ostree_repo_write_mtree (OstreeRepo *self,
if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_DIR_TREE, NULL,
serialized_tree, &contents_csum,
cancellable, error))
- goto out;
+ return FALSE;
ostree_checksum_inplace_from_bytes (contents_csum, contents_checksum_buf);
ostree_mutable_tree_set_contents_checksum (mtree, contents_checksum_buf);
@@ -2949,11 +2875,9 @@ ostree_repo_write_mtree (OstreeRepo *self,
ret_file = G_FILE (_ostree_repo_file_new_root (self, contents_checksum_buf, metadata_checksum));
}
- ret = TRUE;
if (out_file)
*out_file = g_steal_pointer (&ret_file);
- out:
- return ret;
+ return TRUE;
}
/**
diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h
index f1e00f27..b1a58d61 100644
--- a/src/libostree/ostree-repo-private.h
+++ b/src/libostree/ostree-repo-private.h
@@ -100,6 +100,7 @@ struct OstreeRepo {
GError *writable_error;
gboolean in_transaction;
gboolean disable_fsync;
+ gboolean disable_xattrs;
guint zlib_compression_level;
GHashTable *loose_object_devino_hash;
GHashTable *updated_uncompressed_dirs;
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 5ee43918..a7a3a5b0 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -279,18 +279,21 @@ pull_termination_condition (OtPullData *pull_data)
static void
check_outstanding_requests_handle_error (OtPullData *pull_data,
- GError *error)
+ GError **errorp)
{
+ g_assert (errorp);
+
+ GError *error = *errorp;
if (error)
{
if (!pull_data->caught_error)
{
pull_data->caught_error = TRUE;
- g_propagate_error (pull_data->async_error, error);
+ g_propagate_error (pull_data->async_error, g_steal_pointer (errorp));
}
else
{
- g_error_free (error);
+ g_clear_error (errorp);
}
}
else
@@ -382,7 +385,7 @@ idle_worker (gpointer user_data)
{
OtPullData *pull_data = user_data;
ScanObjectQueueData *scan_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
scan_data = g_queue_pop_head (&pull_data->scan_object_queue);
if (!scan_data)
@@ -398,7 +401,7 @@ idle_worker (gpointer user_data)
scan_data->recursion_depth,
pull_data->cancellable,
&error);
- check_outstanding_requests_handle_error (pull_data, error);
+ check_outstanding_requests_handle_error (pull_data, &error);
g_free (scan_data->path);
g_free (scan_data);
@@ -760,7 +763,7 @@ content_fetch_on_write_complete (GObject *object,
{
FetchObjectData *fetch_data = user_data;
OtPullData *pull_data = fetch_data->pull_data;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
OstreeObjectType objtype;
const char *expected_checksum;
@@ -794,7 +797,7 @@ content_fetch_on_write_complete (GObject *object,
pull_data->n_fetched_deltapart_fallbacks++;
out:
pull_data->n_outstanding_content_write_requests--;
- check_outstanding_requests_handle_error (pull_data, local_error);
+ check_outstanding_requests_handle_error (pull_data, &local_error);
fetch_object_data_free (fetch_data);
}
@@ -806,7 +809,7 @@ content_fetch_on_complete (GObject *object,
OstreeFetcher *fetcher = (OstreeFetcher *)object;
FetchObjectData *fetch_data = user_data;
OtPullData *pull_data = fetch_data->pull_data;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
GCancellable *cancellable = NULL;
guint64 length;
@@ -881,7 +884,7 @@ content_fetch_on_complete (GObject *object,
out:
pull_data->n_outstanding_content_fetches--;
- check_outstanding_requests_handle_error (pull_data, local_error);
+ check_outstanding_requests_handle_error (pull_data, &local_error);
if (free_fetch_data)
fetch_object_data_free (fetch_data);
}
@@ -893,7 +896,7 @@ on_metadata_written (GObject *object,
{
FetchObjectData *fetch_data = user_data;
OtPullData *pull_data = fetch_data->pull_data;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
const char *expected_checksum;
OstreeObjectType objtype;
@@ -927,7 +930,7 @@ on_metadata_written (GObject *object,
pull_data->n_outstanding_metadata_write_requests--;
fetch_object_data_free (fetch_data);
- check_outstanding_requests_handle_error (pull_data, local_error);
+ check_outstanding_requests_handle_error (pull_data, &local_error);
}
static void
@@ -943,7 +946,7 @@ meta_fetch_on_complete (GObject *object,
const char *checksum;
g_autofree char *checksum_obj = NULL;
OstreeObjectType objtype;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
glnx_fd_close int fd = -1;
gboolean free_fetch_data = TRUE;
@@ -1038,7 +1041,7 @@ meta_fetch_on_complete (GObject *object,
g_assert (pull_data->n_outstanding_metadata_fetches > 0);
pull_data->n_outstanding_metadata_fetches--;
pull_data->n_fetched_metadata++;
- check_outstanding_requests_handle_error (pull_data, local_error);
+ check_outstanding_requests_handle_error (pull_data, &local_error);
if (free_fetch_data)
fetch_object_data_free (fetch_data);
}
@@ -1061,7 +1064,7 @@ on_static_delta_written (GObject *object,
{
FetchStaticDeltaData *fetch_data = user_data;
OtPullData *pull_data = fetch_data->pull_data;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
g_debug ("execute static delta part %s complete", fetch_data->expected_checksum);
@@ -1072,7 +1075,7 @@ on_static_delta_written (GObject *object,
out:
g_assert (pull_data->n_outstanding_deltapart_write_requests > 0);
pull_data->n_outstanding_deltapart_write_requests--;
- check_outstanding_requests_handle_error (pull_data, local_error);
+ check_outstanding_requests_handle_error (pull_data, &local_error);
/* Always free state */
fetch_static_delta_data_free (fetch_data);
}
@@ -1088,7 +1091,7 @@ static_deltapart_fetch_on_complete (GObject *object,
g_autofree char *temp_path = NULL;
g_autoptr(GInputStream) in = NULL;
g_autoptr(GVariant) part = NULL;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
glnx_fd_close int fd = -1;
gboolean free_fetch_data = TRUE;
@@ -1132,7 +1135,7 @@ static_deltapart_fetch_on_complete (GObject *object,
g_assert (pull_data->n_outstanding_deltapart_fetches > 0);
pull_data->n_outstanding_deltapart_fetches--;
pull_data->n_fetched_deltaparts++;
- check_outstanding_requests_handle_error (pull_data, local_error);
+ check_outstanding_requests_handle_error (pull_data, &local_error);
if (free_fetch_data)
fetch_static_delta_data_free (fetch_data);
}
@@ -1197,6 +1200,14 @@ gpg_verify_unwritten_commit (OtPullData *pull_data,
return TRUE;
}
+static gboolean
+commitstate_is_partial (OtPullData *pull_data,
+ OstreeRepoCommitState commitstate)
+{
+ return pull_data->legacy_transaction_resuming
+ || (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) > 0;
+}
+
static gboolean
scan_commit_object (OtPullData *pull_data,
const char *checksum,
@@ -1253,8 +1264,7 @@ scan_commit_object (OtPullData *pull_data,
goto out;
/* If we found a legacy transaction flag, assume all commits are partial */
- is_partial = pull_data->legacy_transaction_resuming
- || (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) > 0;
+ is_partial = commitstate_is_partial (pull_data, commitstate);
/* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
g_variant_get_child (commit, 1, "@ay", &parent_csum);
@@ -1882,7 +1892,7 @@ get_best_static_delta_start_for (OtPullData *pull_data,
/* Array of possible from checksums */
g_autoptr(GPtrArray) candidates = g_ptr_array_new_with_free_func (g_free);
const char *newest_candidate = NULL;
- guint64 newest_candidate_timestamp;
+ guint64 newest_candidate_timestamp = 0;
g_assert (pull_data->summary_deltas_checksums != NULL);
g_hash_table_iter_init (&hiter, pull_data->summary_deltas_checksums);
@@ -1911,7 +1921,7 @@ get_best_static_delta_start_for (OtPullData *pull_data,
for (guint i = 0; i < candidates->len; i++)
{
const char *candidate = candidates->pdata[i];
- guint64 candidate_ts;
+ guint64 candidate_ts = 0;
g_autoptr(GVariant) commit = NULL;
OstreeRepoCommitState state;
gboolean have_candidate;
@@ -1961,7 +1971,7 @@ on_superblock_fetched (GObject *src,
{
FetchDeltaSuperData *fdata = data;
OtPullData *pull_data = fdata->pull_data;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
g_autoptr(GBytes) delta_superblock_data = NULL;
const char *from_revision = fdata->from_revision;
@@ -2038,7 +2048,7 @@ on_superblock_fetched (GObject *src,
g_assert (pull_data->n_outstanding_metadata_fetches > 0);
pull_data->n_outstanding_metadata_fetches--;
pull_data->n_fetched_metadata++;
- check_outstanding_requests_handle_error (pull_data, local_error);
+ check_outstanding_requests_handle_error (pull_data, &local_error);
}
static gboolean
@@ -3242,6 +3252,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
g_autofree char *from_revision = NULL;
const char *ref = key;
const char *to_revision = value;
+ gboolean have_valid_from_commit = TRUE;
/* If we have a summary, find the latest local commit we have
* to use as a from revision for static deltas.
@@ -3257,9 +3268,27 @@ ostree_repo_pull_with_options (OstreeRepo *self,
if (!ostree_repo_resolve_rev (pull_data->repo, ref, TRUE,
&from_revision, error))
goto out;
+
+ /* Determine whether the from revision we have is partial; this
+ * can happen if e.g. one uses `ostree pull --commit-metadata-only`.
+ * This mirrors the logic in get_best_static_delta_start_for().
+ */
+ if (from_revision)
+ {
+ OstreeRepoCommitState from_commitstate;
+
+ if (!ostree_repo_load_commit (pull_data->repo, from_revision, NULL,
+ &from_commitstate, error))
+ goto out;
+
+ /* Was it partial? OK, we can't use it. */
+ if (commitstate_is_partial (pull_data, from_commitstate))
+ have_valid_from_commit = FALSE;
+ }
}
if (!disable_static_deltas &&
+ have_valid_from_commit &&
(from_revision == NULL || g_strcmp0 (from_revision, to_revision) != 0))
{
g_autofree char *delta_name =
diff --git a/src/libostree/ostree-repo-refs.c b/src/libostree/ostree-repo-refs.c
index 18308d0c..adab50fe 100644
--- a/src/libostree/ostree-repo-refs.c
+++ b/src/libostree/ostree-repo-refs.c
@@ -32,30 +32,23 @@ add_ref_to_set (const char *remote,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- char *contents;
gsize len;
- GString *refname;
-
- contents = glnx_file_get_contents_utf8_at (base_fd, path, &len, cancellable, error);
+ char *contents = glnx_file_get_contents_utf8_at (base_fd, path, &len, cancellable, error);
if (!contents)
- goto out;
+ return FALSE;
g_strchomp (contents);
- refname = g_string_new ("");
+ g_autoptr(GString) refname = g_string_new ("");
if (remote)
{
g_string_append (refname, remote);
g_string_append_c (refname, ':');
}
g_string_append (refname, path);
-
- g_hash_table_insert (refs, g_string_free (refname, FALSE), contents);
+ g_hash_table_insert (refs, g_string_free (g_steal_pointer (&refname), FALSE), contents);
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -66,27 +59,16 @@ write_checksum_file_at (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- const char *lastslash;
-
if (!ostree_validate_checksum_string (sha256, error))
- goto out;
+ return FALSE;
if (ostree_validate_checksum_string (name, NULL))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Rev name '%s' looks like a checksum", name);
- goto out;
- }
+ return glnx_throw (error, "Rev name '%s' looks like a checksum", name);
if (!*name)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid empty ref name");
- goto out;
- }
+ return glnx_throw (error, "Invalid empty ref name");
- lastslash = strrchr (name, '/');
+ const char *lastslash = strrchr (name, '/');
if (lastslash)
{
@@ -94,7 +76,7 @@ write_checksum_file_at (OstreeRepo *self,
parent[lastslash - name] = '\0';
if (!glnx_shutil_mkdir_p_at (dfd, parent, 0777, cancellable, error))
- goto out;
+ return FALSE;
}
{
@@ -118,38 +100,32 @@ write_checksum_file_at (OstreeRepo *self,
g_clear_error (&temp_error);
if (!ostree_repo_list_refs (self, name, &refs, cancellable, error))
- goto out;
+ return FALSE;
g_hash_table_iter_init (&hashiter, refs);
while ((g_hash_table_iter_next (&hashiter, &hashkey, &hashvalue)))
{
if (strcmp (name, (char *)hashkey) != 0)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Conflict: %s exists under %s when attempting write", (char*)hashkey, name);
- goto out;
- }
+ return glnx_throw (error, "Conflict: %s exists under %s when attempting write", (char*)hashkey, name);
}
if (!glnx_shutil_rm_rf_at (dfd, name, cancellable, error))
- goto out;
+ return FALSE;
if (!_ostree_repo_file_replace_contents (self, dfd, name, (guint8*)bufnl, l + 1,
cancellable, error))
- goto out;
+ return FALSE;
}
else
{
g_propagate_error (error, g_steal_pointer (&temp_error));
- goto out;
+ return FALSE;
}
}
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -158,12 +134,11 @@ find_ref_in_remotes (OstreeRepo *self,
int *out_fd,
GError **error)
{
- gboolean ret = FALSE;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
glnx_fd_close int ret_fd = -1;
if (!glnx_dirfd_iterator_init_at (self->repo_dir_fd, "refs/remotes", TRUE, &dfd_iter, error))
- goto out;
+ return FALSE;
while (TRUE)
{
@@ -171,7 +146,7 @@ find_ref_in_remotes (OstreeRepo *self,
glnx_fd_close int remote_dfd = -1;
if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dfd_iter, &dent, NULL, error))
- goto out;
+ return FALSE;
if (dent == NULL)
break;
@@ -179,19 +154,17 @@ find_ref_in_remotes (OstreeRepo *self,
continue;
if (!glnx_opendirat (dfd_iter.fd, dent->d_name, TRUE, &remote_dfd, error))
- goto out;
+ return FALSE;
if (!ot_openat_ignore_enoent (remote_dfd, rev, &ret_fd, error))
- goto out;
+ return FALSE;
if (ret_fd != -1)
break;
}
- ret = TRUE;
*out_fd = ret_fd; ret_fd = -1;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -213,14 +186,13 @@ resolve_refspec_fallback (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_autofree char *ret_rev = NULL;
if (self->parent_repo)
{
if (!resolve_refspec (self->parent_repo, remote, ref, allow_noent,
fallback_remote, &ret_rev, error))
- goto out;
+ return FALSE;
}
else if (!allow_noent)
{
@@ -229,13 +201,11 @@ resolve_refspec_fallback (OstreeRepo *self,
remote ? remote : "",
remote ? ":" : "",
ref);
- goto out;
+ return FALSE;
}
- ret = TRUE;
ot_transfer_out_value (out_rev, &ret_rev);
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -247,11 +217,10 @@ resolve_refspec (OstreeRepo *self,
char **out_rev,
GError **error)
{
- gboolean ret = FALSE;
__attribute__((unused)) GCancellable *cancellable = NULL;
g_autofree char *ret_rev = NULL;
glnx_fd_close int target_fd = -1;
-
+
g_return_val_if_fail (ref != NULL, FALSE);
/* We intentionally don't allow a ref that looks like a checksum */
@@ -264,26 +233,26 @@ resolve_refspec (OstreeRepo *self,
const char *remote_ref = glnx_strjoina ("refs/remotes/", remote, "/", ref);
if (!ot_openat_ignore_enoent (self->repo_dir_fd, remote_ref, &target_fd, error))
- goto out;
+ return FALSE;
}
else
{
const char *local_ref = glnx_strjoina ("refs/heads/", ref);
if (!ot_openat_ignore_enoent (self->repo_dir_fd, local_ref, &target_fd, error))
- goto out;
+ return FALSE;
if (target_fd == -1 && fallback_remote)
{
local_ref = glnx_strjoina ("refs/remotes/", ref);
if (!ot_openat_ignore_enoent (self->repo_dir_fd, local_ref, &target_fd, error))
- goto out;
+ return FALSE;
if (target_fd == -1)
{
if (!find_ref_in_remotes (self, ref, &target_fd, error))
- goto out;
+ return FALSE;
}
}
}
@@ -294,24 +263,22 @@ resolve_refspec (OstreeRepo *self,
if (!ret_rev)
{
g_prefix_error (error, "Couldn't open ref '%s': ", ref);
- goto out;
+ return FALSE;
}
-
+
g_strchomp (ret_rev);
if (!ostree_validate_checksum_string (ret_rev, error))
- goto out;
+ return FALSE;
}
else
{
if (!resolve_refspec_fallback (self, remote, ref, allow_noent, fallback_remote,
&ret_rev, cancellable, error))
- goto out;
+ return FALSE;
}
ot_transfer_out_value (out_rev, &ret_rev);
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -330,65 +297,51 @@ ostree_repo_resolve_partial_checksum (OstreeRepo *self,
char **full_checksum,
GError **error)
{
- gboolean ret = FALSE;
static const char hexchars[] = "0123456789abcdef";
- gsize off;
- g_autoptr(GHashTable) ref_list = NULL;
g_autofree char *ret_rev = NULL;
- guint length;
- const char *checksum = NULL;
- OstreeObjectType objtype;
- GHashTableIter hashiter;
- gpointer key, value;
- GVariant *first_commit;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* If the input is longer than OSTREE_SHA256_STRING_LEN chars or contains non-hex chars,
don't bother looking for it as an object */
- off = strspn (refspec, hexchars);
+ const gsize off = strspn (refspec, hexchars);
if (off > OSTREE_SHA256_STRING_LEN || refspec[off] != '\0')
return TRUE;
/* this looks through all objects and adds them to the ref_list if:
a) they are a commit object AND
b) the obj checksum starts with the partual checksum defined by "refspec" */
+ g_autoptr(GHashTable) ref_list = NULL;
if (!ostree_repo_list_commit_objects_starting_with (self, refspec, &ref_list, NULL, error))
- goto out;
+ return FALSE;
- length = g_hash_table_size (ref_list);
+ guint length = g_hash_table_size (ref_list);
+ GHashTableIter hashiter;
+ gpointer key, value;
+ GVariant *first_commit = NULL;
g_hash_table_iter_init (&hashiter, ref_list);
if (g_hash_table_iter_next (&hashiter, &key, &value))
first_commit = (GVariant*) key;
- else
- first_commit = NULL;
- if (first_commit)
+ OstreeObjectType objtype;
+ const char *checksum = NULL;
+ if (first_commit)
ostree_object_name_deserialize (first_commit, &checksum, &objtype);
/* length more than one - multiple commits match partial refspec: is not unique */
if (length > 1)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Refspec %s not unique", refspec);
- goto out;
- }
-
+ return glnx_throw (error, "Refspec %s not unique", refspec);
/* length is 1 - a single matching commit gives us our revision */
else if (length == 1)
- {
- ret_rev = g_strdup (checksum);
- }
+ ret_rev = g_strdup (checksum);
/* Note: if length is 0, then code will return TRUE
because there is no error, but it will return full_checksum = NULL
to signal to continue parsing */
- ret = TRUE;
ot_transfer_out_value (full_checksum, &ret_rev);
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -399,7 +352,6 @@ _ostree_repo_resolve_rev_internal (OstreeRepo *self,
char **out_rev,
GError **error)
{
- gboolean ret = FALSE;
g_autofree char *ret_rev = NULL;
g_return_val_if_fail (refspec != NULL, FALSE);
@@ -410,12 +362,12 @@ _ostree_repo_resolve_rev_internal (OstreeRepo *self,
}
else if (!ostree_repo_resolve_partial_checksum (self, refspec, &ret_rev, error))
- goto out;
+ return FALSE;
if (!ret_rev)
{
if (error != NULL && *error != NULL)
- goto out;
+ return FALSE;
if (g_str_has_suffix (refspec, "^"))
{
@@ -427,18 +379,14 @@ _ostree_repo_resolve_rev_internal (OstreeRepo *self,
parent_refspec[strlen(parent_refspec) - 1] = '\0';
if (!ostree_repo_resolve_rev (self, parent_refspec, allow_noent, &parent_rev, error))
- goto out;
-
+ return FALSE;
+
if (!ostree_repo_load_variant (self, OSTREE_OBJECT_TYPE_COMMIT, parent_rev,
&commit, error))
- goto out;
-
+ return FALSE;
+
if (!(ret_rev = ostree_commit_get_parent (commit)))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Commit %s has no parent", parent_rev);
- goto out;
- }
+ return glnx_throw (error, "Commit %s has no parent", parent_rev);
}
else
{
@@ -446,18 +394,16 @@ _ostree_repo_resolve_rev_internal (OstreeRepo *self,
g_autofree char *ref = NULL;
if (!ostree_parse_refspec (refspec, &remote, &ref, error))
- goto out;
-
+ return FALSE;
+
if (!resolve_refspec (self, remote, ref, allow_noent,
fallback_remote, &ret_rev, error))
- goto out;
+ return FALSE;
}
}
- ret = TRUE;
ot_transfer_out_value (out_rev, &ret_rev);
- out:
- return ret;
+ return TRUE;
}
/**
@@ -518,11 +464,10 @@ enumerate_refs_recurse (OstreeRepo *repo,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
if (!glnx_dirfd_iterator_init_at (child_dfd, path, FALSE, &dfd_iter, error))
- goto out;
+ return FALSE;
while (TRUE)
{
@@ -530,7 +475,7 @@ enumerate_refs_recurse (OstreeRepo *repo,
struct dirent *dent = NULL;
if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dfd_iter, &dent, cancellable, error))
- goto out;
+ return FALSE;
if (dent == NULL)
break;
@@ -543,22 +488,19 @@ enumerate_refs_recurse (OstreeRepo *repo,
if (!enumerate_refs_recurse (repo, remote, base_dfd, base_path,
dfd_iter.fd, dent->d_name,
refs, cancellable, error))
- goto out;
-
+ return FALSE;
}
else if (dent->d_type == DT_REG)
{
if (!add_ref_to_set (remote, base_dfd, base_path->str, refs,
cancellable, error))
- goto out;
+ return FALSE;
}
g_string_truncate (base_path, len);
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -569,7 +511,6 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_autoptr(GHashTable) ret_all_refs = NULL;
g_autofree char *remote = NULL;
g_autofree char *ref_prefix = NULL;
@@ -583,7 +524,7 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
const char *path;
if (!ostree_parse_refspec (refspec_prefix, &remote, &ref_prefix, error))
- goto out;
+ return FALSE;
if (remote)
{
@@ -599,10 +540,7 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
if (fstatat (self->repo_dir_fd, path, &stbuf, 0) < 0)
{
if (errno != ENOENT)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
}
else
{
@@ -614,23 +552,23 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
g_string_printf (base_path, "%s/", ref_prefix);
if (!glnx_opendirat (self->repo_dir_fd, cut_prefix ? path : prefix_path, TRUE, &base_fd, error))
- goto out;
+ return FALSE;
if (!enumerate_refs_recurse (self, remote, base_fd, base_path,
base_fd, cut_prefix ? "." : ref_prefix,
ret_all_refs, cancellable, error))
- goto out;
+ return FALSE;
}
else
{
glnx_fd_close int prefix_dfd = -1;
-
+
if (!glnx_opendirat (self->repo_dir_fd, prefix_path, TRUE, &prefix_dfd, error))
- goto out;
+ return FALSE;
if (!add_ref_to_set (remote, prefix_dfd, ref_prefix, ret_all_refs,
cancellable, error))
- goto out;
+ return FALSE;
}
}
}
@@ -639,19 +577,19 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
g_autoptr(GString) base_path = g_string_new ("");
glnx_fd_close int refs_heads_dfd = -1;
-
+
if (!glnx_opendirat (self->repo_dir_fd, "refs/heads", TRUE, &refs_heads_dfd, error))
- goto out;
+ return FALSE;
if (!enumerate_refs_recurse (self, NULL, refs_heads_dfd, base_path,
refs_heads_dfd, ".",
ret_all_refs, cancellable, error))
- goto out;
+ return FALSE;
g_string_truncate (base_path, 0);
if (!glnx_dirfd_iterator_init_at (self->repo_dir_fd, "refs/remotes", TRUE, &dfd_iter, error))
- goto out;
+ return FALSE;
while (TRUE)
{
@@ -659,7 +597,7 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
glnx_fd_close int remote_dfd = -1;
if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dfd_iter, &dent, cancellable, error))
- goto out;
+ return FALSE;
if (!dent)
break;
@@ -667,20 +605,18 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
continue;
if (!glnx_opendirat (dfd_iter.fd, dent->d_name, TRUE, &remote_dfd, error))
- goto out;
-
+ return FALSE;
+
if (!enumerate_refs_recurse (self, dent->d_name, remote_dfd, base_path,
remote_dfd, ".",
ret_all_refs,
cancellable, error))
- goto out;
+ return FALSE;
}
}
- ret = TRUE;
ot_transfer_out_value (out_all_refs, &ret_all_refs);
- out:
- return ret;
+ return TRUE;
}
/**
@@ -748,19 +684,16 @@ ostree_repo_remote_list_refs (OstreeRepo *self,
GError **error)
{
g_autoptr(GBytes) summary_bytes = NULL;
- gboolean ret = FALSE;
g_autoptr(GHashTable) ret_all_refs = NULL;
if (!ostree_repo_remote_fetch_summary (self, remote_name,
&summary_bytes, NULL,
cancellable, error))
- goto out;
+ return FALSE;
if (summary_bytes == NULL)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Remote refs not available; server has no summary file\n");
- goto out;
+ return glnx_throw (error, "Remote refs not available; server has no summary file");
}
else
{
@@ -786,12 +719,11 @@ ostree_repo_remote_list_refs (OstreeRepo *self,
if (ref_name != NULL)
{
- const guchar *csum_bytes;
-
g_variant_get_child (child, 1, "(t@aya{sv})", NULL, &csum_v, NULL);
- csum_bytes = ostree_checksum_bytes_peek_validate (csum_v, error);
+
+ const guchar *csum_bytes = ostree_checksum_bytes_peek_validate (csum_v, error);
if (csum_bytes == NULL)
- goto out;
+ return FALSE;
ostree_checksum_inplace_from_bytes (csum_bytes, tmp_checksum);
@@ -804,14 +736,11 @@ ostree_repo_remote_list_refs (OstreeRepo *self,
}
}
- ret = TRUE;
ot_transfer_out_value (out_all_refs, &ret_all_refs);
-
- out:
- return ret;
+ return TRUE;
}
-gboolean
+gboolean
_ostree_repo_write_ref (OstreeRepo *self,
const char *remote,
const char *ref,
@@ -819,7 +748,6 @@ _ostree_repo_write_ref (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
glnx_fd_close int dfd = -1;
if (remote == NULL)
@@ -828,7 +756,7 @@ _ostree_repo_write_ref (OstreeRepo *self,
&dfd, error))
{
g_prefix_error (error, "Opening %s: ", "refs/heads");
- goto out;
+ return FALSE;
}
}
else
@@ -839,23 +767,19 @@ _ostree_repo_write_ref (OstreeRepo *self,
&refs_remotes_dfd, error))
{
g_prefix_error (error, "Opening %s: ", "refs/remotes");
- goto out;
+ return FALSE;
}
if (rev != NULL)
{
/* Ensure we have a dir for the remote */
if (!glnx_shutil_mkdir_p_at (refs_remotes_dfd, remote, 0777, cancellable, error))
- goto out;
+ return FALSE;
}
dfd = glnx_opendirat_with_errno (refs_remotes_dfd, remote, TRUE);
if (dfd < 0 && (errno != ENOENT || rev != NULL))
- {
- glnx_set_error_from_errno (error);
- g_prefix_error (error, "Opening remotes/ dir %s: ", remote);
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "Opening remotes/ dir %s", remote);
}
if (rev == NULL)
@@ -863,27 +787,22 @@ _ostree_repo_write_ref (OstreeRepo *self,
if (dfd >= 0)
{
if (unlinkat (dfd, ref, 0) != 0)
- {
- if (errno != ENOENT)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
- }
+ {
+ if (errno != ENOENT)
+ return glnx_throw_errno (error);
+ }
}
}
else
{
if (!write_checksum_file_at (self, dfd, ref, rev, cancellable, error))
- goto out;
+ return FALSE;
}
if (!_ostree_repo_update_mtime (self, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
gboolean
@@ -892,7 +811,6 @@ _ostree_repo_update_refs (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
GHashTableIter hash_iter;
gpointer key, value;
@@ -905,14 +823,12 @@ _ostree_repo_update_refs (OstreeRepo *self,
g_autofree char *ref = NULL;
if (!ostree_parse_refspec (refspec, &remote, &ref, error))
- goto out;
+ return FALSE;
if (!_ostree_repo_write_ref (self, remote, ref, rev,
cancellable, error))
- goto out;
+ return FALSE;
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 71604480..c8a12543 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -42,6 +42,7 @@
#include
#include
+#include
/**
* SECTION:ostree-repo
@@ -891,26 +892,21 @@ ostree_repo_write_config (OstreeRepo *self,
GKeyFile *new_config,
GError **error)
{
- gboolean ret = FALSE;
- g_autofree char *data = NULL;
- gsize len;
-
g_return_val_if_fail (self->inited, FALSE);
- data = g_key_file_to_data (new_config, &len, error);
+ gsize len;
+ g_autofree char *data = g_key_file_to_data (new_config, &len, error);
if (!glnx_file_replace_contents_at (self->repo_dir_fd, "config",
(guint8*)data, len, 0,
NULL, error))
- goto out;
+ return FALSE;
g_key_file_free (self->config);
self->config = g_key_file_new ();
if (!g_key_file_load_from_data (self->config, data, len, 0, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/* Bind a subset of an a{sv} to options in a given GKeyfile section */
@@ -953,34 +949,24 @@ impl_repo_remote_add (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- g_autoptr(OstreeRemote) remote = NULL;
- gboolean different_sysroot = FALSE;
- gboolean ret = FALSE;
-
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (url != NULL, FALSE);
g_return_val_if_fail (options == NULL || g_variant_is_of_type (options, G_VARIANT_TYPE ("a{sv}")), FALSE);
if (strchr (name, '/') != NULL)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid character '/' in remote name: %s",
- name);
- goto out;
- }
+ return glnx_throw (error, "Invalid character '/' in remote name: %s", name);
- remote = ost_repo_get_remote (self, name, NULL);
+ g_autoptr(OstreeRemote) remote = ost_repo_get_remote (self, name, NULL);
if (remote != NULL && if_not_exists)
{
- ret = TRUE;
- goto out;
+ /* Note early return */
+ return TRUE;
}
else if (remote != NULL)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Remote configuration for \"%s\" already exists: %s",
- name, remote->file ? gs_file_get_path_cached (remote->file) : "(in config)");
- goto out;
+ return glnx_throw (error,
+ "Remote configuration for \"%s\" already exists: %s",
+ name, remote->file ? gs_file_get_path_cached (remote->file) : "(in config)");
}
remote = ost_remote_new ();
@@ -994,20 +980,18 @@ impl_repo_remote_add (OstreeRepo *self,
*
* XXX Having API regret about the "sysroot" argument now.
*/
+ gboolean different_sysroot = FALSE;
if (sysroot != NULL)
different_sysroot = !g_file_equal (sysroot, self->sysroot_dir);
if (different_sysroot || ostree_repo_is_system (self))
{
- g_autofree char *basename = g_strconcat (name, ".conf", NULL);
- g_autoptr(GFile) etc_ostree_remotes_d = NULL;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
if (sysroot == NULL)
sysroot = self->sysroot_dir;
- etc_ostree_remotes_d = g_file_resolve_relative_path (sysroot, SYSCONF_REMOTES);
-
+ g_autoptr(GFile) etc_ostree_remotes_d = g_file_resolve_relative_path (sysroot, SYSCONF_REMOTES);
if (!g_file_make_directory_with_parents (etc_ostree_remotes_d,
cancellable, &local_error))
{
@@ -1017,11 +1001,12 @@ impl_repo_remote_add (OstreeRepo *self,
}
else
{
- g_propagate_error (error, local_error);
- goto out;
+ g_propagate_error (error, g_steal_pointer (&local_error));
+ return FALSE;
}
}
+ g_autofree char *basename = g_strconcat (name, ".conf", NULL);
remote->file = g_file_get_child (etc_ostree_remotes_d, basename);
}
@@ -1035,16 +1020,14 @@ impl_repo_remote_add (OstreeRepo *self,
if (remote->file != NULL)
{
- g_autofree char *data = NULL;
gsize length;
-
- data = g_key_file_to_data (remote->options, &length, NULL);
+ g_autofree char *data = g_key_file_to_data (remote->options, &length, NULL);
if (!g_file_replace_contents (remote->file,
data, length,
NULL, FALSE, 0, NULL,
cancellable, error))
- goto out;
+ return FALSE;
}
else
{
@@ -1054,15 +1037,12 @@ impl_repo_remote_add (OstreeRepo *self,
ot_keyfile_copy_group (remote->options, config, remote->group);
if (!ostree_repo_write_config (self, config, error))
- goto out;
+ return FALSE;
}
ost_repo_add_remote (self, remote);
- ret = TRUE;
-
- out:
- return ret;
+ return TRUE;
}
/**
@@ -1103,67 +1083,52 @@ impl_repo_remote_delete (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- g_autoptr(OstreeRemote) remote = NULL;
- gboolean ret = FALSE;
-
g_return_val_if_fail (name != NULL, FALSE);
if (strchr (name, '/') != NULL)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid character '/' in remote name: %s",
- name);
- goto out;
- }
+ return glnx_throw (error, "Invalid character '/' in remote name: %s", name);
+ g_autoptr(OstreeRemote) remote = NULL;
if (if_exists)
{
remote = ost_repo_get_remote (self, name, NULL);
if (!remote)
{
- ret = TRUE;
- goto out;
+ /* Note early return */
+ return TRUE;
}
}
else
remote = ost_repo_get_remote (self, name, error);
if (remote == NULL)
- goto out;
+ return FALSE;
if (remote->file != NULL)
{
if (unlink (gs_file_get_path_cached (remote->file)) != 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
}
else
{
- g_autoptr(GKeyFile) config = NULL;
-
- config = ostree_repo_copy_config (self);
+ g_autoptr(GKeyFile) config = ostree_repo_copy_config (self);
/* XXX Not sure it's worth failing if the group to remove
* isn't found. It's the end result we want, after all. */
if (g_key_file_remove_group (config, remote->group, NULL))
{
if (!ostree_repo_write_config (self, config, error))
- goto out;
+ return FALSE;
}
}
/* Delete the remote's keyring file, if it exists. */
if (!ot_ensure_unlinked_at (self->repo_dir_fd, remote->keyring, error))
- goto out;
+ return FALSE;
ost_repo_remove_remote (self, remote);
- ret = TRUE;
-
- out:
- return ret;
+ return TRUE;
}
/**
@@ -1319,11 +1284,9 @@ ostree_repo_remote_get_url (OstreeRepo *self,
char **out_url,
GError **error)
{
- g_autofree char *url = NULL;
- gboolean ret = FALSE;
-
g_return_val_if_fail (name != NULL, FALSE);
+ g_autofree char *url = NULL;
if (_ostree_repo_remote_name_is_file (name))
{
url = g_strdup (name);
@@ -1331,23 +1294,19 @@ ostree_repo_remote_get_url (OstreeRepo *self,
else
{
if (!ostree_repo_get_remote_option (self, name, "url", NULL, &url, error))
- goto out;
+ return FALSE;
if (url == NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No \"url\" option in remote \"%s\"", name);
- goto out;
+ return FALSE;
}
}
if (out_url != NULL)
*out_url = g_steal_pointer (&url);
-
- ret = TRUE;
-
- out:
- return ret;
+ return TRUE;
}
/**
@@ -1583,8 +1542,9 @@ ostree_repo_remote_gpg_import (OstreeRepo *self,
if (fstatat (self->repo_dir_fd, remote->keyring, &stbuf, AT_SYMLINK_NOFOLLOW) == 0)
{
+ GLnxFileCopyFlags copyflags = self->disable_xattrs ? GLNX_FILE_COPY_NOXATTRS : 0;
if (!glnx_file_copy_at (self->repo_dir_fd, remote->keyring,
- &stbuf, target_temp_fd, "pubring.gpg", 0,
+ &stbuf, target_temp_fd, "pubring.gpg", copyflags,
cancellable, error))
{
g_prefix_error (error, "Unable to copy remote's keyring: ");
@@ -1741,7 +1701,6 @@ ostree_repo_mode_to_string (OstreeRepoMode mode,
const char **out_mode,
GError **error)
{
- gboolean ret = FALSE;
const char *ret_mode;
switch (mode)
@@ -1752,19 +1711,18 @@ ostree_repo_mode_to_string (OstreeRepoMode mode,
case OSTREE_REPO_MODE_BARE_USER:
ret_mode = "bare-user";
break;
+ case OSTREE_REPO_MODE_BARE_USER_ONLY:
+ ret_mode = "bare-user-only";
+ break;
case OSTREE_REPO_MODE_ARCHIVE_Z2:
ret_mode ="archive-z2";
break;
default:
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid mode '%d'", mode);
- goto out;
+ return glnx_throw (error, "Invalid mode '%d'", mode);
}
- ret = TRUE;
*out_mode = ret_mode;
- out:
- return ret;
+ return TRUE;
}
gboolean
@@ -1772,27 +1730,22 @@ ostree_repo_mode_from_string (const char *mode,
OstreeRepoMode *out_mode,
GError **error)
{
- gboolean ret = FALSE;
OstreeRepoMode ret_mode;
if (strcmp (mode, "bare") == 0)
ret_mode = OSTREE_REPO_MODE_BARE;
else if (strcmp (mode, "bare-user") == 0)
ret_mode = OSTREE_REPO_MODE_BARE_USER;
+ else if (strcmp (mode, "bare-user-only") == 0)
+ ret_mode = OSTREE_REPO_MODE_BARE_USER_ONLY;
else if (strcmp (mode, "archive-z2") == 0 ||
strcmp (mode, "archive") == 0)
ret_mode = OSTREE_REPO_MODE_ARCHIVE_Z2;
else
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid mode '%s' in repository configuration", mode);
- goto out;
- }
+ return glnx_throw (error, "Invalid mode '%s' in repository configuration", mode);
- ret = TRUE;
*out_mode = ret_mode;
- out:
- return ret;
+ return TRUE;
}
#define DEFAULT_CONFIG_CONTENTS ("[core]\n" \
@@ -1830,10 +1783,7 @@ ostree_repo_create (OstreeRepo *self,
if (mkdir (repopath, 0755) != 0)
{
if (G_UNLIKELY (errno != EEXIST))
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+ return glnx_throw_errno (error);
}
if (!glnx_opendirat (AT_FDCWD, repopath, TRUE, &dfd, error))
@@ -1843,11 +1793,12 @@ ostree_repo_create (OstreeRepo *self,
{
if (errno == ENOENT)
{
- const char *mode_str;
+ const char *mode_str = NULL;
g_autoptr(GString) config_data = g_string_new (DEFAULT_CONFIG_CONTENTS);
if (!ostree_repo_mode_to_string (mode, &mode_str, error))
return FALSE;
+ g_assert (mode_str);
g_string_append_printf (config_data, "mode=%s\n", mode_str);
@@ -1857,10 +1808,7 @@ ostree_repo_create (OstreeRepo *self,
return FALSE;
}
else
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+ return glnx_throw_errno (error);
}
for (guint i = 0; i < G_N_ELEMENTS (state_dirs); i++)
@@ -1869,10 +1817,7 @@ ostree_repo_create (OstreeRepo *self,
if (mkdirat (dfd, elt, 0755) == -1)
{
if (G_UNLIKELY (errno != EEXIST))
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+ return glnx_throw_errno (error);
}
}
@@ -1890,8 +1835,7 @@ enumerate_directory_allow_noent (GFile *dirpath,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- GError *temp_error = NULL;
+ g_autoptr(GError) temp_error = NULL;
g_autoptr(GFileEnumerator) ret_direnum = NULL;
ret_direnum = g_file_enumerate_children (dirpath, queryargs, queryflags,
@@ -1899,21 +1843,17 @@ enumerate_directory_allow_noent (GFile *dirpath,
if (!ret_direnum)
{
if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- {
- g_clear_error (&temp_error);
- ret = TRUE;
- }
+ g_clear_error (&temp_error);
else
- g_propagate_error (error, temp_error);
-
- goto out;
+ {
+ g_propagate_error (error, g_steal_pointer (&temp_error));
+ return FALSE;
+ }
}
- ret = TRUE;
if (out_direnum)
*out_direnum = g_steal_pointer (&ret_direnum);
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -1979,17 +1919,12 @@ append_one_remote_config (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
g_autoptr(GKeyFile) remotedata = g_key_file_new ();
-
if (!g_key_file_load_from_file (remotedata, gs_file_get_path_cached (path),
0, error))
- goto out;
+ return FALSE;
- ret = add_remotes_from_keyfile (self, remotedata, path, error);
-
- out:
- return ret;
+ return add_remotes_from_keyfile (self, remotedata, path, error);
}
static GFile *
@@ -2033,11 +1968,7 @@ reload_core_config (OstreeRepo *self,
return FALSE;
if (strcmp (version, "1") != 0)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid repository version '%s'", version);
- return FALSE;
- }
+ return glnx_throw (error, "Invalid repository version '%s'", version);
if (!ot_keyfile_get_boolean_with_default (self->config, "core", "archive",
FALSE, &is_archive, error))
@@ -2075,6 +2006,11 @@ reload_core_config (OstreeRepo *self,
ostree_repo_set_disable_fsync (self, TRUE);
}
+ /* See https://github.com/ostreedev/ostree/issues/758 */
+ if (!ot_keyfile_get_boolean_with_default (self->config, "core", "disable-xattrs",
+ FALSE, &self->disable_xattrs, error))
+ return FALSE;
+
{ g_autofree char *tmp_expiry_seconds = NULL;
/* 86400 secs = one day */
@@ -2125,25 +2061,23 @@ reload_remote_config (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GFile) remotes_d = NULL;
- g_autoptr(GFileEnumerator) direnum = NULL;
g_mutex_lock (&self->remotes_lock);
g_hash_table_remove_all (self->remotes);
g_mutex_unlock (&self->remotes_lock);
if (!add_remotes_from_keyfile (self, self->config, NULL, error))
- goto out;
+ return FALSE;
- remotes_d = get_remotes_d_dir (self);
+ g_autoptr(GFile) remotes_d = get_remotes_d_dir (self);
if (remotes_d == NULL)
return TRUE;
+ g_autoptr(GFileEnumerator) direnum = NULL;
if (!enumerate_directory_allow_noent (remotes_d, OSTREE_GIO_FAST_QUERYINFO, 0,
&direnum,
cancellable, error))
- goto out;
+ return FALSE;
if (direnum)
{
while (TRUE)
@@ -2155,7 +2089,7 @@ reload_remote_config (OstreeRepo *self,
if (!g_file_enumerator_iterate (direnum, &file_info, &path,
NULL, error))
- goto out;
+ return FALSE;
if (file_info == NULL)
break;
@@ -2166,14 +2100,12 @@ reload_remote_config (OstreeRepo *self,
g_str_has_suffix (name, ".conf"))
{
if (!append_one_remote_config (self, path, cancellable, error))
- goto out;
+ return FALSE;
}
}
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2202,7 +2134,6 @@ ostree_repo_open (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
struct stat stbuf;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -2225,7 +2156,7 @@ ostree_repo_open (OstreeRepo *self,
&boot_id,
NULL,
error))
- goto out;
+ return FALSE;
g_strdelimit (boot_id, "\n", '\0');
}
@@ -2236,14 +2167,14 @@ ostree_repo_open (OstreeRepo *self,
&self->repo_dir_fd, error))
{
g_prefix_error (error, "%s: ", gs_file_get_path_cached (self->repodir));
- goto out;
+ return FALSE;
}
if (!glnx_opendirat (self->repo_dir_fd, "objects", TRUE,
&self->objects_dir_fd, error))
{
g_prefix_error (error, "Opening objects/ directory: ");
- goto out;
+ return FALSE;
}
self->writable = faccessat (self->objects_dir_fd, ".", W_OK, 0) == 0;
@@ -2251,13 +2182,11 @@ ostree_repo_open (OstreeRepo *self,
{
/* This is returned through ostree_repo_is_writable(). */
glnx_set_error_from_errno (&self->writable_error);
+ /* Note - we don't return this error yet! */
}
if (fstat (self->objects_dir_fd, &stbuf) != 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
if (stbuf.st_uid != getuid () || stbuf.st_gid != getgid ())
{
@@ -2270,37 +2199,34 @@ ostree_repo_open (OstreeRepo *self,
}
if (!glnx_opendirat (self->repo_dir_fd, "tmp", TRUE, &self->tmp_dir_fd, error))
- goto out;
+ return FALSE;
if (self->writable)
{
if (!glnx_shutil_mkdir_p_at (self->tmp_dir_fd, _OSTREE_CACHE_DIR, 0775, cancellable, error))
- goto out;
+ return FALSE;
if (!glnx_opendirat (self->tmp_dir_fd, _OSTREE_CACHE_DIR, TRUE, &self->cache_dir_fd, error))
- goto out;
+ return FALSE;
}
if (!ostree_repo_reload_config (self, cancellable, error))
- goto out;
+ return FALSE;
/* TODO - delete this */
if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2 && self->enable_uncompressed_cache)
{
if (!glnx_shutil_mkdir_p_at (self->repo_dir_fd, "uncompressed-objects-cache", 0755,
cancellable, error))
- goto out;
+ return FALSE;
if (!glnx_opendirat (self->repo_dir_fd, "uncompressed-objects-cache", TRUE,
&self->uncompressed_objects_dir_fd,
error))
- goto out;
+ return FALSE;
}
self->inited = TRUE;
-
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2368,8 +2294,8 @@ ostree_repo_get_disable_fsync (OstreeRepo *self)
/* Replace the contents of a file, honoring the repository's fsync
* policy.
- */
-gboolean
+ */
+gboolean
_ostree_repo_file_replace_contents (OstreeRepo *self,
int dfd,
const char *path,
@@ -2474,7 +2400,7 @@ list_loose_objects_at (OstreeRepo *self,
if ((self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
&& strcmp (dot, ".filez") == 0) ||
- ((self->mode == OSTREE_REPO_MODE_BARE || self->mode == OSTREE_REPO_MODE_BARE_USER)
+ ((_ostree_repo_mode_is_bare (self->mode))
&& strcmp (dot, ".file") == 0))
objtype = OSTREE_OBJECT_TYPE_FILE;
else if (strcmp (dot, ".dirtree") == 0)
@@ -2529,7 +2455,6 @@ list_loose_objects (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
guint c;
int dfd = -1;
static const gchar hexchars[] = "0123456789abcdef";
@@ -2546,21 +2471,16 @@ list_loose_objects (OstreeRepo *self,
if (errno == ENOENT)
continue;
else
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
}
/* Takes ownership of dfd */
if (!list_loose_objects_at (self, inout_objects, buf, dfd,
commit_starting_with,
cancellable, error))
- goto out;
+ return FALSE;
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -2574,7 +2494,6 @@ load_metadata_internal (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
struct stat stbuf;
glnx_fd_close int fd = -1;
@@ -2587,22 +2506,19 @@ load_metadata_internal (OstreeRepo *self,
if (!ot_openat_ignore_enoent (self->objects_dir_fd, loose_path_buf, &fd,
error))
- goto out;
+ return FALSE;
if (fd < 0 && self->commit_stagedir_fd != -1)
{
if (!ot_openat_ignore_enoent (self->commit_stagedir_fd, loose_path_buf, &fd,
error))
- goto out;
+ return FALSE;
}
if (fd != -1)
{
if (fstat (fd, &stbuf) < 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
if (out_variant)
{
@@ -2613,7 +2529,7 @@ load_metadata_internal (OstreeRepo *self,
mfile = g_mapped_file_new_from_fd (fd, FALSE, error);
if (!mfile)
- goto out;
+ return FALSE;
ret_variant = g_variant_new_from_data (ostree_metadata_variant_type (objtype),
g_mapped_file_get_contents (mfile),
g_mapped_file_get_length (mfile),
@@ -2626,7 +2542,7 @@ load_metadata_internal (OstreeRepo *self,
{
g_autoptr(GBytes) data = glnx_fd_readall_bytes (fd, cancellable, error);
if (!data)
- goto out;
+ return FALSE;
ret_variant = g_variant_new_from_bytes (ostree_metadata_variant_type (objtype),
data, TRUE);
g_variant_ref_sink (ret_variant);
@@ -2636,7 +2552,7 @@ load_metadata_internal (OstreeRepo *self,
{
ret_stream = g_unix_input_stream_new (fd, TRUE);
if (!ret_stream)
- goto out;
+ return FALSE;
fd = -1; /* Transfer ownership */
}
@@ -2646,21 +2562,19 @@ load_metadata_internal (OstreeRepo *self,
else if (self->parent_repo)
{
if (!ostree_repo_load_variant (self->parent_repo, objtype, sha256, &ret_variant, error))
- goto out;
+ return FALSE;
}
else if (error_if_not_found)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No such metadata object %s.%s",
sha256, ostree_object_type_to_string (objtype));
- goto out;
+ return FALSE;
}
- ret = TRUE;
ot_transfer_out_value (out_variant, &ret_variant);
ot_transfer_out_value (out_stream, &ret_stream);
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -2745,8 +2659,7 @@ _ostree_repo_read_bare_fd (OstreeRepo *self,
{
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
- g_assert (self->mode == OSTREE_REPO_MODE_BARE ||
- self->mode == OSTREE_REPO_MODE_BARE_USER);
+ g_assert (_ostree_repo_mode_is_bare (self->mode));
_ostree_loose_path (loose_path_buf, checksum, OSTREE_OBJECT_TYPE_FILE, self->mode);
@@ -2910,6 +2823,37 @@ ostree_repo_load_file (OstreeRepo *self,
g_file_info_set_symlink_target (ret_file_info, targetbuf);
}
}
+ else if (repo_mode == OSTREE_REPO_MODE_BARE_USER_ONLY)
+ {
+ glnx_fd_close int fd = -1;
+
+ /* Canonical info is: uid/gid is 0 and no xattrs, which
+ might be wrong and thus not validate correctly, but
+ at least we report something consistent. */
+ g_file_info_set_attribute_uint32 (ret_file_info, "unix::uid", 0);
+ g_file_info_set_attribute_uint32 (ret_file_info, "unix::gid", 0);
+
+ if (g_file_info_get_file_type (ret_file_info) == G_FILE_TYPE_REGULAR &&
+ out_input)
+ {
+ fd = openat (self->objects_dir_fd, loose_path_buf, O_RDONLY | O_CLOEXEC);
+ if (fd < 0)
+ {
+ glnx_set_error_from_errno (error);
+ goto out;
+ }
+
+ ret_input = g_unix_input_stream_new (fd, TRUE);
+ fd = -1; /* Transfer ownership */
+ }
+
+ if (out_xattrs)
+ {
+ GVariantBuilder builder;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)"));
+ ret_xattrs = g_variant_ref_sink (g_variant_builder_end (&builder));
+ }
+ }
else
{
g_assert (repo_mode == OSTREE_REPO_MODE_BARE);
@@ -2928,8 +2872,10 @@ ostree_repo_load_file (OstreeRepo *self,
if (out_xattrs)
{
- if (!glnx_fd_get_all_xattrs (fd, &ret_xattrs,
- cancellable, error))
+ if (self->disable_xattrs)
+ ret_xattrs = g_variant_ref_sink (g_variant_new_array (G_VARIANT_TYPE ("(ayay)"), NULL, 0));
+ else if (!glnx_fd_get_all_xattrs (fd, &ret_xattrs,
+ cancellable, error))
goto out;
}
@@ -2942,15 +2888,17 @@ ostree_repo_load_file (OstreeRepo *self,
else if (g_file_info_get_file_type (ret_file_info) == G_FILE_TYPE_SYMBOLIC_LINK
&& out_xattrs)
{
- if (!glnx_dfd_name_get_all_xattrs (self->objects_dir_fd, loose_path_buf,
- &ret_xattrs,
- cancellable, error))
+ if (self->disable_xattrs)
+ ret_xattrs = g_variant_ref_sink (g_variant_new_array (G_VARIANT_TYPE ("(ayay)"), NULL, 0));
+ else if (!glnx_dfd_name_get_all_xattrs (self->objects_dir_fd, loose_path_buf,
+ &ret_xattrs,
+ cancellable, error))
goto out;
}
}
}
}
-
+
if (!found)
{
if (self->parent_repo)
@@ -3476,26 +3424,20 @@ ostree_repo_query_object_storage_size (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
char loose_path[_OSTREE_LOOSE_PATH_MAX];
int res;
struct stat stbuf;
_ostree_loose_path (loose_path, sha256, objtype, self->mode);
- do
+ do
res = fstatat (self->objects_dir_fd, loose_path, &stbuf, AT_SYMLINK_NOFOLLOW);
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
- {
- glnx_set_prefix_error_from_errno (error, "Querying object %s.%s", sha256, ostree_object_type_to_string (objtype));
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "Querying object %s.%s", sha256, ostree_object_type_to_string (objtype));
*out_size = stbuf.st_size;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -3563,13 +3505,11 @@ ostree_repo_load_commit (OstreeRepo *self,
OstreeRepoCommitState *out_state,
GError **error)
{
- gboolean ret = FALSE;
-
if (out_variant)
{
if (!load_metadata_internal (self, OSTREE_OBJECT_TYPE_COMMIT, checksum, TRUE,
out_variant, NULL, NULL, NULL, error))
- goto out;
+ return FALSE;
}
if (out_state)
@@ -3585,14 +3525,11 @@ ostree_repo_load_commit (OstreeRepo *self,
}
else if (errno != ENOENT)
{
- glnx_set_error_from_errno (error);
- goto out;
+ return glnx_throw_errno (error);
}
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -3618,15 +3555,13 @@ ostree_repo_list_objects (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GHashTable) ret_objects = NULL;
-
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (self->inited, FALSE);
- ret_objects = g_hash_table_new_full (ostree_hash_object_name, g_variant_equal,
- (GDestroyNotify) g_variant_unref,
- (GDestroyNotify) g_variant_unref);
+ g_autoptr(GHashTable) ret_objects =
+ g_hash_table_new_full (ostree_hash_object_name, g_variant_equal,
+ (GDestroyNotify) g_variant_unref,
+ (GDestroyNotify) g_variant_unref);
if (flags & OSTREE_REPO_LIST_OBJECTS_ALL)
flags |= (OSTREE_REPO_LIST_OBJECTS_LOOSE | OSTREE_REPO_LIST_OBJECTS_PACKED);
@@ -3634,11 +3569,11 @@ ostree_repo_list_objects (OstreeRepo *self,
if (flags & OSTREE_REPO_LIST_OBJECTS_LOOSE)
{
if (!list_loose_objects (self, ret_objects, NULL, cancellable, error))
- goto out;
+ return FALSE;
if ((flags & OSTREE_REPO_LIST_OBJECTS_NO_PARENTS) == 0 && self->parent_repo)
{
if (!list_loose_objects (self->parent_repo, ret_objects, NULL, cancellable, error))
- goto out;
+ return FALSE;
}
}
@@ -3647,10 +3582,8 @@ ostree_repo_list_objects (OstreeRepo *self,
/* Nothing for now... */
}
- ret = TRUE;
ot_transfer_out_value (out_objects, &ret_objects);
- out:
- return ret;
+ return TRUE;
}
/**
@@ -3720,25 +3653,20 @@ ostree_repo_read_commit (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GFile) ret_root = NULL;
g_autofree char *resolved_commit = NULL;
-
if (!ostree_repo_resolve_rev (self, ref, FALSE, &resolved_commit, error))
- goto out;
+ return FALSE;
- ret_root = (GFile*) _ostree_repo_file_new_for_commit (self, resolved_commit, error);
+ g_autoptr(GFile) ret_root = (GFile*) _ostree_repo_file_new_for_commit (self, resolved_commit, error);
if (!ret_root)
- goto out;
+ return FALSE;
if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile*)ret_root, error))
- goto out;
+ return FALSE;
- ret = TRUE;
ot_transfer_out_value(out_root, &ret_root);
ot_transfer_out_value(out_commit, &resolved_commit);
- out:
- return ret;
+ return TRUE;
}
/**
@@ -4225,6 +4153,13 @@ out:
/**
* ostree_repo_sign_delta:
+ * @self: Self
+ * @from_commit: From commit
+ * @to_commit: To commit
+ * @key_id: key id
+ * @homedir: homedir
+ * @cancellable: cancellable
+ * @error: error
*
* This function is deprecated, sign the summary file instead.
* Add a GPG signature to a static delta.
@@ -4859,7 +4794,6 @@ _ostree_repo_try_lock_tmpdir (int tmpdir_dfd,
gboolean *out_did_lock,
GError **error)
{
- gboolean ret = FALSE;
g_autofree char *lock_name = g_strconcat (tmpdir_name, "-lock", NULL);
gboolean did_lock = FALSE;
g_autoptr(GError) local_error = NULL;
@@ -4876,7 +4810,7 @@ _ostree_repo_try_lock_tmpdir (int tmpdir_dfd,
else
{
g_propagate_error (error, g_steal_pointer (&local_error));
- goto out;
+ return FALSE;
}
}
else
@@ -4884,10 +4818,8 @@ _ostree_repo_try_lock_tmpdir (int tmpdir_dfd,
did_lock = TRUE;
}
- ret = TRUE;
*out_did_lock = did_lock;
- out:
- return ret;
+ return TRUE;
}
/* This allocates and locks a subdir of the repo tmp dir, using an existing
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 34685cc6..1664d65d 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -123,6 +123,10 @@ gboolean ostree_repo_remote_delete (OstreeRepo *self,
/**
* OstreeRepoRemoteChange:
* The remote change operation.
+ * @OSTREE_REPO_REMOTE_CHANGE_ADD: Add a remote
+ * @OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS: Like above, but do nothing if the remote exists
+ * @OSTREE_REPO_REMOTE_CHANGE_DELETE: Delete a remote
+ * @OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS: Delete a remote, do nothing if the remote does not exist
*/
typedef enum {
OSTREE_REPO_REMOTE_CHANGE_ADD,
@@ -536,11 +540,15 @@ typedef OstreeRepoCommitFilterResult (*OstreeRepoCommitFilter) (OstreeRepo *r
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE: No special flags
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS: Do not process extended attributes
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES: Generate size information.
+ * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS: Canonicalize permissions for bare-user-only mode.
+ * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED: Emit an error if configured SELinux policy does not provide a label
*/
typedef enum {
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE = 0,
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS = (1 << 0),
- OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES = (1 << 1)
+ OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES = (1 << 1),
+ OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS = (1 << 2),
+ OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED = (1 << 3),
} OstreeRepoCommitModifierFlags;
/**
diff --git a/src/libotutil/ot-spawn-utils.h b/src/libostree/ostree-sepolicy-private.h
similarity index 55%
rename from src/libotutil/ot-spawn-utils.h
rename to src/libostree/ostree-sepolicy-private.h
index 76ea24e3..55d49eaf 100644
--- a/src/libotutil/ot-spawn-utils.h
+++ b/src/libostree/ostree-sepolicy-private.h
@@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
- * Copyright (C) 2011 Colin Walters .
+ * Copyright (C) 2017 Colin Walters
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -16,18 +16,26 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
- *
- * Author: Colin Walters
*/
#pragma once
-#include
+#include "ostree-types.h"
G_BEGIN_DECLS
-GThreadPool * ot_thread_pool_new_nproc (GFunc func,
- gpointer user_data);
-
+typedef struct {
+ gboolean initialized;
+} OstreeSepolicyFsCreatecon;
+
+void _ostree_sepolicy_fscreatecon_clear (OstreeSepolicyFsCreatecon *con);
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(OstreeSepolicyFsCreatecon, _ostree_sepolicy_fscreatecon_clear)
+
+gboolean _ostree_sepolicy_preparefscreatecon (OstreeSepolicyFsCreatecon *con,
+ OstreeSePolicy *self,
+ const char *path,
+ guint32 mode,
+ GError **error);
+
G_END_DECLS
diff --git a/src/libostree/ostree-sepolicy.c b/src/libostree/ostree-sepolicy.c
index fa264704..6063022c 100644
--- a/src/libostree/ostree-sepolicy.c
+++ b/src/libostree/ostree-sepolicy.c
@@ -28,6 +28,7 @@
#include "otutil.h"
#include "ostree-sepolicy.h"
+#include "ostree-sepolicy-private.h"
#include "ostree-bootloader-uboot.h"
#include "ostree-bootloader-syslinux.h"
@@ -42,6 +43,8 @@
struct OstreeSePolicy {
GObject parent;
+ int rootfs_dfd;
+ int rootfs_dfd_owned;
GFile *path;
gboolean runtime_enabled;
@@ -63,7 +66,8 @@ static void initable_iface_init (GInitableIface *initable_iface);
enum {
PROP_0,
- PROP_PATH
+ PROP_PATH,
+ PROP_ROOTFS_DFD
};
G_DEFINE_TYPE_WITH_CODE (OstreeSePolicy, ostree_sepolicy, G_TYPE_OBJECT,
@@ -75,6 +79,8 @@ ostree_sepolicy_finalize (GObject *object)
OstreeSePolicy *self = OSTREE_SEPOLICY (object);
g_clear_object (&self->path);
+ if (self->rootfs_dfd_owned != -1)
+ (void) close (self->rootfs_dfd_owned);
#ifdef HAVE_SELINUX
g_clear_object (&self->selinux_policy_root);
g_clear_pointer (&self->selinux_policy_name, g_free);
@@ -100,8 +106,25 @@ ostree_sepolicy_set_property(GObject *object,
switch (prop_id)
{
case PROP_PATH:
- /* Canonicalize */
- self->path = g_file_new_for_path (gs_file_get_path_cached (g_value_get_object (value)));
+ {
+ GFile *path = g_value_get_object (value);
+ if (path)
+ {
+ /* Canonicalize */
+ self->path = g_file_new_for_path (gs_file_get_path_cached (path));
+ g_assert_cmpint (self->rootfs_dfd, ==, -1);
+ }
+ }
+ break;
+ case PROP_ROOTFS_DFD:
+ {
+ int fd = g_value_get_int (value);
+ if (fd != -1)
+ {
+ g_assert (self->path == NULL);
+ self->rootfs_dfd = fd;
+ }
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -122,6 +145,9 @@ ostree_sepolicy_get_property(GObject *object,
case PROP_PATH:
g_value_set_object (value, self->path);
break;
+ case PROP_ROOTFS_DFD:
+ g_value_set_int (value, self->rootfs_dfd);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -133,7 +159,7 @@ ostree_sepolicy_constructed (GObject *object)
{
OstreeSePolicy *self = OSTREE_SEPOLICY (object);
- g_assert (self->path != NULL);
+ g_assert (self->path != NULL || self->rootfs_dfd != -1);
G_OBJECT_CLASS (ostree_sepolicy_parent_class)->constructed (object);
}
@@ -155,6 +181,13 @@ ostree_sepolicy_class_init (OstreeSePolicyClass *klass)
"",
G_TYPE_FILE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_ROOTFS_DFD,
+ g_param_spec_int ("rootfs-dfd",
+ "", "",
+ -1, G_MAXINT, -1,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
}
#ifdef HAVE_SELINUX
@@ -252,6 +285,7 @@ initable_init (GInitable *initable,
#ifdef HAVE_SELINUX
gboolean ret = FALSE;
OstreeSePolicy *self = OSTREE_SEPOLICY (initable);
+ g_autoptr(GFile) path = NULL;
g_autoptr(GFile) etc_selinux_dir = NULL;
g_autoptr(GFile) policy_config_path = NULL;
g_autoptr(GFile) policy_root = NULL;
@@ -262,11 +296,28 @@ initable_init (GInitable *initable,
const char *selinux_prefix = "SELINUX=";
const char *selinuxtype_prefix = "SELINUXTYPE=";
- etc_selinux_dir = g_file_resolve_relative_path (self->path, "etc/selinux");
+ /* TODO - use this below */
+ if (self->rootfs_dfd != -1)
+ path = ot_fdrel_to_gfile (self->rootfs_dfd, ".");
+ else if (self->path)
+ {
+ path = g_object_ref (self->path);
+#if 0
+ /* TODO - use this below */
+ if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (self->path), TRUE,
+ &self->rootfs_dfd_owned, error))
+ goto out;
+ self->rootfs_dfd = self->rootfs_dfd_owned;
+#endif
+ }
+ else
+ g_assert_not_reached ();
+
+ etc_selinux_dir = g_file_resolve_relative_path (path, "etc/selinux");
if (!g_file_query_exists (etc_selinux_dir, NULL))
{
g_object_unref (etc_selinux_dir);
- etc_selinux_dir = g_file_resolve_relative_path (self->path, "usr/etc/selinux");
+ etc_selinux_dir = g_file_resolve_relative_path (path, "usr/etc/selinux");
}
policy_config_path = g_file_get_child (etc_selinux_dir, "config");
@@ -367,6 +418,8 @@ initable_init (GInitable *initable,
static void
ostree_sepolicy_init (OstreeSePolicy *self)
{
+ self->rootfs_dfd = -1;
+ self->rootfs_dfd_owned = -1;
}
static void
@@ -378,6 +431,8 @@ initable_iface_init (GInitableIface *initable_iface)
/**
* ostree_sepolicy_new:
* @path: Path to a root directory
+ * @cancellable: Cancellable
+ * @error: Error
*
* Returns: (transfer full): An accessor object for SELinux policy in root located at @path
*/
@@ -389,6 +444,22 @@ ostree_sepolicy_new (GFile *path,
return g_initable_new (OSTREE_TYPE_SEPOLICY, cancellable, error, "path", path, NULL);
}
+/**
+ * ostree_sepolicy_new_at:
+ * @rootfs_dfd: Directory fd for rootfs (will not be cloned)
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Returns: (transfer full): An accessor object for SELinux policy in root located at @rootfs_dfd
+ */
+OstreeSePolicy*
+ostree_sepolicy_new_at (int rootfs_dfd,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return g_initable_new (OSTREE_TYPE_SEPOLICY, cancellable, error, "rootfs-dfd", rootfs_dfd, NULL);
+}
+
/**
* ostree_sepolicy_get_path:
* @self:
@@ -455,35 +526,34 @@ ostree_sepolicy_get_label (OstreeSePolicy *self,
GError **error)
{
#ifdef HAVE_SELINUX
- gboolean ret = FALSE;
- int res;
- char *con = NULL;
+ /* Early return if no policy */
+ if (!self->selinux_hnd)
+ return TRUE;
- if (self->selinux_hnd)
+ /* http://marc.info/?l=selinux&m=149082134430052&w=2
+ * https://github.com/ostreedev/ostree/pull/768
+ */
+ if (strcmp (relpath, "/proc") == 0)
+ relpath = "/mnt";
+
+ char *con = NULL;
+ int res = selabel_lookup_raw (self->selinux_hnd, &con, relpath, unix_mode);
+ if (res != 0)
{
- res = selabel_lookup_raw (self->selinux_hnd, &con, relpath, unix_mode);
- if (res != 0)
- {
- if (errno != ENOENT)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
- }
+ if (errno == ENOENT)
+ *out_label = NULL;
else
- {
- /* Ensure we consistently allocate with g_malloc */
- *out_label = g_strdup (con);
- freecon (con);
- }
+ return glnx_throw_errno (error);
+ }
+ else
+ {
+ /* Ensure we consistently allocate with g_malloc */
+ *out_label = g_strdup (con);
+ freecon (con);
}
- ret = TRUE;
- out:
- return ret;
-#else
- return TRUE;
#endif
+ return TRUE;
}
/**
@@ -621,6 +691,7 @@ ostree_sepolicy_setfscreatecon (OstreeSePolicy *self,
/**
* ostree_sepolicy_fscreatecon_cleanup:
+ * @unused: Not used, just in case you didn't infer that from the parameter name
*
* Cleanup function for ostree_sepolicy_setfscreatecon().
*/
@@ -631,3 +702,31 @@ ostree_sepolicy_fscreatecon_cleanup (void **unused)
setfscreatecon (NULL);
#endif
}
+
+/* Currently private copy of the older sepolicy/fscreatecon API with a nicer
+ * g_auto() cleanup. May be made public later.
+ */
+gboolean
+_ostree_sepolicy_preparefscreatecon (OstreeSepolicyFsCreatecon *con,
+ OstreeSePolicy *self,
+ const char *path,
+ guint32 mode,
+ GError **error)
+{
+ if (!self || ostree_sepolicy_get_name (self) == NULL)
+ return TRUE;
+
+ if (!ostree_sepolicy_setfscreatecon (self, path, mode, error))
+ return FALSE;
+
+ con->initialized = TRUE;
+ return TRUE;
+}
+
+void
+_ostree_sepolicy_fscreatecon_clear (OstreeSepolicyFsCreatecon *con)
+{
+ if (!con->initialized)
+ return;
+ ostree_sepolicy_fscreatecon_cleanup (NULL);
+}
diff --git a/src/libostree/ostree-sepolicy.h b/src/libostree/ostree-sepolicy.h
index d204953e..1c1a5786 100644
--- a/src/libostree/ostree-sepolicy.h
+++ b/src/libostree/ostree-sepolicy.h
@@ -38,6 +38,12 @@ OstreeSePolicy* ostree_sepolicy_new (GFile *path,
GCancellable *cancellable,
GError **error);
+_OSTREE_PUBLIC
+OstreeSePolicy* ostree_sepolicy_new_at (int rootfs_dfd,
+ GCancellable *cancellable,
+ GError **error);
+
+
_OSTREE_PUBLIC
GFile * ostree_sepolicy_get_path (OstreeSePolicy *self);
diff --git a/src/libostree/ostree-sysroot-cleanup.c b/src/libostree/ostree-sysroot-cleanup.c
index 2a78d2ce..022654c3 100644
--- a/src/libostree/ostree-sysroot-cleanup.c
+++ b/src/libostree/ostree-sysroot-cleanup.c
@@ -515,12 +515,7 @@ ostree_sysroot_cleanup (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- OstreeSysrootCleanupFlags flags;
-
- /* Do everything. */
- flags = OSTREE_SYSROOT_CLEANUP_ALL;
-
- return _ostree_sysroot_piecemeal_cleanup (self, flags, cancellable, error);
+ return _ostree_sysroot_cleanup_internal (self, TRUE, cancellable, error);
}
/**
@@ -537,55 +532,41 @@ ostree_sysroot_prepare_cleanup (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- OstreeSysrootCleanupFlags flags;
-
- /* Do everything EXCEPT pruning the repository. */
- flags = OSTREE_SYSROOT_CLEANUP_ALL & ~OSTREE_SYSROOT_CLEANUP_PRUNE_REPO;
-
- return _ostree_sysroot_piecemeal_cleanup (self, flags, cancellable, error);
+ return _ostree_sysroot_cleanup_internal (self, FALSE, cancellable, error);
}
gboolean
-_ostree_sysroot_piecemeal_cleanup (OstreeSysroot *self,
- OstreeSysrootCleanupFlags flags,
- GCancellable *cancellable,
- GError **error)
+_ostree_sysroot_cleanup_internal (OstreeSysroot *self,
+ gboolean do_prune_repo,
+ GCancellable *cancellable,
+ GError **error)
{
- gboolean ret = FALSE;
glnx_unref_object OstreeRepo *repo = NULL;
g_return_val_if_fail (OSTREE_IS_SYSROOT (self), FALSE);
g_return_val_if_fail (self->loaded, FALSE);
- if (flags & OSTREE_SYSROOT_CLEANUP_BOOTVERSIONS)
- {
- if (!cleanup_other_bootversions (self, cancellable, error))
- goto out;
- }
+ if (!cleanup_other_bootversions (self, cancellable, error))
+ return FALSE;
- if (flags & OSTREE_SYSROOT_CLEANUP_DEPLOYMENTS)
- {
- if (!cleanup_old_deployments (self, cancellable, error))
- goto out;
- }
+ if (!cleanup_old_deployments (self, cancellable, error))
+ return FALSE;
if (!ostree_sysroot_get_repo (self, &repo, cancellable, error))
- goto out;
-
+ return FALSE;
+
if (!generate_deployment_refs (self, repo,
self->bootversion,
self->subbootversion,
self->deployments,
cancellable, error))
- goto out;
-
- if (flags & OSTREE_SYSROOT_CLEANUP_PRUNE_REPO)
+ return FALSE;
+
+ if (do_prune_repo)
{
if (!prune_repo (repo, cancellable, error))
- goto out;
+ return FALSE;
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 1cfe6ab1..ed8c8bca 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -30,6 +30,7 @@
#endif
#include "ostree-sysroot-private.h"
+#include "ostree-sepolicy-private.h"
#include "ostree-deployment-private.h"
#include "ostree-core-private.h"
#include "ostree-linuxfsutil.h"
@@ -87,6 +88,15 @@ symlink_at_replace (const char *oldpath,
return ret;
}
+static GLnxFileCopyFlags
+sysroot_flags_to_copy_flags (GLnxFileCopyFlags defaults,
+ OstreeSysrootDebugFlags sysrootflags)
+{
+ if (sysrootflags & OSTREE_SYSROOT_DEBUG_NO_XATTRS)
+ defaults |= GLNX_FILE_COPY_NOXATTRS;
+ return defaults;
+}
+
/* Try a hardlink if we can, otherwise fall back to copying. Used
* right now for kernels/initramfs in /boot, where we can just
* hardlink if we're on the same partition.
@@ -96,6 +106,7 @@ hardlink_or_copy_at (int src_dfd,
const char *src_subpath,
int dest_dfd,
const char *dest_subpath,
+ OstreeSysrootDebugFlags flags,
GCancellable *cancellable,
GError **error)
{
@@ -105,7 +116,8 @@ hardlink_or_copy_at (int src_dfd,
{
if (errno == EMLINK || errno == EXDEV)
{
- return glnx_file_copy_at (src_dfd, src_subpath, NULL, dest_dfd, dest_subpath, 0,
+ return glnx_file_copy_at (src_dfd, src_subpath, NULL, dest_dfd, dest_subpath,
+ sysroot_flags_to_copy_flags (0, flags),
cancellable, error);
}
else
@@ -125,6 +137,7 @@ dirfd_copy_attributes_and_xattrs (int src_parent_dfd,
const char *src_name,
int src_dfd,
int dest_dfd,
+ OstreeSysrootDebugFlags flags,
GCancellable *cancellable,
GError **error)
{
@@ -135,13 +148,16 @@ dirfd_copy_attributes_and_xattrs (int src_parent_dfd,
/* Clone all xattrs first, so we get the SELinux security context
* right. This will allow other users access if they have ACLs, but
* oh well.
- */
- if (!glnx_dfd_name_get_all_xattrs (src_parent_dfd, src_name,
- &xattrs, cancellable, error))
- goto out;
- if (!glnx_fd_set_all_xattrs (dest_dfd, xattrs,
- cancellable, error))
- goto out;
+ */
+ if (!(flags & OSTREE_SYSROOT_DEBUG_NO_XATTRS))
+ {
+ if (!glnx_dfd_name_get_all_xattrs (src_parent_dfd, src_name,
+ &xattrs, cancellable, error))
+ goto out;
+ if (!glnx_fd_set_all_xattrs (dest_dfd, xattrs,
+ cancellable, error))
+ goto out;
+ }
if (fstat (src_dfd, &src_stbuf) != 0)
{
@@ -168,6 +184,7 @@ static gboolean
copy_dir_recurse (int src_parent_dfd,
int dest_parent_dfd,
const char *name,
+ OstreeSysrootDebugFlags flags,
GCancellable *cancellable,
GError **error)
{
@@ -180,16 +197,13 @@ copy_dir_recurse (int src_parent_dfd,
/* Create with mode 0700, we'll fchmod/fchown later */
if (mkdirat (dest_parent_dfd, name, 0700) != 0)
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+ return glnx_throw_errno (error);
if (!glnx_opendirat (dest_parent_dfd, name, TRUE, &dest_dfd, error))
return FALSE;
if (!dirfd_copy_attributes_and_xattrs (src_parent_dfd, name, src_dfd_iter.fd, dest_dfd,
- cancellable, error))
+ flags, cancellable, error))
return FALSE;
while (TRUE)
@@ -203,22 +217,19 @@ copy_dir_recurse (int src_parent_dfd,
if (fstatat (src_dfd_iter.fd, dent->d_name, &child_stbuf,
AT_SYMLINK_NOFOLLOW) != 0)
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+ return glnx_throw_errno (error);
if (S_ISDIR (child_stbuf.st_mode))
{
if (!copy_dir_recurse (src_dfd_iter.fd, dest_dfd, dent->d_name,
- cancellable, error))
+ flags, cancellable, error))
return FALSE;
}
else
{
if (!glnx_file_copy_at (src_dfd_iter.fd, dent->d_name, &child_stbuf,
dest_dfd, dent->d_name,
- GLNX_FILE_COPY_OVERWRITE,
+ sysroot_flags_to_copy_flags (GLNX_FILE_COPY_OVERWRITE, flags),
cancellable, error))
return FALSE;
}
@@ -233,6 +244,7 @@ ensure_directory_from_template (int orig_etc_fd,
int new_etc_fd,
const char *path,
int *out_dfd,
+ OstreeSysrootDebugFlags flags,
GCancellable *cancellable,
GError **error)
{
@@ -261,7 +273,7 @@ ensure_directory_from_template (int orig_etc_fd,
if (strcmp (parent_path, ".") != 0)
{
if (!ensure_directory_from_template (orig_etc_fd, modified_etc_fd, new_etc_fd,
- parent_path, NULL, cancellable, error))
+ parent_path, NULL, flags, cancellable, error))
goto out;
/* Loop */
@@ -285,7 +297,7 @@ ensure_directory_from_template (int orig_etc_fd,
goto out;
if (!dirfd_copy_attributes_and_xattrs (modified_etc_fd, path, src_dfd, target_dfd,
- cancellable, error))
+ flags, cancellable, error))
goto out;
ret = TRUE;
@@ -311,6 +323,7 @@ copy_modified_config_file (int orig_etc_fd,
int modified_etc_fd,
int new_etc_fd,
const char *path,
+ OstreeSysrootDebugFlags flags,
GCancellable *cancellable,
GError **error)
{
@@ -331,7 +344,7 @@ copy_modified_config_file (int orig_etc_fd,
g_autofree char *parent = g_path_get_dirname (path);
if (!ensure_directory_from_template (orig_etc_fd, modified_etc_fd, new_etc_fd,
- parent, &dest_parent_dfd, cancellable, error))
+ parent, &dest_parent_dfd, flags, cancellable, error))
goto out;
}
else
@@ -385,7 +398,7 @@ copy_modified_config_file (int orig_etc_fd,
if (S_ISDIR (modified_stbuf.st_mode))
{
- if (!copy_dir_recurse (modified_etc_fd, new_etc_fd, path,
+ if (!copy_dir_recurse (modified_etc_fd, new_etc_fd, path, flags,
cancellable, error))
goto out;
}
@@ -393,7 +406,7 @@ copy_modified_config_file (int orig_etc_fd,
{
if (!glnx_file_copy_at (modified_etc_fd, path, &modified_stbuf,
new_etc_fd, path,
- GLNX_FILE_COPY_OVERWRITE,
+ sysroot_flags_to_copy_flags (GLNX_FILE_COPY_OVERWRITE, flags),
cancellable, error))
goto out;
}
@@ -425,6 +438,7 @@ static gboolean
merge_etc_changes (GFile *orig_etc,
GFile *modified_etc,
GFile *new_etc,
+ OstreeSysrootDebugFlags flags,
GCancellable *cancellable,
GError **error)
{
@@ -495,7 +509,7 @@ merge_etc_changes (GFile *orig_etc,
g_assert (path);
if (!copy_modified_config_file (orig_etc_fd, modified_etc_fd, new_etc_fd, path,
- cancellable, error))
+ flags, cancellable, error))
goto out;
}
for (i = 0; i < added->len; i++)
@@ -506,7 +520,7 @@ merge_etc_changes (GFile *orig_etc,
g_assert (path);
if (!copy_modified_config_file (orig_etc_fd, modified_etc_fd, new_etc_fd, path,
- cancellable, error))
+ flags, cancellable, error))
goto out;
}
@@ -701,89 +715,54 @@ selinux_relabel_dir (OstreeSysroot *sysroot,
return ret;
}
-static gboolean
-selinux_relabel_file (OstreeSysroot *sysroot,
- OstreeSePolicy *sepolicy,
- GFile *path,
- const char *prefix,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- g_autoptr(GPtrArray) path_parts = g_ptr_array_new ();
- g_autoptr(GFileInfo) file_info = g_file_query_info (path, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, error);
- if (!file_info)
- goto out;
-
- g_ptr_array_add (path_parts, (char*)prefix);
- g_ptr_array_add (path_parts, (char*)g_file_info_get_name (file_info));
- if (!relabel_one_path (sysroot, sepolicy, path, file_info, path_parts,
- cancellable, error))
- {
- g_prefix_error (error, "Relabeling /%s/%s: ", prefix,
- g_file_info_get_name (file_info));
- goto out;
- }
-
- ret = TRUE;
- out:
- return ret;
-}
-
static gboolean
selinux_relabel_var_if_needed (OstreeSysroot *sysroot,
OstreeSePolicy *sepolicy,
- GFile *deployment_var_path,
+ int os_deploy_dfd,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
/* This is a bit of a hack; we should change the code at some
* point in the distant future to only create (and label) /var
* when doing a deployment.
*/
- g_autoptr(GFile) deployment_var_labeled =
- g_file_get_child (deployment_var_path, ".ostree-selabeled");
- g_autoptr(GFile) deployment_var_labeled_tmp =
- g_file_get_child (deployment_var_path, ".ostree-selabeled.tmp");
-
- if (!g_file_query_exists (deployment_var_labeled, NULL))
+ const char selabeled[] = "var/.ostree-selabeled";
+ gboolean deployment_var_labeled;
+
+ if (!ot_query_exists_at (os_deploy_dfd, selabeled, &deployment_var_labeled, error))
+ return FALSE;
+
+ if (!deployment_var_labeled)
{
ot_log_structured_print_id_v (OSTREE_VARRELABEL_ID,
"Relabeling /var (no stamp file '%s' found)",
- gs_file_get_path_cached (deployment_var_labeled));
+ selabeled);
+ g_autoptr(GFile) deployment_var_path = ot_fdrel_to_gfile (os_deploy_dfd, "var");
if (!selinux_relabel_dir (sysroot, sepolicy,
deployment_var_path, "var",
cancellable, error))
{
g_prefix_error (error, "Relabeling /var: ");
- goto out;
+ return FALSE;
}
- if (!g_file_replace_contents (deployment_var_labeled_tmp, "", 0, NULL, FALSE,
- G_FILE_CREATE_REPLACE_DESTINATION, NULL,
- cancellable, error))
- goto out;
-
- if (!selinux_relabel_file (sysroot, sepolicy,
- deployment_var_labeled_tmp, "var",
- cancellable, error))
- goto out;
+ { g_auto(OstreeSepolicyFsCreatecon) con = { 0, };
+ const char *selabeled_abspath = glnx_strjoina ("/", selabeled);
- if (rename (gs_file_get_path_cached (deployment_var_labeled_tmp),
- gs_file_get_path_cached (deployment_var_labeled)) < 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ if (!_ostree_sepolicy_preparefscreatecon (&con, sepolicy,
+ selabeled_abspath,
+ 0644, error))
+ return FALSE;
+
+ if (!glnx_file_replace_contents_at (os_deploy_dfd, selabeled, (guint8*)"", 0,
+ GLNX_FILE_REPLACE_DATASYNC_NEW,
+ cancellable, error))
+ return FALSE;
+ }
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -861,7 +840,7 @@ merge_configuration (OstreeSysroot *sysroot,
/* TODO - set out labels as we copy files */
g_assert (!etc_exists);
if (!copy_dir_recurse (deployment_usr_dfd, deployment_dfd, "etc",
- cancellable, error))
+ sysroot->debug_flags, cancellable, error))
goto out;
/* Here, we initialize SELinux policy from the /usr/etc inside
@@ -881,8 +860,8 @@ merge_configuration (OstreeSysroot *sysroot,
if (source_etc_path)
{
- if (!merge_etc_changes (source_etc_pristine_path, source_etc_path, deployment_etc_path,
- cancellable, error))
+ if (!merge_etc_changes (source_etc_pristine_path, source_etc_path, deployment_etc_path,
+ sysroot->debug_flags, cancellable, error))
goto out;
}
@@ -1070,20 +1049,13 @@ syncfs_dir_at (int dfd,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
glnx_fd_close int child_dfd = -1;
-
if (!glnx_opendirat (dfd, path, TRUE, &child_dfd, error))
- goto out;
+ return FALSE;
if (syncfs (child_dfd) != 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/* First, sync the root directory as well as /var and /boot which may
@@ -1095,16 +1067,11 @@ full_system_sync (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
-
if (syncfs (self->sysroot_fd) != 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
if (!syncfs_dir_at (self->sysroot_fd, "boot", cancellable, error))
- goto out;
+ return FALSE;
/* And now out of an excess of conservativism, we still invoke
* sync(). The advantage of still using `syncfs()` above is that we
@@ -1114,9 +1081,7 @@ full_system_sync (OstreeSysroot *self,
*/
sync ();
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -1126,43 +1091,36 @@ create_new_bootlinks (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- guint i;
- int old_subbootversion;
- int new_subbootversion;
glnx_fd_close int ostree_dfd = -1;
- glnx_fd_close int ostree_subbootdir_dfd = -1;
- g_autofree char *ostree_bootdir_name = NULL;
- g_autofree char *ostree_subbootdir_name = NULL;
-
if (!glnx_opendirat (self->sysroot_fd, "ostree", TRUE, &ostree_dfd, error))
- goto out;
-
- ostree_bootdir_name = g_strdup_printf ("boot.%d", bootversion);
+ return FALSE;
+ int old_subbootversion;
if (bootversion != self->bootversion)
{
if (!_ostree_sysroot_read_current_subbootversion (self, bootversion, &old_subbootversion,
cancellable, error))
- goto out;
+ return FALSE;
}
else
old_subbootversion = self->subbootversion;
- new_subbootversion = old_subbootversion == 0 ? 1 : 0;
+ int new_subbootversion = old_subbootversion == 0 ? 1 : 0;
/* Create the "subbootdir", which is a directory holding a symlink farm pointing to
* deployments per-osname.
*/
- ostree_subbootdir_name = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion);
+ g_autofree char *ostree_subbootdir_name = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion);
if (!glnx_shutil_rm_rf_at (ostree_dfd, ostree_subbootdir_name, cancellable, error))
- goto out;
+ return FALSE;
if (!glnx_shutil_mkdir_p_at (ostree_dfd, ostree_subbootdir_name, 0755, cancellable, error))
- goto out;
- if (!glnx_opendirat (ostree_dfd, ostree_subbootdir_name, FALSE, &ostree_subbootdir_dfd, error))
- goto out;
+ return FALSE;
- for (i = 0; i < new_deployments->len; i++)
+ glnx_fd_close int ostree_subbootdir_dfd = -1;
+ if (!glnx_opendirat (ostree_dfd, ostree_subbootdir_name, FALSE, &ostree_subbootdir_dfd, error))
+ return FALSE;
+
+ for (guint i = 0; i < new_deployments->len; i++)
{
OstreeDeployment *deployment = new_deployments->pdata[i];
g_autofree char *bootlink_parent = g_strconcat (ostree_deployment_get_osname (deployment),
@@ -1176,16 +1134,14 @@ create_new_bootlinks (OstreeSysroot *self,
ostree_deployment_get_deployserial (deployment));
if (!glnx_shutil_mkdir_p_at (ostree_subbootdir_dfd, bootlink_parent, 0755, cancellable, error))
- goto out;
+ return FALSE;
if (!symlink_at_replace (bootlink_target, ostree_subbootdir_dfd, bootlink_pathname,
cancellable, error))
- goto out;
+ return FALSE;
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -1195,37 +1151,28 @@ swap_bootlinks (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- int old_subbootversion, new_subbootversion;
glnx_fd_close int ostree_dfd = -1;
- g_autofree char *ostree_bootdir_name = NULL;
- g_autofree char *ostree_subbootdir_name = NULL;
-
if (!glnx_opendirat (self->sysroot_fd, "ostree", TRUE, &ostree_dfd, error))
- goto out;
-
- ostree_bootdir_name = g_strdup_printf ("boot.%d", bootversion);
+ return FALSE;
+ int old_subbootversion;
if (bootversion != self->bootversion)
{
if (!_ostree_sysroot_read_current_subbootversion (self, bootversion, &old_subbootversion,
cancellable, error))
- goto out;
+ return FALSE;
}
else
old_subbootversion = self->subbootversion;
- new_subbootversion = old_subbootversion == 0 ? 1 : 0;
-
- ostree_subbootdir_name = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion);
-
+ int new_subbootversion = old_subbootversion == 0 ? 1 : 0;
+ g_autofree char *ostree_bootdir_name = g_strdup_printf ("boot.%d", bootversion);
+ g_autofree char *ostree_subbootdir_name = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion);
if (!symlink_at_replace (ostree_subbootdir_name, ostree_dfd, ostree_bootdir_name,
cancellable, error))
- goto out;
-
- ret = TRUE;
- out:
- return ret;
+ return FALSE;
+
+ return TRUE;
}
static char *
@@ -1242,29 +1189,25 @@ parse_os_release (const char *contents,
const char *split)
{
g_autofree char **lines = g_strsplit (contents, split, -1);
- char **iter;
GHashTable *ret = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- for (iter = lines; *iter; iter++)
+ for (char **iter = lines; *iter; iter++)
{
g_autofree char *line = *iter;
- char *eq;
- const char *quotedval;
- char *val;
if (g_str_has_prefix (line, "#"))
continue;
-
- eq = strchr (line, '=');
+
+ char *eq = strchr (line, '=');
if (!eq)
continue;
-
+
*eq = '\0';
- quotedval = eq + 1;
- val = g_shell_unquote (quotedval, NULL);
+ const char *quotedval = eq + 1;
+ char *val = g_shell_unquote (quotedval, NULL);
if (!val)
continue;
-
+
g_hash_table_insert (ret, g_steal_pointer (&line), val);
}
@@ -1273,7 +1216,7 @@ parse_os_release (const char *contents,
/*
* install_deployment_kernel:
- *
+ *
* Write out an entry in /boot/loader/entries for @deployment.
*/
static gboolean
@@ -1287,76 +1230,55 @@ install_deployment_kernel (OstreeSysroot *sysroot,
GError **error)
{
- gboolean ret = FALSE;
- struct stat stbuf;
- const char *osname = ostree_deployment_get_osname (deployment);
- const char *bootcsum = ostree_deployment_get_bootcsum (deployment);
- g_autofree char *bootcsumdir = NULL;
- g_autofree char *bootconfdir = NULL;
- g_autofree char *bootconf_name = NULL;
- g_autofree char *dest_kernel_name = NULL;
- g_autofree char *dest_initramfs_name = NULL;
- g_autofree char *tree_kernel_name = NULL;
- g_autofree char *tree_initramfs_name = NULL;
- g_autofree char *deployment_dirpath = NULL;
+ OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (deployment);
+ g_autofree char *deployment_dirpath = ostree_sysroot_get_deployment_dirpath (sysroot, deployment);
glnx_fd_close int deployment_dfd = -1;
- glnx_fd_close int tree_boot_dfd = -1;
- glnx_fd_close int boot_dfd = -1;
- glnx_fd_close int bootcsum_dfd = -1;
- g_autofree char *contents = NULL;
- g_autofree char *deployment_version = NULL;
- g_autoptr(GHashTable) osrelease_values = NULL;
- g_autofree char *version_key = NULL;
- g_autofree char *ostree_kernel_arg = NULL;
- g_autofree char *options_key = NULL;
- GString *title_key;
- __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
- const char *val;
- OstreeBootconfigParser *bootconfig;
-
- bootconfig = ostree_deployment_get_bootconfig (deployment);
- deployment_dirpath = ostree_sysroot_get_deployment_dirpath (sysroot, deployment);
-
if (!glnx_opendirat (sysroot->sysroot_fd, deployment_dirpath, FALSE,
&deployment_dfd, error))
- goto out;
+ return FALSE;
+ glnx_fd_close int tree_boot_dfd = -1;
+ g_autofree char *tree_kernel_name = NULL;
+ g_autofree char *tree_initramfs_name = NULL;
if (!get_kernel_from_tree (deployment_dfd, &tree_boot_dfd,
&tree_kernel_name, &tree_initramfs_name,
cancellable, error))
- goto out;
+ return FALSE;
+ glnx_fd_close int boot_dfd = -1;
if (!glnx_opendirat (sysroot->sysroot_fd, "boot", TRUE, &boot_dfd, error))
- goto out;
+ return FALSE;
- bootcsumdir = g_strdup_printf ("ostree/%s-%s", osname, bootcsum);
- bootconfdir = g_strdup_printf ("loader.%d/entries", new_bootversion);
- bootconf_name = g_strdup_printf ("ostree-%s-%d.conf", osname,
+ const char *osname = ostree_deployment_get_osname (deployment);
+ const char *bootcsum = ostree_deployment_get_bootcsum (deployment);
+ g_autofree char *bootcsumdir = g_strdup_printf ("ostree/%s-%s", osname, bootcsum);
+ g_autofree char *bootconfdir = g_strdup_printf ("loader.%d/entries", new_bootversion);
+ g_autofree char *bootconf_name = g_strdup_printf ("ostree-%s-%d.conf", osname,
ostree_deployment_get_index (deployment));
-
if (!glnx_shutil_mkdir_p_at (boot_dfd, bootcsumdir, 0775, cancellable, error))
- goto out;
+ return FALSE;
+
+ glnx_fd_close int bootcsum_dfd = -1;
if (!glnx_opendirat (boot_dfd, bootcsumdir, TRUE, &bootcsum_dfd, error))
- goto out;
+ return FALSE;
if (!glnx_shutil_mkdir_p_at (boot_dfd, bootconfdir, 0775, cancellable, error))
- goto out;
-
- dest_kernel_name = remove_checksum_from_kernel_name (tree_kernel_name, bootcsum);
+ return FALSE;
+ g_autofree char *dest_kernel_name = remove_checksum_from_kernel_name (tree_kernel_name, bootcsum);
+ struct stat stbuf;
if (fstatat (bootcsum_dfd, dest_kernel_name, &stbuf, 0) != 0)
{
if (errno != ENOENT)
- {
- glnx_set_prefix_error_from_errno (error, "fstat %s", dest_kernel_name);
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "fstat %s", dest_kernel_name);
if (!hardlink_or_copy_at (tree_boot_dfd, tree_kernel_name,
bootcsum_dfd, dest_kernel_name,
+ sysroot->debug_flags,
cancellable, error))
- goto out;
+ return FALSE;
}
+ g_autofree char *dest_initramfs_name = NULL;
if (tree_initramfs_name)
{
dest_initramfs_name = remove_checksum_from_kernel_name (tree_initramfs_name, bootcsum);
@@ -1364,33 +1286,28 @@ install_deployment_kernel (OstreeSysroot *sysroot,
if (fstatat (bootcsum_dfd, dest_initramfs_name, &stbuf, 0) != 0)
{
if (errno != ENOENT)
- {
- glnx_set_prefix_error_from_errno (error, "fstat %s", dest_initramfs_name);
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "fstat %s", dest_initramfs_name);
if (!hardlink_or_copy_at (tree_boot_dfd, tree_initramfs_name,
bootcsum_dfd, dest_initramfs_name,
+ sysroot->debug_flags,
cancellable, error))
- goto out;
+ return FALSE;
}
}
+ g_autofree char *contents = NULL;
if (fstatat (deployment_dfd, "usr/lib/os-release", &stbuf, 0) != 0)
{
if (errno != ENOENT)
{
- glnx_set_error_from_errno (error);
- goto out;
+ return glnx_throw_errno (error);
}
else
{
contents = glnx_file_get_contents_utf8_at (deployment_dfd, "etc/os-release", NULL,
cancellable, error);
if (!contents)
- {
- g_prefix_error (error, "Reading /etc/os-release: ");
- goto out;
- }
+ return g_prefix_error (error, "Reading /etc/os-release: "), FALSE;
}
}
else
@@ -1398,26 +1315,18 @@ install_deployment_kernel (OstreeSysroot *sysroot,
contents = glnx_file_get_contents_utf8_at (deployment_dfd, "usr/lib/os-release", NULL,
cancellable, error);
if (!contents)
- {
- g_prefix_error (error, "Reading /usr/lib/os-release: ");
- goto out;
- }
+ return g_prefix_error (error, "Reading /usr/lib/os-release: "), FALSE;
}
- osrelease_values = parse_os_release (contents, "\n");
-
+ g_autoptr(GHashTable) osrelease_values = parse_os_release (contents, "\n");
/* title */
- val = g_hash_table_lookup (osrelease_values, "PRETTY_NAME");
+ const char *val = g_hash_table_lookup (osrelease_values, "PRETTY_NAME");
if (val == NULL)
val = g_hash_table_lookup (osrelease_values, "ID");
if (val == NULL)
- {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "No PRETTY_NAME or ID in /etc/os-release");
- goto out;
- }
-
+ return glnx_throw (error, "No PRETTY_NAME or ID in /etc/os-release");
+ g_autofree char *deployment_version = NULL;
if (repo)
{
/* Try extracting a version for this deployment. */
@@ -1439,7 +1348,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
/* XXX The SYSLINUX bootloader backend actually parses the title string
* (specifically, it looks for the substring "(ostree"), so further
* changes to the title format may require updating that backend. */
- title_key = g_string_new (val);
+ g_autoptr(GString) title_key = g_string_new (val);
if (deployment_version && *deployment_version)
{
g_string_append_c (title_key, ' ');
@@ -1457,14 +1366,11 @@ install_deployment_kernel (OstreeSysroot *sysroot,
}
g_string_append_c (title_key, ')');
ostree_bootconfig_parser_set (bootconfig, "title", title_key->str);
- g_string_free (title_key, TRUE);
- version_key = g_strdup_printf ("%d", n_deployments - ostree_deployment_get_index (deployment));
+ g_autofree char *version_key = g_strdup_printf ("%d", n_deployments - ostree_deployment_get_index (deployment));
ostree_bootconfig_parser_set (bootconfig, "version", version_key);
-
- { g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", dest_kernel_name, NULL);
- ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath);
- }
+ g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", dest_kernel_name, NULL);
+ ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath);
if (dest_initramfs_name)
{
@@ -1474,29 +1380,25 @@ install_deployment_kernel (OstreeSysroot *sysroot,
val = ostree_bootconfig_parser_get (bootconfig, "options");
- ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d",
+ g_autofree char *ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d",
new_bootversion, osname, bootcsum,
ostree_deployment_get_bootserial (deployment));
- kargs = _ostree_kernel_args_from_string (val);
+ __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = _ostree_kernel_args_from_string (val);
_ostree_kernel_args_replace_take (kargs, ostree_kernel_arg);
ostree_kernel_arg = NULL;
- options_key = _ostree_kernel_args_to_string (kargs);
+ g_autofree char *options_key = _ostree_kernel_args_to_string (kargs);
ostree_bootconfig_parser_set (bootconfig, "options", options_key);
-
- { glnx_fd_close int bootconf_dfd = -1;
- if (!glnx_opendirat (boot_dfd, bootconfdir, TRUE, &bootconf_dfd, error))
- goto out;
+ glnx_fd_close int bootconf_dfd = -1;
+ if (!glnx_opendirat (boot_dfd, bootconfdir, TRUE, &bootconf_dfd, error))
+ return FALSE;
- if (!ostree_bootconfig_parser_write_at (ostree_deployment_get_bootconfig (deployment),
- bootconf_dfd, bootconf_name,
- cancellable, error))
- goto out;
- }
+ if (!ostree_bootconfig_parser_write_at (ostree_deployment_get_bootconfig (deployment),
+ bootconf_dfd, bootconf_name,
+ cancellable, error))
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -1506,23 +1408,18 @@ prepare_new_bootloader_link (OstreeSysroot *sysroot,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autofree char *new_target = NULL;
-
g_assert ((current_bootversion == 0 && new_bootversion == 1) ||
(current_bootversion == 1 && new_bootversion == 0));
- new_target = g_strdup_printf ("loader.%d", new_bootversion);
+ g_autofree char *new_target = g_strdup_printf ("loader.%d", new_bootversion);
/* We shouldn't actually need to replace but it's easier to reuse
that code */
if (!symlink_at_replace (new_target, sysroot->sysroot_fd, "boot/loader.tmp",
cancellable, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -1532,7 +1429,6 @@ swap_bootloader (OstreeSysroot *sysroot,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
glnx_fd_close int boot_dfd = -1;
int res;
@@ -1540,7 +1436,7 @@ swap_bootloader (OstreeSysroot *sysroot,
(current_bootversion == 1 && new_bootversion == 0));
if (!glnx_opendirat (sysroot->sysroot_fd, "boot", TRUE, &boot_dfd, error))
- goto out;
+ return FALSE;
/* The symlink was already written, and we used syncfs() to ensure
* its data is in place. Renaming now should give us atomic semantics;
@@ -1550,10 +1446,7 @@ swap_bootloader (OstreeSysroot *sysroot,
res = renameat (boot_dfd, "loader.tmp", boot_dfd, "loader");
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
/* Now we explicitly fsync this directory, even though it
* isn't required for atomicity, for two reasons:
@@ -1565,14 +1458,9 @@ swap_bootloader (OstreeSysroot *sysroot,
* admin by going back to the previous session.
*/
if (fsync (boot_dfd) != 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno (error);
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static GHashTable *
@@ -1657,10 +1545,7 @@ cleanup_legacy_current_symlinks (OstreeSysroot *self,
if (unlinkat (self->sysroot_fd, buf->str, 0) < 0)
{
if (errno != ENOENT)
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+ return glnx_throw_errno (error);
}
}
@@ -1720,8 +1605,8 @@ is_ro_mount (const char *path)
* @cancellable: Cancellable
* @error: Error
*
- * Assuming @new_deployments have already been deployed in place on
- * disk, atomically update bootloader configuration.
+ * Older version of ostree_sysroot_write_deployments_with_options(). This
+ * version will perform post-deployment cleanup by default.
*/
gboolean
ostree_sysroot_write_deployments (OstreeSysroot *self,
@@ -1729,17 +1614,32 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- return _ostree_sysroot_write_deployments_internal (self, new_deployments,
- OSTREE_SYSROOT_CLEANUP_ALL,
- cancellable, error);
+ OstreeSysrootWriteDeploymentsOpts opts = { .do_postclean = TRUE };
+ return ostree_sysroot_write_deployments_with_options (self, new_deployments, &opts,
+ cancellable, error);
}
+/**
+ * ostree_sysroot_write_deployments_with_options:
+ * @self: Sysroot
+ * @new_deployments: (element-type OstreeDeployment): List of new deployments
+ * @opts: Options
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Assuming @new_deployments have already been deployed in place on disk via
+ * ostree_sysroot_deploy_tree(), atomically update bootloader configuration. By
+ * default, no post-transaction cleanup will be performed. You should invoke
+ * ostree_sysroot_cleanup() at some point after the transaction, or specify
+ * `do_postclean` in @opts. Skipping the post-transaction cleanup is useful
+ * if for example you want to control pruning of the repository.
+ */
gboolean
-_ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
- GPtrArray *new_deployments,
- OstreeSysrootCleanupFlags cleanup_flags,
- GCancellable *cancellable,
- GError **error)
+ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
+ GPtrArray *new_deployments,
+ OstreeSysrootWriteDeploymentsOpts *opts,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
guint i;
@@ -1965,11 +1865,13 @@ _ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
/* And finally, cleanup of any leftover data.
*/
- if (!_ostree_sysroot_piecemeal_cleanup (self, cleanup_flags,
- cancellable, error))
+ if (opts->do_postclean)
{
- g_prefix_error (error, "Performing final cleanup: ");
- goto out;
+ if (!ostree_sysroot_cleanup (self, cancellable, error))
+ {
+ g_prefix_error (error, "Performing final cleanup: ");
+ goto out;
+ }
}
ret = TRUE;
@@ -1997,18 +1899,17 @@ allocate_deployserial (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
guint i;
int new_deployserial = 0;
- g_autoptr(GFile) osdir = NULL;
g_autoptr(GPtrArray) tmp_current_deployments =
g_ptr_array_new_with_free_func (g_object_unref);
- osdir = ot_gfile_get_child_build_path (self->path, "ostree/deploy", osname, NULL);
+ const char *osdir_name = glnx_strjoina ("ostree/deploy/", osname);
+ g_autoptr(GFile) osdir = g_file_resolve_relative_path (self->path, osdir_name);
if (!_ostree_sysroot_list_deployment_dirs_for_os (osdir, tmp_current_deployments,
cancellable, error))
- goto out;
+ return FALSE;
for (i = 0; i < tmp_current_deployments->len; i++)
{
@@ -2020,12 +1921,10 @@ allocate_deployserial (OstreeSysroot *self,
new_deployserial = MAX(new_deployserial, ostree_deployment_get_deployserial (deployment)+1);
}
- ret = TRUE;
*out_deployserial = new_deployserial;
- out:
- return ret;
+ return TRUE;
}
-
+
/**
* ostree_sysroot_deploy_tree:
* @self: Sysroot
@@ -2052,122 +1951,98 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- gint new_deployserial;
- glnx_unref_object OstreeDeployment *new_deployment = NULL;
- glnx_unref_object OstreeDeployment *merge_deployment = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
- g_autoptr(GFile) osdeploydir = NULL;
- g_autoptr(GFile) deployment_var = NULL;
- glnx_fd_close int tree_boot_dfd = -1;
- g_autofree char *tree_kernel_path = NULL;
- g_autofree char *tree_initramfs_path = NULL;
- glnx_fd_close int deployment_dfd = -1;
- glnx_unref_object OstreeSePolicy *sepolicy = NULL;
- g_autofree char *new_bootcsum = NULL;
- glnx_unref_object OstreeBootconfigParser *bootconfig = NULL;
-
g_return_val_if_fail (osname != NULL || self->booted_deployment != NULL, FALSE);
if (osname == NULL)
osname = ostree_deployment_get_osname (self->booted_deployment);
- osdeploydir = ot_gfile_get_child_build_path (self->path, "ostree", "deploy", osname, NULL);
- if (!g_file_query_exists (osdeploydir, NULL))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
- "No OS named \"%s\" known", osname);
- goto out;
- }
-
- deployment_var = g_file_get_child (osdeploydir, "var");
+ const char *osdeploypath = glnx_strjoina ("ostree/deploy/", osname);
+ glnx_fd_close int os_deploy_dfd = -1;
+ if (!glnx_opendirat (self->sysroot_fd, osdeploypath, TRUE, &os_deploy_dfd, error))
+ return FALSE;
+ glnx_unref_object OstreeRepo *repo = NULL;
if (!ostree_sysroot_get_repo (self, &repo, cancellable, error))
- goto out;
+ return FALSE;
+ glnx_unref_object OstreeDeployment *merge_deployment = NULL;
if (provided_merge_deployment != NULL)
merge_deployment = g_object_ref (provided_merge_deployment);
+ gint new_deployserial;
if (!allocate_deployserial (self, osname, revision, &new_deployserial,
cancellable, error))
- goto out;
+ return FALSE;
- new_deployment = ostree_deployment_new (0, osname, revision, new_deployserial,
- new_bootcsum, -1);
+ g_autofree char *new_bootcsum = NULL;
+ glnx_unref_object OstreeDeployment *new_deployment =
+ ostree_deployment_new (0, osname, revision, new_deployserial,
+ new_bootcsum, -1);
ostree_deployment_set_origin (new_deployment, origin);
/* Check out the userspace tree onto the filesystem */
+ glnx_fd_close int deployment_dfd = -1;
if (!checkout_deployment_tree (self, repo, new_deployment, &deployment_dfd,
cancellable, error))
{
g_prefix_error (error, "Checking out tree: ");
- goto out;
+ return FALSE;
}
+ glnx_fd_close int tree_boot_dfd = -1;
+ g_autofree char *tree_kernel_path = NULL;
+ g_autofree char *tree_initramfs_path = NULL;
if (!get_kernel_from_tree (deployment_dfd, &tree_boot_dfd,
&tree_kernel_path, &tree_initramfs_path,
cancellable, error))
- goto out;
-
+ return FALSE;
+
if (tree_initramfs_path != NULL)
{
if (!checksum_from_kernel_src (tree_initramfs_path, &new_bootcsum, error))
- goto out;
+ return FALSE;
}
else
{
if (!checksum_from_kernel_src (tree_kernel_path, &new_bootcsum, error))
- goto out;
+ return FALSE;
}
-
+
_ostree_deployment_set_bootcsum (new_deployment, new_bootcsum);
/* Create an empty boot configuration; we will merge things into
* it as we go.
*/
- bootconfig = ostree_bootconfig_parser_new ();
+ glnx_unref_object OstreeBootconfigParser *bootconfig = ostree_bootconfig_parser_new ();
ostree_deployment_set_bootconfig (new_deployment, bootconfig);
+ glnx_unref_object OstreeSePolicy *sepolicy = NULL;
if (!merge_configuration (self, merge_deployment, new_deployment,
deployment_dfd,
&sepolicy,
cancellable, error))
{
g_prefix_error (error, "During /etc merge: ");
- goto out;
+ return FALSE;
}
- g_clear_object (&self->sepolicy);
- self->sepolicy = g_object_ref (sepolicy);
-
- if (!selinux_relabel_var_if_needed (self, sepolicy, deployment_var,
+ if (!selinux_relabel_var_if_needed (self, sepolicy, os_deploy_dfd,
cancellable, error))
- goto out;
+ return FALSE;
if (!(self->debug_flags & OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS))
{
if (!ostree_sysroot_deployment_set_mutable (self, new_deployment, FALSE,
cancellable, error))
- goto out;
+ return FALSE;
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-variable"
- { ostree_cleanup_sepolicy_fscreatecon gpointer dummy = NULL;
-#pragma GCC diagnostic pop
+ { g_auto(OstreeSepolicyFsCreatecon) con = { 0, };
- /* Explicitly override the label for the origin file to ensure
- * it's system_conf_t.
- */
- if (self->sepolicy != NULL
- && ostree_sepolicy_get_name (self->sepolicy) != NULL)
- {
- if (!ostree_sepolicy_setfscreatecon (self->sepolicy,
- "/etc/ostree/remotes.d/dummy.conf",
- 0644,
- error))
- goto out;
- }
+ if (!_ostree_sepolicy_preparefscreatecon (&con, sepolicy,
+ "/etc/ostree/remotes.d/dummy.conf",
+ 0644, error))
+ return FALSE;
/* Don't fsync here, as we assume that's all done in
* ostree_sysroot_write_deployments().
@@ -2177,7 +2052,7 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
cancellable, error))
{
g_prefix_error (error, "Writing out origin file: ");
- goto out;
+ return FALSE;
}
}
@@ -2195,10 +2070,8 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
ostree_bootconfig_parser_set (bootconfig, "options", new_options);
}
- ret = TRUE;
ot_transfer_out_value (out_new_deployment, &new_deployment);
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2219,7 +2092,6 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
guint i;
g_autoptr(GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
glnx_unref_object OstreeDeployment *new_deployment = NULL;
@@ -2246,11 +2118,9 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
if (!ostree_sysroot_write_deployments (self, new_deployments,
cancellable, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
/**
@@ -2258,6 +2128,7 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self,
* @self: Sysroot
* @deployment: A deployment
* @is_mutable: Whether or not deployment's files can be changed
+ * @cancellable: Cancellable
* @error: Error
*
* By default, deployment directories are not mutable. This function
@@ -2271,20 +2142,17 @@ ostree_sysroot_deployment_set_mutable (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment);
- glnx_fd_close int fd = -1;
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
+ g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment);
+ glnx_fd_close int fd = -1;
if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE, &fd, error))
- goto out;
+ return FALSE;
if (!_ostree_linuxfs_fd_alter_immutable_flag (fd, !is_mutable, cancellable, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
diff --git a/src/libostree/ostree-sysroot-private.h b/src/libostree/ostree-sysroot-private.h
index b2def7fa..4bc7802b 100644
--- a/src/libostree/ostree-sysroot-private.h
+++ b/src/libostree/ostree-sysroot-private.h
@@ -30,7 +30,9 @@ G_BEGIN_DECLS
typedef enum {
/* Don't flag deployments as immutable. */
- OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS = 1 << 0
+ OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS = 1 << 0,
+ /* See https://github.com/ostreedev/ostree/pull/759 */
+ OSTREE_SYSROOT_DEBUG_NO_XATTRS = 1 << 1,
} OstreeSysrootDebugFlags;
@@ -47,8 +49,6 @@ struct OstreeSysroot {
gboolean loaded;
- OstreeSePolicy *sepolicy;
-
GPtrArray *deployments;
int bootversion;
int subbootversion;
@@ -109,22 +109,9 @@ gboolean _ostree_sysroot_query_bootloader (OstreeSysroot *sysroot,
gboolean _ostree_sysroot_bump_mtime (OstreeSysroot *sysroot,
GError **error);
-typedef enum {
- OSTREE_SYSROOT_CLEANUP_BOOTVERSIONS = 1 << 0,
- OSTREE_SYSROOT_CLEANUP_DEPLOYMENTS = 1 << 1,
- OSTREE_SYSROOT_CLEANUP_PRUNE_REPO = 1 << 2,
- OSTREE_SYSROOT_CLEANUP_ALL = 0xffff
-} OstreeSysrootCleanupFlags;
-
-gboolean _ostree_sysroot_piecemeal_cleanup (OstreeSysroot *sysroot,
- OstreeSysrootCleanupFlags flags,
- GCancellable *cancellable,
- GError **error);
-
-gboolean _ostree_sysroot_write_deployments_internal (OstreeSysroot *self,
- GPtrArray *new_deployments,
- OstreeSysrootCleanupFlags cleanup_flags,
- GCancellable *cancellable,
- GError **error);
+gboolean _ostree_sysroot_cleanup_internal (OstreeSysroot *sysroot,
+ gboolean prune_repo,
+ GCancellable *cancellable,
+ GError **error);
G_END_DECLS
diff --git a/src/libostree/ostree-sysroot-upgrader.c b/src/libostree/ostree-sysroot-upgrader.c
index 232f8435..4e7c8bf3 100644
--- a/src/libostree/ostree-sysroot-upgrader.c
+++ b/src/libostree/ostree-sysroot-upgrader.c
@@ -293,6 +293,8 @@ ostree_sysroot_upgrader_init (OstreeSysrootUpgrader *self)
/**
* ostree_sysroot_upgrader_new:
* @sysroot: An #OstreeSysroot
+ * @cancellable: Cancellable
+ * @error: Error
*
* Returns: (transfer full): An upgrader
*/
@@ -309,6 +311,8 @@ ostree_sysroot_upgrader_new (OstreeSysroot *sysroot,
* ostree_sysroot_upgrader_new_for_os:
* @sysroot: An #OstreeSysroot
* @osname: (allow-none): Operating system name
+ * @cancellable: Cancellable
+ * @error: Error
*
* Returns: (transfer full): An upgrader
*/
@@ -327,6 +331,8 @@ ostree_sysroot_upgrader_new_for_os (OstreeSysroot *sysroot,
* @sysroot: An #OstreeSysroot
* @osname: (allow-none): Operating system name
* @flags: Flags
+ * @cancellable: Cancellable
+ * @error: Error
*
* Returns: (transfer full): An upgrader
*/
@@ -514,6 +520,14 @@ ostree_sysroot_upgrader_pull (OstreeSysrootUpgrader *self,
/**
* ostree_sysroot_upgrader_pull_one_dir:
+ * @self: Upgrader
+ * @dir_to_pull: Subdirectory path (should include a leading /)
+ * @flags: Flags controlling pull behavior
+ * @upgrader_flags: Flags controlling upgrader behavior
+ * @progress: (allow-none): Progress
+ * @out_changed: (out): Whether or not the origin changed
+ * @cancellable: Cancellable
+ * @error: Error
*
* Like ostree_sysroot_upgrader_pull(), but allows retrieving just a
* subpath of the tree. This can be used to download metadata files
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
index f50e34bd..bdf7376b 100644
--- a/src/libostree/ostree-sysroot.c
+++ b/src/libostree/ostree-sysroot.c
@@ -21,10 +21,12 @@
#include "config.h"
#include "otutil.h"
+#include
#include
#include
#include "ostree-core-private.h"
+#include "ostree-sepolicy-private.h"
#include "ostree-sysroot-private.h"
#include "ostree-deployment-private.h"
#include "ostree-bootloader-uboot.h"
@@ -70,7 +72,6 @@ ostree_sysroot_finalize (GObject *object)
OstreeSysroot *self = OSTREE_SYSROOT (object);
g_clear_object (&self->path);
- g_clear_object (&self->sepolicy);
g_clear_object (&self->repo);
g_clear_pointer (&self->deployments, g_ptr_array_unref);
g_clear_object (&self->booted_deployment);
@@ -160,9 +161,10 @@ ostree_sysroot_init (OstreeSysroot *self)
{
const GDebugKey keys[] = {
{ "mutable-deployments", OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS },
+ { "no-xattrs", OSTREE_SYSROOT_DEBUG_NO_XATTRS },
};
- self->debug_flags = g_parse_debug_string (g_getenv("OSTREE_SYSROOT_DEBUG"),
+ self->debug_flags = g_parse_debug_string (g_getenv ("OSTREE_SYSROOT_DEBUG"),
keys, G_N_ELEMENTS (keys));
self->sysroot_fd = -1;
@@ -1268,12 +1270,13 @@ ostree_sysroot_get_merge_deployment (OstreeSysroot *self,
/**
* ostree_sysroot_origin_new_from_refspec:
+ * @self: Sysroot
* @refspec: A refspec
*
* Returns: (transfer full): A new config file which sets @refspec as an origin
*/
GKeyFile *
-ostree_sysroot_origin_new_from_refspec (OstreeSysroot *sysroot,
+ostree_sysroot_origin_new_from_refspec (OstreeSysroot *self,
const char *refspec)
{
GKeyFile *ret = g_key_file_new ();
@@ -1551,6 +1554,7 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot,
g_autoptr(GPtrArray) deployments = NULL;
g_autoptr(GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref);
const gboolean postclean = (flags & OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN) == 0;
+ OstreeSysrootWriteDeploymentsOpts write_opts = { .do_postclean = postclean };
gboolean retain = (flags & OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN) > 0;
const gboolean make_default = !((flags & OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT) > 0);
gboolean added_new = FALSE;
@@ -1601,9 +1605,8 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot,
added_new = TRUE;
}
- if (!_ostree_sysroot_write_deployments_internal (sysroot, new_deployments,
- postclean ? OSTREE_SYSROOT_CLEANUP_ALL : 0,
- cancellable, error))
+ if (!ostree_sysroot_write_deployments_with_options (sysroot, new_deployments, &write_opts,
+ cancellable, error))
goto out;
ret = TRUE;
@@ -1688,6 +1691,7 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self,
GError **error)
{
gboolean ret = FALSE;
+ glnx_unref_object OstreeSePolicy *sepolicy = NULL;
OstreeDeploymentUnlockedState current_unlocked =
ostree_deployment_get_unlocked (deployment);
glnx_unref_object OstreeDeployment *deployment_clone =
@@ -1735,6 +1739,10 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self,
if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE, &deployment_dfd, error))
goto out;
+ sepolicy = ostree_sepolicy_new_at (deployment_dfd, cancellable, error);
+ if (!sepolicy)
+ goto out;
+
switch (unlocked_state)
{
case OSTREE_DEPLOYMENT_UNLOCKED_NONE:
@@ -1762,8 +1770,16 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self,
const char *development_ovl_upper;
const char *development_ovl_work;
- if (!glnx_mkdtempat (AT_FDCWD, development_ovldir, 0700, error))
- goto out;
+ /* Ensure that the directory is created with the same label as `/usr` */
+ { g_auto(OstreeSepolicyFsCreatecon) con = { 0, };
+
+ if (!_ostree_sepolicy_preparefscreatecon (&con, sepolicy,
+ "/usr", 0755, error))
+ goto out;
+
+ if (!glnx_mkdtempat (AT_FDCWD, development_ovldir, 0755, error))
+ goto out;
+ }
development_ovl_upper = glnx_strjoina (development_ovldir, "/upper");
if (!glnx_shutil_mkdir_p_at (AT_FDCWD, development_ovl_upper, 0755, cancellable, error))
diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h
index 1e98cc10..09614b55 100644
--- a/src/libostree/ostree-sysroot.h
+++ b/src/libostree/ostree-sysroot.h
@@ -145,6 +145,20 @@ gboolean ostree_sysroot_write_deployments (OstreeSysroot *self,
GCancellable *cancellable,
GError **error);
+typedef struct {
+ gboolean do_postclean;
+ gboolean unused_bools[7];
+ int unused_ints[7];
+ gpointer unused_ptrs[7];
+} OstreeSysrootWriteDeploymentsOpts;
+
+_OSTREE_PUBLIC
+gboolean ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
+ GPtrArray *new_deployments,
+ OstreeSysrootWriteDeploymentsOpts *opts,
+ GCancellable *cancellable,
+ GError **error);
+
_OSTREE_PUBLIC
gboolean ostree_sysroot_deploy_tree (OstreeSysroot *self,
const char *osname,
diff --git a/src/libostree/ostree-version.h b/src/libostree/ostree-version.h
new file mode 100644
index 00000000..4d402126
--- /dev/null
+++ b/src/libostree/ostree-version.h
@@ -0,0 +1,82 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2017 Georges Basile Stavracas Neto
+ *
+ * This program 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 licence 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.
+ */
+
+#pragma once
+
+/**
+ * SECTION:ostree-version
+ * @short_description: ostree version checking
+ *
+ * ostree provides macros to check the version of the library
+ * at compile-time
+ */
+
+/**
+ * OSTREE_YEAR_VERSION:
+ *
+ * ostree year version component (e.g. 2017 if %OSTREE_VERSION is 2017.2)
+ */
+#define OSTREE_YEAR_VERSION (2017)
+
+/**
+ * OSTREE_RELEASE_VERSION:
+ *
+ * ostree release version component (e.g. 2 if %OSTREE_VERSION is 2017.2)
+ */
+#define OSTREE_RELEASE_VERSION (4)
+
+/**
+ * OSTREE_VERSION
+ *
+ * ostree version.
+ */
+#define OSTREE_VERSION (2017.4)
+
+/**
+ * OSTREE_VERSION_S:
+ *
+ * ostree version, encoded as a string, useful for printing and
+ * concatenation.
+ */
+#define OSTREE_VERSION_S "2017.4"
+
+#define OSTREE_ENCODE_VERSION(year,release) \
+ ((year) << 16 | (release))
+
+/**
+ * OSTREE_VERSION_HEX:
+ *
+ * ostree version, encoded as an hexadecimal number, useful for
+ * integer comparisons.
+ */
+#define OSTREE_VERSION_HEX \
+ (OSTREE_ENCODE_VERSION (OSTREE_YEAR_VERSION, OSTREE_RELEASE_VERSION))
+
+/**
+ * OSTREE_CHECK_VERSION:
+ * @year: required year version
+ * @release: required release version
+ *
+ * Compile-time version checking. Evaluates to %TRUE if the version
+ * of ostree is equal or greater than the required one.
+ */
+#define OSTREE_CHECK_VERSION(year,release) \
+ (OSTREE_YEAR_VERSION > (year) || \
+ (OSTREE_YEAR_VERSION == (year) && OSTREE_RELEASE_VERSION >= (release)))
diff --git a/src/libostree/ostree-version.h.in b/src/libostree/ostree-version.h.in
new file mode 100644
index 00000000..7d775cc2
--- /dev/null
+++ b/src/libostree/ostree-version.h.in
@@ -0,0 +1,82 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2017 Georges Basile Stavracas Neto
+ *
+ * This program 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 licence 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.
+ */
+
+#pragma once
+
+/**
+ * SECTION:ostree-version
+ * @short_description: ostree version checking
+ *
+ * ostree provides macros to check the version of the library
+ * at compile-time
+ */
+
+/**
+ * OSTREE_YEAR_VERSION:
+ *
+ * ostree year version component (e.g. 2017 if %OSTREE_VERSION is 2017.2)
+ */
+#define OSTREE_YEAR_VERSION (@YEAR_VERSION@)
+
+/**
+ * OSTREE_RELEASE_VERSION:
+ *
+ * ostree release version component (e.g. 2 if %OSTREE_VERSION is 2017.2)
+ */
+#define OSTREE_RELEASE_VERSION (@RELEASE_VERSION@)
+
+/**
+ * OSTREE_VERSION
+ *
+ * ostree version.
+ */
+#define OSTREE_VERSION (@VERSION@)
+
+/**
+ * OSTREE_VERSION_S:
+ *
+ * ostree version, encoded as a string, useful for printing and
+ * concatenation.
+ */
+#define OSTREE_VERSION_S "@VERSION@"
+
+#define OSTREE_ENCODE_VERSION(year,release) \
+ ((year) << 16 | (release))
+
+/**
+ * OSTREE_VERSION_HEX:
+ *
+ * ostree version, encoded as an hexadecimal number, useful for
+ * integer comparisons.
+ */
+#define OSTREE_VERSION_HEX \
+ (OSTREE_ENCODE_VERSION (OSTREE_YEAR_VERSION, OSTREE_RELEASE_VERSION))
+
+/**
+ * OSTREE_CHECK_VERSION:
+ * @year: required year version
+ * @release: required release version
+ *
+ * Compile-time version checking. Evaluates to %TRUE if the version
+ * of ostree is equal or greater than the required one.
+ */
+#define OSTREE_CHECK_VERSION(year,release) \
+ (OSTREE_YEAR_VERSION > (year) || \
+ (OSTREE_YEAR_VERSION == (year) && OSTREE_RELEASE_VERSION >= (release)))
diff --git a/src/libostree/ostree.h b/src/libostree/ostree.h
index 9846a7e3..eb4ed8d3 100644
--- a/src/libostree/ostree.h
+++ b/src/libostree/ostree.h
@@ -33,3 +33,4 @@
#include
#include
+#include
diff --git a/src/libotutil/ot-checksum-instream.c b/src/libotutil/ot-checksum-instream.c
new file mode 100644
index 00000000..686554df
--- /dev/null
+++ b/src/libotutil/ot-checksum-instream.c
@@ -0,0 +1,195 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2017 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 "config.h"
+
+#include "ot-checksum-instream.h"
+#include "ot-checksum-utils.h"
+
+#ifdef HAVE_OPENSSL
+#include
+#endif
+
+G_DEFINE_TYPE (OtChecksumInstream, ot_checksum_instream, G_TYPE_FILTER_INPUT_STREAM)
+
+struct _OtChecksumInstreamPrivate {
+#ifdef HAVE_OPENSSL
+ EVP_MD_CTX *checksum;
+#else
+ GChecksumType checksum_type;
+ GChecksum *checksum;
+#endif
+};
+
+static gssize ot_checksum_instream_read (GInputStream *stream,
+ void *buffer,
+ gsize count,
+ GCancellable *cancellable,
+ GError **error);
+
+static void
+ot_checksum_instream_finalize (GObject *object)
+{
+ OtChecksumInstream *self = (OtChecksumInstream*)object;
+
+#ifdef HAVE_OPENSSL
+ EVP_MD_CTX_destroy (self->priv->checksum);
+#else
+ g_checksum_free (self->priv->checksum);
+#endif
+
+ G_OBJECT_CLASS (ot_checksum_instream_parent_class)->finalize (object);
+}
+
+static void
+ot_checksum_instream_class_init (OtChecksumInstreamClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (OtChecksumInstreamPrivate));
+
+ object_class->finalize = ot_checksum_instream_finalize;
+ stream_class->read_fn = ot_checksum_instream_read;
+}
+
+static void
+ot_checksum_instream_init (OtChecksumInstream *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, OT_TYPE_CHECKSUM_INSTREAM, OtChecksumInstreamPrivate);
+}
+
+#ifdef HAVE_OPENSSL
+static const EVP_MD *
+gchecksum_type_to_openssl (GChecksumType checksum_type)
+{
+ switch (checksum_type)
+ {
+ case G_CHECKSUM_SHA256:
+ return EVP_sha256 ();
+ default:
+ /* If there's something else, fill in here */
+ g_assert_not_reached ();
+ }
+}
+#endif
+
+OtChecksumInstream *
+ot_checksum_instream_new (GInputStream *base,
+ GChecksumType checksum_type)
+{
+ OtChecksumInstream *stream;
+
+ g_return_val_if_fail (G_IS_INPUT_STREAM (base), NULL);
+
+ stream = g_object_new (OT_TYPE_CHECKSUM_INSTREAM,
+ "base-stream", base,
+ NULL);
+
+ /* For now */
+ g_assert (checksum_type == G_CHECKSUM_SHA256);
+
+#ifdef HAVE_OPENSSL
+ stream->priv->checksum = EVP_MD_CTX_create ();
+ g_assert (stream->priv->checksum);
+ g_assert (EVP_DigestInit_ex (stream->priv->checksum, gchecksum_type_to_openssl (checksum_type), NULL));
+#else
+ stream->priv->checksum = g_checksum_new (checksum_type);
+ stream->priv->checksum_type = checksum_type;
+#endif
+
+ return (OtChecksumInstream*) (stream);
+}
+
+static gssize
+ot_checksum_instream_read (GInputStream *stream,
+ void *buffer,
+ gsize count,
+ GCancellable *cancellable,
+ GError **error)
+{
+ OtChecksumInstream *self = (OtChecksumInstream*) stream;
+ GFilterInputStream *fself = (GFilterInputStream*) self;
+ gssize res = -1;
+
+ res = g_input_stream_read (fself->base_stream,
+ buffer,
+ count,
+ cancellable,
+ error);
+ if (res > 0)
+ {
+#ifdef HAVE_OPENSSL
+ g_assert (EVP_DigestUpdate (self->priv->checksum, buffer, res));
+#else
+ g_checksum_update (self->priv->checksum, buffer, res);
+#endif
+ }
+
+ return res;
+}
+
+void
+ot_checksum_instream_get_digest (OtChecksumInstream *stream,
+ guint8 *buffer,
+ gsize *digest_len)
+{
+#ifdef HAVE_OPENSSL
+ unsigned len;
+ EVP_DigestFinal_ex (stream->priv->checksum, buffer, &len);
+ if (digest_len)
+ *digest_len = len;
+#else
+ g_checksum_get_digest (stream->priv->checksum, buffer, digest_len);
+#endif
+}
+
+guint8*
+ot_checksum_instream_dup_digest (OtChecksumInstream *stream,
+ gsize *ret_len)
+{
+#ifdef HAVE_OPENSSL
+ guint len;
+ guchar *ret = g_malloc0 (EVP_MAX_MD_SIZE);
+ g_assert (EVP_DigestFinal_ex (stream->priv->checksum, ret, &len));
+#else
+ gsize len = g_checksum_type_get_length (stream->priv->checksum_type);
+ guchar *ret = g_malloc (len);
+ g_checksum_get_digest (stream->priv->checksum, ret, &len);
+#endif
+ if (ret_len)
+ *ret_len = len;
+ return ret;
+}
+
+char *
+ot_checksum_instream_get_string (OtChecksumInstream *stream)
+{
+#ifdef HAVE_OPENSSL
+ unsigned len;
+ guint8 csum[EVP_MAX_MD_SIZE];
+ g_assert (EVP_DigestFinal_ex (stream->priv->checksum, csum, &len));
+ char *buf = g_malloc (len * 2 + 1);
+ ot_bin2hex (buf, (guint8*)csum, len);
+ return buf;
+#else
+ return g_strdup (g_checksum_get_string (stream->priv->checksum));
+#endif
+}
diff --git a/src/libotutil/ot-checksum-instream.h b/src/libotutil/ot-checksum-instream.h
new file mode 100644
index 00000000..78a5d44e
--- /dev/null
+++ b/src/libotutil/ot-checksum-instream.h
@@ -0,0 +1,64 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2011 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.
+ *
+ */
+
+#pragma once
+
+#include
+
+G_BEGIN_DECLS
+
+#define OT_TYPE_CHECKSUM_INSTREAM (ot_checksum_instream_get_type ())
+#define OT_CHECKSUM_INSTREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), OT_TYPE_CHECKSUM_INPUT_STREAM, OtChecksumInstream))
+#define OT_CHECKSUM_INSTREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), OT_TYPE_CHECKSUM_INPUT_STREAM, OtChecksumInstreamClass))
+#define OT_IS_CHECKSUM_INSTREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), OT_TYPE_CHECKSUM_INPUT_STREAM))
+#define OT_IS_CHECKSUM_INSTREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), OT_TYPE_CHECKSUM_INPUT_STREAM))
+#define OT_CHECKSUM_INSTREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), OT_TYPE_CHECKSUM_INPUT_STREAM, OtChecksumInstreamClass))
+
+typedef struct _OtChecksumInstream OtChecksumInstream;
+typedef struct _OtChecksumInstreamClass OtChecksumInstreamClass;
+typedef struct _OtChecksumInstreamPrivate OtChecksumInstreamPrivate;
+
+struct _OtChecksumInstream
+{
+ GFilterInputStream parent_instance;
+
+ /*< private >*/
+ OtChecksumInstreamPrivate *priv;
+};
+
+struct _OtChecksumInstreamClass
+{
+ GFilterInputStreamClass parent_class;
+};
+
+GType ot_checksum_instream_get_type (void) G_GNUC_CONST;
+
+OtChecksumInstream * ot_checksum_instream_new (GInputStream *stream, GChecksumType checksum);
+
+void ot_checksum_instream_get_digest (OtChecksumInstream *stream,
+ guint8 *buffer,
+ gsize *digest_len);
+
+guint8* ot_checksum_instream_dup_digest (OtChecksumInstream *stream,
+ gsize *ret_len);
+char * ot_checksum_instream_get_string (OtChecksumInstream *stream);
+
+G_END_DECLS
diff --git a/src/libotutil/ot-checksum-utils.c b/src/libotutil/ot-checksum-utils.c
index 8d30bdc3..39417044 100644
--- a/src/libotutil/ot-checksum-utils.c
+++ b/src/libotutil/ot-checksum-utils.c
@@ -26,6 +26,22 @@
#include
+
+void
+ot_bin2hex (char *out_buf, const guint8 *inbuf, gsize len)
+{
+ static const gchar hexchars[] = "0123456789abcdef";
+ guint i, j;
+
+ for (i = 0, j = 0; i < len; i++, j += 2)
+ {
+ guchar byte = inbuf[i];
+ out_buf[j] = hexchars[byte >> 4];
+ out_buf[j+1] = hexchars[byte & 0xF];
+ }
+ out_buf[j] = '\0';
+}
+
guchar *
ot_csum_from_gchecksum (GChecksum *checksum)
{
@@ -164,46 +180,3 @@ ot_checksum_file_at (int dfd,
return ret;
}
-
-static void
-checksum_stream_thread (GSimpleAsyncResult *result,
- GObject *object,
- GCancellable *cancellable)
-{
- GError *error = NULL;
- guchar *csum;
-
- if (!ot_gio_checksum_stream ((GInputStream*)object, &csum,
- cancellable, &error))
- g_simple_async_result_take_error (result, error);
- else
- g_simple_async_result_set_op_res_gpointer (result, csum, g_free);
-}
-
-void
-ot_gio_checksum_stream_async (GInputStream *in,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *result;
-
- result = g_simple_async_result_new ((GObject*) in,
- callback, user_data,
- ot_gio_checksum_stream_async);
-
- g_simple_async_result_run_in_thread (result, checksum_stream_thread, io_priority, cancellable);
- g_object_unref (result);
-}
-
-guchar *
-ot_gio_checksum_stream_finish (GInputStream *in,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == ot_gio_checksum_stream_async);
- return g_memdup (g_simple_async_result_get_op_res_gpointer (simple), 32);
-}
diff --git a/src/libotutil/ot-checksum-utils.h b/src/libotutil/ot-checksum-utils.h
index 8b3a394e..fdf7b09b 100644
--- a/src/libotutil/ot-checksum-utils.h
+++ b/src/libotutil/ot-checksum-utils.h
@@ -26,6 +26,8 @@
G_BEGIN_DECLS
+void ot_bin2hex (char *out_buf, const guint8 *inbuf, gsize len);
+
guchar *ot_csum_from_gchecksum (GChecksum *checksum);
gboolean ot_gio_write_update_checksum (GOutputStream *out,
@@ -59,14 +61,4 @@ char * ot_checksum_file_at (int dfd,
GCancellable *cancellable,
GError **error);
-void ot_gio_checksum_stream_async (GInputStream *in,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-guchar * ot_gio_checksum_stream_finish (GInputStream *in,
- GAsyncResult *result,
- GError **error);
-
G_END_DECLS
diff --git a/src/libotutil/ot-fs-utils.c b/src/libotutil/ot-fs-utils.c
index 4575effe..a0a72ca5 100644
--- a/src/libotutil/ot-fs-utils.c
+++ b/src/libotutil/ot-fs-utils.c
@@ -25,6 +25,16 @@
#include
#include
+/* Convert a fd-relative path to a GFile* - use
+ * for legacy code.
+ */
+GFile *
+ot_fdrel_to_gfile (int dfd, const char *path)
+{
+ g_autofree char *abspath = glnx_fdrel_abspath (dfd, path);
+ return g_file_new_for_path (abspath);
+}
+
int
ot_opendirat (int dfd, const char *path, gboolean follow)
{
@@ -205,6 +215,30 @@ ot_ensure_unlinked_at (int dfd,
return TRUE;
}
+gboolean
+ot_query_exists_at (int dfd, const char *path,
+ gboolean *out_exists,
+ GError **error)
+{
+ struct stat stbuf;
+ gboolean ret_exists;
+
+ if (fstatat (dfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
+ {
+ if (errno != ENOENT)
+ {
+ glnx_set_error_from_errno (error);
+ return FALSE;
+ }
+ ret_exists = FALSE;
+ }
+ else
+ ret_exists = TRUE;
+
+ *out_exists = ret_exists;
+ return TRUE;
+}
+
gboolean
ot_openat_ignore_enoent (int dfd,
const char *path,
diff --git a/src/libotutil/ot-fs-utils.h b/src/libotutil/ot-fs-utils.h
index 27f0f38e..13909c8e 100644
--- a/src/libotutil/ot-fs-utils.h
+++ b/src/libotutil/ot-fs-utils.h
@@ -24,6 +24,8 @@
G_BEGIN_DECLS
+GFile * ot_fdrel_to_gfile (int dfd, const char *path);
+
int ot_opendirat (int dfd, const char *path, gboolean follow);
gboolean ot_gopendirat (int dfd,
const char *path,
@@ -57,6 +59,11 @@ gboolean ot_openat_read_stream (int dfd,
GCancellable *cancellable,
GError **error);
+
+gboolean ot_query_exists_at (int dfd, const char *path,
+ gboolean *out_exists,
+ GError **error);
+
gboolean ot_ensure_unlinked_at (int dfd,
const char *path,
GError **error);
diff --git a/src/libotutil/ot-gio-utils.c b/src/libotutil/ot-gio-utils.c
index da32653e..5d12d430 100644
--- a/src/libotutil/ot-gio-utils.c
+++ b/src/libotutil/ot-gio-utils.c
@@ -51,91 +51,6 @@ ot_gfile_type_for_mode (guint32 mode)
}
-GFile *
-ot_gfile_from_build_path (const char *first, ...)
-{
- va_list args;
- const char *arg;
- g_autofree char *path = NULL;
- g_autoptr(GPtrArray) components = NULL;
-
- va_start (args, first);
-
- components = g_ptr_array_new ();
-
- arg = first;
- while (arg != NULL)
- {
- g_ptr_array_add (components, (char*)arg);
- arg = va_arg (args, const char *);
- }
-
- va_end (args);
-
- g_ptr_array_add (components, NULL);
-
- path = g_build_filenamev ((char**)components->pdata);
-
- return g_file_new_for_path (path);
-}
-
-GFile *
-ot_gfile_get_child_strconcat (GFile *parent,
- const char *first,
- ...)
-{
- va_list args;
- GFile *ret;
- GString *buf;
- const char *arg;
-
- g_return_val_if_fail (first != NULL, NULL);
-
- va_start (args, first);
-
- buf = g_string_new (first);
-
- while ((arg = va_arg (args, const char *)) != NULL)
- g_string_append (buf, arg);
-
- va_end (args);
-
- ret = g_file_get_child (parent, buf->str);
-
- g_string_free (buf, TRUE);
-
- return ret;
-}
-
-GFile *
-ot_gfile_get_child_build_path (GFile *parent,
- const char *first, ...)
-{
- va_list args;
- const char *arg;
- g_autofree char *path = NULL;
- g_autoptr(GPtrArray) components = NULL;
-
- va_start (args, first);
-
- components = g_ptr_array_new ();
-
- arg = first;
- while (arg != NULL)
- {
- g_ptr_array_add (components, (char*)arg);
- arg = va_arg (args, const char *);
- }
-
- va_end (args);
-
- g_ptr_array_add (components, NULL);
-
- path = g_build_filenamev ((char**)components->pdata);
-
- return g_file_resolve_relative_path (parent, path);
-}
-
GFile *
ot_gfile_resolve_path_printf (GFile *path,
const char *format,
@@ -151,130 +66,6 @@ ot_gfile_resolve_path_printf (GFile *path,
return g_file_resolve_relative_path (path, relpath);
}
-
-gboolean
-ot_gfile_get_symlink_target_from_info (GFile *path,
- GFileInfo *file_info,
- GFile **out_target,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- const char *target;
- g_autoptr(GFile) path_parent = NULL;
- g_autoptr(GFile) ret_target = NULL;
-
- if (g_file_info_get_file_type (file_info) != G_FILE_TYPE_SYMBOLIC_LINK)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Not a symbolic link");
- goto out;
- }
-
- path_parent = g_file_get_parent (path);
- target = g_file_info_get_symlink_target (file_info);
- g_assert (target);
- ret_target = g_file_resolve_relative_path (path_parent, target);
-
- ret = TRUE;
- out:
- ot_transfer_out_value (out_target, &ret_target);
- return ret;
-}
-
-gboolean
-ot_gfile_query_info_allow_noent (GFile *path,
- const char *queryopts,
- GFileQueryInfoFlags flags,
- GFileInfo **out_info,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- g_autoptr(GFileInfo) ret_file_info = NULL;
- GError *temp_error = NULL;
-
- ret_file_info = g_file_query_info (path, queryopts, flags,
- cancellable, &temp_error);
- if (!ret_file_info)
- {
- if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- {
- g_clear_error (&temp_error);
- }
- else
- {
- g_propagate_error (error, temp_error);
- goto out;
- }
- }
-
- ret = TRUE;
- ot_transfer_out_value (out_info, &ret_file_info);
- out:
- return ret;
-}
-
-gboolean
-ot_gfile_query_symlink_target_allow_noent (GFile *path,
- GFile **out_target,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- g_autoptr(GFileInfo) file_info = NULL;
- g_autoptr(GFile) ret_target = NULL;
-
- if (!ot_gfile_query_info_allow_noent (path, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- &file_info,
- cancellable, error))
- goto out;
-
- if (file_info != NULL)
- {
- if (!ot_gfile_get_symlink_target_from_info (path, file_info, &ret_target,
- cancellable, error))
- goto out;
- }
-
- ret = TRUE;
- ot_transfer_out_value (out_target, &ret_target);
- out:
- return ret;
-}
-
-gboolean
-ot_gfile_load_contents_utf8_allow_noent (GFile *path,
- char **out_contents,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- GError *temp_error = NULL;
- g_autofree char *ret_contents = NULL;
-
- ret_contents = glnx_file_get_contents_utf8_at (AT_FDCWD, gs_file_get_path_cached (path), NULL,
- cancellable, &temp_error);
- if (!ret_contents)
- {
- if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- {
- g_clear_error (&temp_error);
- }
- else
- {
- g_propagate_error (error, temp_error);
- goto out;
- }
- }
-
- ret = TRUE;
- ot_transfer_out_value (out_contents, &ret_contents);
- out:
- return ret;
-}
-
/**
* ot_gfile_replace_contents_fsync:
*
diff --git a/src/libotutil/ot-gio-utils.h b/src/libotutil/ot-gio-utils.h
index 34040238..0fd3ddf0 100644
--- a/src/libotutil/ot-gio-utils.h
+++ b/src/libotutil/ot-gio-utils.h
@@ -35,47 +35,10 @@ G_BEGIN_DECLS
GFileType ot_gfile_type_for_mode (guint32 mode);
-GFile *ot_gfile_from_build_path (const char *first, ...) G_GNUC_NULL_TERMINATED;
-
-GFile *ot_gfile_get_child_strconcat (GFile *parent, const char *first, ...) G_GNUC_NULL_TERMINATED;
-
-GFile *ot_gfile_get_child_build_path (GFile *parent, const char *first, ...) G_GNUC_NULL_TERMINATED;
-
GFile * ot_gfile_resolve_path_printf (GFile *path,
const char *format,
...) G_GNUC_PRINTF(2, 3);
-
-gboolean ot_gfile_get_symlink_target_from_info (GFile *path,
- GFileInfo *file_info,
- GFile **out_target,
- GCancellable *cancellable,
- GError **error);
-
-gboolean ot_gfile_query_info_allow_noent (GFile *path,
- const char *queryopts,
- GFileQueryInfoFlags flags,
- GFileInfo **out_info,
- GCancellable *cancellable,
- GError **error);
-
-gboolean ot_gfile_query_symlink_target_allow_noent (GFile *path,
- GFile **out_target,
- GCancellable *cancellable,
- GError **error);
-
-gboolean ot_gfile_load_contents_utf8_allow_noent (GFile *path,
- char **out_contents,
- GCancellable *cancellable,
- GError **error);
-
-gboolean ot_file_replace_contents_at (int dfd,
- const char *path,
- GBytes *contents,
- gboolean datasync,
- GCancellable *cancellable,
- GError **error);
-
gboolean ot_gfile_replace_contents_fsync (GFile *path,
GBytes *contents,
GCancellable *cancellable,
diff --git a/src/libotutil/ot-spawn-utils.c b/src/libotutil/ot-spawn-utils.c
deleted file mode 100644
index f798264b..00000000
--- a/src/libotutil/ot-spawn-utils.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
- *
- * Copyright (C) 2011 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.
- *
- * Author: Colin Walters
- */
-
-#include "config.h"
-
-#include "otutil.h"
-
-#include
-
-/**
- * ot_thread_pool_new_nproc:
- *
- * Like g_thread_pool_new (), but choose number of threads appropriate
- * for CPU bound workers automatically. Also aborts on error.
- */
-GThreadPool *
-ot_thread_pool_new_nproc (GFunc func,
- gpointer user_data)
-{
- long nproc_onln;
- GThreadPool *ret;
- GError *local_error = NULL;
-
- nproc_onln = sysconf (_SC_NPROCESSORS_ONLN);
- if (G_UNLIKELY (nproc_onln == -1 && errno == EINVAL))
- nproc_onln = 2;
- ret = g_thread_pool_new (func, user_data, (int)nproc_onln, FALSE, &local_error);
- g_assert_no_error (local_error);
- return ret;
-}
diff --git a/src/libotutil/ot-unix-utils.c b/src/libotutil/ot-unix-utils.c
index 4f659a27..46dd346e 100644
--- a/src/libotutil/ot-unix-utils.c
+++ b/src/libotutil/ot-unix-utils.c
@@ -121,17 +121,3 @@ ot_util_path_split_validate (const char *path,
out:
return ret;
}
-
-void
-ot_util_fatal_literal (const char *msg)
-{
- g_printerr ("%s\n", msg);
- exit (EXIT_FAILURE);
-}
-
-void
-ot_util_fatal_gerror (GError *error)
-{
- g_assert (error != NULL);
- ot_util_fatal_literal (error->message);
-}
diff --git a/src/libotutil/ot-unix-utils.h b/src/libotutil/ot-unix-utils.h
index 0547a54e..817e6fd3 100644
--- a/src/libotutil/ot-unix-utils.h
+++ b/src/libotutil/ot-unix-utils.h
@@ -36,10 +36,6 @@
G_BEGIN_DECLS
-void ot_util_fatal_literal (const char *msg) G_GNUC_NORETURN;
-
-void ot_util_fatal_gerror (GError *error) G_GNUC_NORETURN;
-
gboolean ot_util_filename_validate (const char *name, GError **error);
gboolean ot_util_path_split_validate (const char *path, GPtrArray **out_components, GError **error);
diff --git a/src/libotutil/ot-variant-utils.c b/src/libotutil/ot-variant-utils.c
index 1c4c5efa..c8c049fb 100644
--- a/src/libotutil/ot-variant-utils.c
+++ b/src/libotutil/ot-variant-utils.c
@@ -80,36 +80,6 @@ ot_util_variant_asv_to_hash_table (GVariant *variant)
return ret;
}
-gboolean
-ot_util_variant_save (GFile *dest,
- GVariant *variant,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- g_autoptr(GOutputStream) out = NULL;
- gsize bytes_written;
-
- out = (GOutputStream*)g_file_replace (dest, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION,
- cancellable, error);
- if (!out)
- goto out;
-
- if (!g_output_stream_write_all (out,
- g_variant_get_data (variant),
- g_variant_get_size (variant),
- &bytes_written,
- cancellable,
- error))
- goto out;
- if (!g_output_stream_close (out, cancellable, error))
- goto out;
-
- ret = TRUE;
- out:
- return ret;
-}
-
GVariant *
ot_util_variant_take_ref (GVariant *variant)
{
@@ -198,43 +168,6 @@ ot_util_variant_map_fd (int fd,
return ret;
}
-/**
- * Read all input from @src, allocating a new #GVariant from it into
- * output variable @out_variant. @src will be closed as a result.
- *
- * Note the returned @out_variant is not floating.
- */
-gboolean
-ot_util_variant_from_stream (GInputStream *src,
- const GVariantType *type,
- gboolean trusted,
- GVariant **out_variant,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean ret = FALSE;
- g_autoptr(GMemoryOutputStream) data_stream = NULL;
- g_autoptr(GVariant) ret_variant = NULL;
-
- data_stream = (GMemoryOutputStream*)g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
-
- if (g_output_stream_splice ((GOutputStream*)data_stream, src,
- G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- cancellable, error) < 0)
- goto out;
-
- ret_variant = g_variant_new_from_data (type, g_memory_output_stream_get_data (data_stream),
- g_memory_output_stream_get_data_size (data_stream),
- trusted, (GDestroyNotify) g_object_unref, data_stream);
- data_stream = NULL; /* Transfer ownership */
- g_variant_ref_sink (ret_variant);
-
- ret = TRUE;
- ot_transfer_out_value (out_variant, &ret_variant);
- out:
- return ret;
-}
-
GInputStream *
ot_variant_read (GVariant *variant)
{
diff --git a/src/libotutil/ot-variant-utils.h b/src/libotutil/ot-variant-utils.h
index 8a33cf60..4f2131ee 100644
--- a/src/libotutil/ot-variant-utils.h
+++ b/src/libotutil/ot-variant-utils.h
@@ -37,11 +37,6 @@ GHashTable *ot_util_variant_asv_to_hash_table (GVariant *variant);
GVariant * ot_util_variant_take_ref (GVariant *variant);
-gboolean ot_util_variant_save (GFile *dest,
- GVariant *variant,
- GCancellable *cancellable,
- GError **error);
-
typedef enum {
OT_VARIANT_MAP_TRUSTED = (1 << 0),
OT_VARIANT_MAP_ALLOW_NOENT = (1 << 1)
@@ -61,13 +56,6 @@ gboolean ot_util_variant_map_fd (int fd,
GVariant **out_variant,
GError **error);
-gboolean ot_util_variant_from_stream (GInputStream *src,
- const GVariantType *type,
- gboolean trusted,
- GVariant **out_variant,
- GCancellable *cancellable,
- GError **error);
-
GInputStream *ot_variant_read (GVariant *variant);
GVariantBuilder *ot_util_variant_builder_from_variant (GVariant *variant,
diff --git a/src/libotutil/otutil.h b/src/libotutil/otutil.h
index c66d5634..dfe951d0 100644
--- a/src/libotutil/otutil.h
+++ b/src/libotutil/otutil.h
@@ -49,9 +49,9 @@
#include
#include
#include
-#include
#include
#include
#include
+#include
void ot_ptrarray_add_many (GPtrArray *a, ...) G_GNUC_NULL_TERMINATED;
diff --git a/src/ostree/main.c b/src/ostree/main.c
index eff3082d..5a2ed661 100644
--- a/src/ostree/main.c
+++ b/src/ostree/main.c
@@ -58,7 +58,7 @@ static OstreeCommand commands[] = {
{ "show", ostree_builtin_show },
{ "static-delta", ostree_builtin_static_delta },
{ "summary", ostree_builtin_summary },
-#ifdef HAVE_LIBSOUP
+#if defined(HAVE_LIBSOUP) && defined(BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE)
{ "trivial-httpd", ostree_builtin_trivial_httpd },
#endif
{ NULL }
@@ -68,7 +68,7 @@ int
main (int argc,
char **argv)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
int ret;
setlocale (LC_ALL, "");
@@ -88,7 +88,6 @@ main (int argc,
suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */
}
g_printerr ("%serror: %s%s\n", prefix, suffix, error->message);
- g_error_free (error);
}
return ret;
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 218fb701..e6738c89 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -45,6 +45,7 @@ static gboolean opt_link_checkout_speedup;
static gboolean opt_skip_if_unchanged;
static gboolean opt_tar_autocreate_parents;
static gboolean opt_no_xattrs;
+static gboolean opt_canonical_permissions;
static char **opt_trees;
static gint opt_owner_uid = -1;
static gint opt_owner_gid = -1;
@@ -84,6 +85,7 @@ static GOptionEntry options[] = {
{ "add-detached-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_detached_metadata_strings, "Add a key/value pair to detached metadata", "KEY=VALUE" },
{ "owner-uid", 0, 0, G_OPTION_ARG_INT, &opt_owner_uid, "Set file ownership user id", "UID" },
{ "owner-gid", 0, 0, G_OPTION_ARG_INT, &opt_owner_gid, "Set file ownership group id", "GID" },
+ { "canonical-permissions", 0, 0, G_OPTION_ARG_NONE, &opt_canonical_permissions, "Canonicalize permissions in the same way bare-user does for hardlinked files", NULL },
{ "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Do not import extended attributes", NULL },
{ "link-checkout-speedup", 0, 0, G_OPTION_ARG_NONE, &opt_link_checkout_speedup, "Optimize for commits of trees composed of hardlinks into the repository", NULL },
{ "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &opt_tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL },
@@ -399,6 +401,8 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError
if (opt_no_xattrs)
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS;
+ if (opt_canonical_permissions)
+ flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS;
if (opt_generate_sizes)
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES;
if (opt_disable_fsync)
diff --git a/src/ostree/ot-builtin-diff.c b/src/ostree/ot-builtin-diff.c
index 963a8b7c..a7e2aad2 100644
--- a/src/ostree/ot-builtin-diff.c
+++ b/src/ostree/ot-builtin-diff.c
@@ -30,11 +30,15 @@
static gboolean opt_stats;
static gboolean opt_fs_diff;
static gboolean opt_no_xattrs;
+static gint opt_owner_uid = -1;
+static gint opt_owner_gid = -1;
static GOptionEntry options[] = {
{ "stats", 0, 0, G_OPTION_ARG_NONE, &opt_stats, "Print various statistics", NULL },
{ "fs-diff", 0, 0, G_OPTION_ARG_NONE, &opt_fs_diff, "Print filesystem diff", NULL },
{ "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Skip output of extended attributes", NULL },
+ { "owner-uid", 0, 0, G_OPTION_ARG_INT, &opt_owner_uid, "Use file ownership user id for local files", "UID" },
+ { "owner-gid", 0, 0, G_OPTION_ARG_INT, &opt_owner_gid, "Use file ownership group id for local files", "GID" },
{ NULL }
};
@@ -177,8 +181,10 @@ ostree_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **
modified = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_diff_item_unref);
removed = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
added = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
-
- if (!ostree_diff_dirs (diff_flags, srcf, targetf, modified, removed, added, cancellable, error))
+
+ OstreeDiffDirsOptions diff_opts = { opt_owner_uid, opt_owner_gid };
+ if (!ostree_diff_dirs_with_options (diff_flags, srcf, targetf, modified, removed,
+ added, &diff_opts, cancellable, error))
goto out;
ostree_diff_print (srcf, targetf, modified, removed, added);
diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c
index 6c45002a..3aaa2303 100644
--- a/src/ostree/ot-builtin-show.c
+++ b/src/ostree/ot-builtin-show.c
@@ -52,17 +52,13 @@ do_print_variant_generic (const GVariantType *type,
const char *filename,
GError **error)
{
- gboolean ret = FALSE;
g_autoptr(GVariant) variant = NULL;
if (!ot_util_variant_map_at (AT_FDCWD, filename, type, TRUE, &variant, error))
- goto out;
+ return FALSE;
ot_dump_variant (variant);
-
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -71,34 +67,23 @@ do_print_related (OstreeRepo *repo,
const char *resolved_rev,
GError **error)
{
- gboolean ret = FALSE;
- const char *name;
- g_autoptr(GVariant) csum_v = NULL;
g_autoptr(GVariant) variant = NULL;
- g_autoptr(GVariant) related = NULL;
- GVariantIter *viter = NULL;
-
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
resolved_rev, &variant, error))
- goto out;
-
- /* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
- related = g_variant_get_child_value (variant, 2);
-
- viter = g_variant_iter_new (related);
+ return FALSE;
+ /* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
+ g_autoptr(GVariant) related = g_variant_get_child_value (variant, 2);
+ g_autoptr(GVariantIter) viter = g_variant_iter_new (related);
+
+ const char *name;
+ GVariant* csum_v;
while (g_variant_iter_loop (viter, "(&s@ay)", &name, &csum_v))
{
g_autofree char *checksum = ostree_checksum_from_bytes_v (csum_v);
g_print ("%s %s\n", name, checksum);
}
- csum_v = NULL;
-
- ret = TRUE;
- out:
- if (viter)
- g_variant_iter_free (viter);
- return ret;
+ return TRUE;
}
static gboolean
@@ -108,8 +93,6 @@ do_print_metadata_key (OstreeRepo *repo,
const char *key,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GVariant) value = NULL;
g_autoptr(GVariant) commit = NULL;
g_autoptr(GVariant) metadata = NULL;
@@ -117,7 +100,7 @@ do_print_metadata_key (OstreeRepo *repo,
{
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
resolved_rev, &commit, error))
- goto out;
+ return FALSE;
/* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
metadata = g_variant_get_child_value (commit, 0);
}
@@ -125,28 +108,25 @@ do_print_metadata_key (OstreeRepo *repo,
{
if (!ostree_repo_read_commit_detached_metadata (repo, resolved_rev, &metadata,
NULL, error))
- goto out;
+ return FALSE;
if (metadata == NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No detached metadata for commit %s", resolved_rev);
- goto out;
+ return FALSE;
}
}
-
- value = g_variant_lookup_value (metadata, key, NULL);
+
+ g_autoptr(GVariant) value = g_variant_lookup_value (metadata, key, NULL);
if (!value)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No such metadata key '%s'", key);
- goto out;
+ return FALSE;
}
ot_dump_variant (value);
-
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -155,13 +135,12 @@ print_object (OstreeRepo *repo,
const char *checksum,
GError **error)
{
- g_autoptr(GVariant) variant = NULL;
OstreeDumpFlags flags = OSTREE_DUMP_NONE;
- gboolean ret = FALSE;
+ g_autoptr(GVariant) variant = NULL;
if (!ostree_repo_load_variant (repo, objtype, checksum,
&variant, error))
- goto out;
+ return FALSE;
if (opt_raw)
flags |= OSTREE_DUMP_RAW;
ot_dump_object (objtype, checksum, variant, flags);
@@ -169,7 +148,7 @@ print_object (OstreeRepo *repo,
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
{
glnx_unref_object OstreeGpgVerifyResult *result = NULL;
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
g_autoptr(GFile) gpg_homedir = opt_gpg_homedir ? g_file_new_for_path (opt_gpg_homedir) : NULL;
if (opt_gpg_verify_remote)
@@ -186,24 +165,20 @@ print_object (OstreeRepo *repo,
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
- g_clear_error (&local_error);
+ /* Ignore */
}
else if (local_error != NULL)
{
- g_propagate_error (error, local_error);
- goto out;
+ g_propagate_error (error, g_steal_pointer (&local_error));
+ return FALSE;
}
else
{
- GString *buffer;
- guint n_sigs, ii;
-
- n_sigs = ostree_gpg_verify_result_count_all (result);
+ guint n_sigs = ostree_gpg_verify_result_count_all (result);
g_print ("Found %u signature%s:\n", n_sigs, n_sigs == 1 ? "" : "s");
- buffer = g_string_sized_new (256);
-
- for (ii = 0; ii < n_sigs; ii++)
+ g_autoptr(GString) buffer = g_string_sized_new (256);
+ for (guint ii = 0; ii < n_sigs; ii++)
{
g_string_append_c (buffer, '\n');
ostree_gpg_verify_result_describe (result, ii, buffer, " ",
@@ -211,13 +186,10 @@ print_object (OstreeRepo *repo,
}
g_print ("%s", buffer->str);
- g_string_free (buffer, TRUE);
}
}
- ret = TRUE;
-out:
- return ret;
+ return TRUE;
}
static gboolean
@@ -228,7 +200,6 @@ print_if_found (OstreeRepo *repo,
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
gboolean have_object = FALSE;
if (*inout_was_found)
@@ -236,62 +207,56 @@ print_if_found (OstreeRepo *repo,
if (!ostree_repo_has_object (repo, objtype, checksum, &have_object,
cancellable, error))
- goto out;
+ return FALSE;
if (have_object)
{
if (!print_object (repo, objtype, checksum, error))
- goto out;
+ return FALSE;
*inout_was_found = TRUE;
}
-
- ret = TRUE;
- out:
- return ret;
+
+ return TRUE;
}
gboolean
ostree_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
+ g_autoptr(GOptionContext) context = g_option_context_new ("OBJECT - Output a metadata object");
+
glnx_unref_object OstreeRepo *repo = NULL;
- gboolean ret = FALSE;
- const char *rev;
- g_autofree char *resolved_rev = NULL;
-
- context = g_option_context_new ("OBJECT - Output a metadata object");
-
if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
- goto out;
+ return FALSE;
if (argc <= 1)
{
ot_util_usage_error (context, "An object argument is required", error);
- goto out;
+ return FALSE;
}
- rev = argv[1];
+ const char *rev = argv[1];
+ g_autofree char *resolved_rev = NULL;
if (opt_print_metadata_key || opt_print_detached_metadata_key)
{
gboolean detached = opt_print_detached_metadata_key != NULL;
const char *key = detached ? opt_print_detached_metadata_key : opt_print_metadata_key;
if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error))
- goto out;
+ return FALSE;
if (!do_print_metadata_key (repo, resolved_rev, detached, key, error))
- goto out;
+ return FALSE;
}
else if (opt_print_related)
{
if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error))
- goto out;
+ return FALSE;
if (!do_print_related (repo, rev, resolved_rev, error))
- goto out;
+ return FALSE;
}
else if (opt_print_variant_type)
{
if (!do_print_variant_generic (G_VARIANT_TYPE (opt_print_variant_type), rev, error))
- goto out;
+ return FALSE;
}
else
{
@@ -299,33 +264,32 @@ ostree_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **
if (!ostree_validate_checksum_string (rev, NULL))
{
if (!ostree_repo_resolve_rev (repo, rev, FALSE, &resolved_rev, error))
- goto out;
+ return FALSE;
if (!print_object (repo, OSTREE_OBJECT_TYPE_COMMIT, resolved_rev, error))
- goto out;
+ return FALSE;
}
else
{
if (!print_if_found (repo, OSTREE_OBJECT_TYPE_COMMIT, rev,
&found, cancellable, error))
- goto out;
+ return FALSE;
if (!print_if_found (repo, OSTREE_OBJECT_TYPE_DIR_META, rev,
&found, cancellable, error))
- goto out;
+ return FALSE;
if (!print_if_found (repo, OSTREE_OBJECT_TYPE_DIR_TREE, rev,
&found, cancellable, error))
- goto out;
+ return FALSE;
if (!found)
{
g_autoptr(GFileInfo) finfo = NULL;
g_autoptr(GVariant) xattrs = NULL;
- GFileType filetype;
-
+
if (!ostree_repo_load_file (repo, rev, NULL, &finfo, &xattrs,
cancellable, error))
- goto out;
+ return FALSE;
g_print ("Object: %s\nType: %s\n", rev, ostree_object_type_to_string (OSTREE_OBJECT_TYPE_FILE));
- filetype = g_file_info_get_file_type (finfo);
+ GFileType filetype = g_file_info_get_file_type (finfo);
g_print ("File Type: ");
switch (filetype)
{
@@ -358,8 +322,6 @@ ostree_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **
}
}
}
-
- ret = TRUE;
- out:
- return ret;
+
+ return TRUE;
}
diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c
index 3484b18e..7eb65602 100644
--- a/src/ostree/ot-main.c
+++ b/src/ostree/ot-main.c
@@ -259,7 +259,7 @@ ostree_option_context_parse (GOptionContext *context,
if (opt_repo == NULL && !(flags & OSTREE_BUILTIN_FLAG_NO_REPO))
{
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
repo = ostree_repo_new_default ();
if (!ostree_repo_open (repo, cancellable, &local_error))
@@ -270,14 +270,13 @@ ostree_option_context_parse (GOptionContext *context,
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Command requires a --repo argument");
- g_error_free (local_error);
help = g_option_context_get_help (context, FALSE, NULL);
g_printerr ("%s", help);
}
else
{
- g_propagate_error (error, local_error);
+ g_propagate_error (error, g_steal_pointer (&local_error));
}
goto out;
}
diff --git a/src/ostree/ot-remote-builtin-add-cookie.c b/src/ostree/ot-remote-builtin-add-cookie.c
index e4156172..d5ea3da5 100644
--- a/src/ostree/ot-remote-builtin-add-cookie.c
+++ b/src/ostree/ot-remote-builtin-add-cookie.c
@@ -37,7 +37,7 @@ gboolean
ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
const char *remote_name;
const char *domain;
const char *path;
diff --git a/src/ostree/ot-remote-builtin-add.c b/src/ostree/ot-remote-builtin-add.c
index 93c989f9..3e3aeda9 100644
--- a/src/ostree/ot-remote-builtin-add.c
+++ b/src/ostree/ot-remote-builtin-add.c
@@ -45,7 +45,7 @@ gboolean
ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
const char *remote_name;
const char *remote_url;
char **iter;
diff --git a/src/ostree/ot-remote-builtin-delete-cookie.c b/src/ostree/ot-remote-builtin-delete-cookie.c
index 6d1b85ad..cb1177fc 100644
--- a/src/ostree/ot-remote-builtin-delete-cookie.c
+++ b/src/ostree/ot-remote-builtin-delete-cookie.c
@@ -37,7 +37,7 @@ gboolean
ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
const char *remote_name;
const char *domain;
const char *path;
diff --git a/src/ostree/ot-remote-builtin-delete.c b/src/ostree/ot-remote-builtin-delete.c
index 8a4dd5f3..cac1b7ea 100644
--- a/src/ostree/ot-remote-builtin-delete.c
+++ b/src/ostree/ot-remote-builtin-delete.c
@@ -36,7 +36,7 @@ gboolean
ot_remote_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
const char *remote_name;
gboolean ret = FALSE;
diff --git a/src/ostree/ot-remote-builtin-gpg-import.c b/src/ostree/ot-remote-builtin-gpg-import.c
index d1db06d0..4df0dfe7 100644
--- a/src/ostree/ot-remote-builtin-gpg-import.c
+++ b/src/ostree/ot-remote-builtin-gpg-import.c
@@ -94,7 +94,7 @@ gboolean
ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
g_autoptr(GInputStream) source_stream = NULL;
const char *remote_name;
const char * const *key_ids;
diff --git a/src/ostree/ot-remote-builtin-list-cookies.c b/src/ostree/ot-remote-builtin-list-cookies.c
index 1c3924af..83d75a57 100644
--- a/src/ostree/ot-remote-builtin-list-cookies.c
+++ b/src/ostree/ot-remote-builtin-list-cookies.c
@@ -36,7 +36,7 @@ gboolean
ot_remote_builtin_list_cookies (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
const char *remote_name;
g_autofree char *jar_path = NULL;
g_autofree char *cookie_file = NULL;
diff --git a/src/ostree/ot-remote-builtin-list.c b/src/ostree/ot-remote-builtin-list.c
index faf8d8ad..0769ece7 100644
--- a/src/ostree/ot-remote-builtin-list.c
+++ b/src/ostree/ot-remote-builtin-list.c
@@ -34,7 +34,7 @@ gboolean
ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
g_auto(GStrv) remotes = NULL;
guint ii, n_remotes = 0;
gboolean ret = FALSE;
diff --git a/src/ostree/ot-remote-builtin-refs.c b/src/ostree/ot-remote-builtin-refs.c
index 9e742912..f5b3afe3 100644
--- a/src/ostree/ot-remote-builtin-refs.c
+++ b/src/ostree/ot-remote-builtin-refs.c
@@ -36,7 +36,7 @@ gboolean
ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
const char *remote_name;
gboolean ret = FALSE;
g_autoptr(GHashTable) refs = NULL;
diff --git a/src/ostree/ot-remote-builtin-show-url.c b/src/ostree/ot-remote-builtin-show-url.c
index 401dfb0b..c1666558 100644
--- a/src/ostree/ot-remote-builtin-show-url.c
+++ b/src/ostree/ot-remote-builtin-show-url.c
@@ -33,7 +33,7 @@ gboolean
ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
const char *remote_name;
g_autofree char *remote_url = NULL;
gboolean ret = FALSE;
diff --git a/src/ostree/ot-remote-builtin-summary.c b/src/ostree/ot-remote-builtin-summary.c
index 39321b53..b4d99254 100644
--- a/src/ostree/ot-remote-builtin-summary.c
+++ b/src/ostree/ot-remote-builtin-summary.c
@@ -40,7 +40,7 @@ gboolean
ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
- glnx_unref_object OstreeRepo *repo = NULL;
+ g_autoptr(OstreeRepo) repo = NULL;
const char *remote_name;
g_autoptr(GBytes) summary_bytes = NULL;
g_autoptr(GBytes) signature_bytes = NULL;
diff --git a/tests/archive-test.sh b/tests/archive-test.sh
index 9c5f8a47..76bc2635 100644
--- a/tests/archive-test.sh
+++ b/tests/archive-test.sh
@@ -31,7 +31,7 @@ echo "ok content"
cd ${test_tmpdir}
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init
+ostree_repo_init repo2
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
echo "ok local clone"
diff --git a/tests/basic-test.sh b/tests/basic-test.sh
index 045e4217..294854bf 100644
--- a/tests/basic-test.sh
+++ b/tests/basic-test.sh
@@ -19,15 +19,64 @@
set -euo pipefail
-echo "1..63"
+echo "1..65"
$CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
echo "ok yaml version"
+CHECKOUT_U_ARG=""
+COMMIT_ARGS=""
+DIFF_ARGS=""
+if grep bare-user-only repo/config; then
+ # In bare-user-only repos we can only represent files with uid/gid 0, no
+ # xattrs and canonical permissions, so we need to commit them as such, or
+ # we end up with repos that don't pass fsck
+ COMMIT_ARGS="--canonical-permissions"
+ DIFF_ARGS="--owner-uid=0 --owner-gid=0 --no-xattrs"
+ # Also, since we can't check out uid=0 files we need to check out in user mode
+ CHECKOUT_U_ARG="-U"
+fi
+
+validate_checkout_basic() {
+ (cd $1;
+ assert_has_file firstfile
+ assert_has_file baz/cow
+ assert_file_has_content baz/cow moo
+ assert_has_file baz/deeper/ohyeah
+ )
+}
+
$OSTREE checkout test2 checkout-test2
+validate_checkout_basic checkout-test2
echo "ok checkout"
+# Note this tests bare-user *and* bare-user-only
+rm checkout-test2 -rf
+if grep bare-user repo/config; then
+ $OSTREE checkout -U -H test2 checkout-test2
+else
+ $OSTREE checkout -H test2 checkout-test2
+fi
+validate_checkout_basic checkout-test2
+rm checkout-test2 -rf
+# Only do these tests on bare-user/bare, not bare-user-only
+# since the latter automatically synthesizes -U if it's not passed.
+if ! grep -q bare-user-only repo/config; then
+if grep -q bare-user repo/config; then
+ if $OSTREE checkout -H test2 checkout-test2 2>err.txt; then
+ assert_not_reached "checkout -H worked?"
+ fi
+ assert_file_has_content err.txt "User repository.*requires.*user"
+else
+ if $OSTREE checkout -U -H test2 checkout-test2 2>err.txt; then
+ assert_not_reached "checkout -H worked?"
+ fi
+ assert_file_has_content err.txt "Bare repository mode cannot hardlink in user"
+fi
+fi
+echo "ok checkout -H"
+
$OSTREE rev-parse test2
$OSTREE rev-parse 'test2^'
$OSTREE rev-parse 'test2^^' 2>/dev/null && fatal "rev-parse test2^^ unexpectedly succeeded!"
@@ -46,20 +95,16 @@ echo "ok shortened checksum"
echo "ok repo-in-cwd"
rm test-repo -rf
-$OSTREE --repo=test-repo init --mode=bare-user
-$OSTREE --repo=test-repo init --mode=bare-user
+ostree_repo_init test-repo --mode=bare-user
+ostree_repo_init test-repo --mode=bare-user
rm test-repo -rf
echo "ok repo-init on existing repo"
+rm checkout-test2 -rf
+$OSTREE checkout test2 checkout-test2
cd checkout-test2
-assert_has_file firstfile
-assert_has_file baz/cow
-assert_file_has_content baz/cow moo
-assert_has_file baz/deeper/ohyeah
-echo "ok content"
-
rm firstfile
-$OSTREE commit -b test2 -s delete
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s delete
cd $test_tmpdir
$OSTREE checkout test2 $test_tmpdir/checkout-test2-2
@@ -80,7 +125,7 @@ mkdir -p another/nested/tree
echo anotherone > another/nested/tree/1
echo whee2 > another/whee
# FIXME - remove grep for .
-$OSTREE commit -b test2 -s "Another commit"
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit"
echo "ok commit"
cd ${test_tmpdir}
@@ -96,7 +141,7 @@ mkdir -p yet/another/tree
echo leaf > yet/another/tree/green
echo helloworld > yet/message
rm a/5
-$OSTREE commit -b test2 -s "Current directory"
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Current directory"
echo "ok cwd commit"
cd ${test_tmpdir}
@@ -107,15 +152,15 @@ assert_file_has_content four '4'
echo "ok cwd contents"
cd ${test_tmpdir}
-$OSTREE commit -b test2-no-parent -s '' $test_tmpdir/checkout-test2-4
+$OSTREE commit ${COMMIT_ARGS} -b test2-no-parent -s '' $test_tmpdir/checkout-test2-4
assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
-$OSTREE commit -b test2-no-parent -s '' --parent=none $test_tmpdir/checkout-test2-4
+$OSTREE commit ${COMMIT_ARGS} -b test2-no-parent -s '' --parent=none $test_tmpdir/checkout-test2-4
assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
echo "ok commit no parent"
cd ${test_tmpdir}
-empty_rev=$($OSTREE commit -b test2-no-subject -s '' --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
-omitted_rev=$($OSTREE commit -b test2-no-subject-2 --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
+empty_rev=$($OSTREE commit ${COMMIT_ARGS} -b test2-no-subject -s '' --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
+omitted_rev=$($OSTREE commit ${COMMIT_ARGS} -b test2-no-subject-2 --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
assert_streq $empty_rev $omitted_rev
echo "ok commit no subject"
@@ -127,7 +172,7 @@ commit message.
Build-Host: foo.example.com
Crunchy-With-Extra-Ketchup: true
EOF
-$OSTREE commit -b branch-with-commitmsg -F commitmsg.txt -s 'a message' $test_tmpdir/checkout-test2-4
+$OSTREE commit ${COMMIT_ARGS} -b branch-with-commitmsg -F commitmsg.txt -s 'a message' $test_tmpdir/checkout-test2-4
$OSTREE log branch-with-commitmsg > log.txt
assert_file_has_content log.txt '^ *This is a long$'
assert_file_has_content log.txt '^ *Build-Host:.*example.com$'
@@ -136,17 +181,17 @@ $OSTREE refs --delete branch-with-commitmsg
echo "ok commit body file"
cd ${test_tmpdir}
-$OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
-$OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
-$OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
+$OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
+$OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
+$OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
assert_streq $($OSTREE log test2-custom-parent |grep '^commit' | wc -l) "3"
prevparent=$($OSTREE rev-parse test2-custom-parent^)
-$OSTREE commit -b test2-custom-parent -s '' --parent=${prevparent} $test_tmpdir/checkout-test2-4
+$OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' --parent=${prevparent} $test_tmpdir/checkout-test2-4
assert_streq $($OSTREE log test2-custom-parent |grep '^commit' | wc -l) "3"
echo "ok commit custom parent"
cd ${test_tmpdir}
-orphaned_rev=$($OSTREE commit --orphan -s "$(date)" $test_tmpdir/checkout-test2-4)
+orphaned_rev=$($OSTREE commit ${COMMIT_ARGS} --orphan -s "$(date)" $test_tmpdir/checkout-test2-4)
$OSTREE ls ${orphaned_rev} >/dev/null
$OSTREE prune --refs-only
if $OSTREE ls ${orphaned_rev} 2>err.txt; then
@@ -171,6 +216,21 @@ cd ${test_tmpdir}
assert_file_has_content diff-test2-2 'A *oh-look-a-file$'
echo "ok diff cwd"
+cd ${test_tmpdir}/checkout-test2-4
+$OSTREE diff ${DIFF_ARGS} test2 ./ > ${test_tmpdir}/diff-test2
+assert_file_empty ${test_tmpdir}/diff-test2
+$OSTREE diff ${DIFF_ARGS} test2 --owner-uid=$((`id -u`+1)) ./ > ${test_tmpdir}/diff-test2
+assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet$'
+assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/message$'
+assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/another/tree/green$'
+echo "ok diff file with different uid"
+
+$OSTREE diff ${DIFF_ARGS} test2 --owner-gid=$((`id -g`+1)) ./ > ${test_tmpdir}/diff-test2
+assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet$'
+assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/message$'
+assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/another/tree/green$'
+echo "ok diff file with different gid"
+
cd ${test_tmpdir}/checkout-test2-4
rm four
mkdir four
@@ -182,12 +242,12 @@ echo "ok diff file changing type"
cd ${test_tmpdir}
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init
+ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
echo "ok pull-local"
cd ${test_tmpdir}
-${CMD_PREFIX} ostree --repo=repo2 checkout test2 test2-checkout-from-local-clone
+${CMD_PREFIX} ostree --repo=repo2 checkout ${CHECKOUT_U_ARG} test2 test2-checkout-from-local-clone
cd test2-checkout-from-local-clone
assert_file_has_content yet/another/tree/green 'leaf'
echo "ok local clone checkout"
@@ -195,31 +255,33 @@ echo "ok local clone checkout"
$OSTREE checkout -U test2 checkout-user-test2
echo "ok user checkout"
-$OSTREE commit -b test2 -s "Another commit" --tree=ref=test2
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit" --tree=ref=test2
echo "ok commit from ref"
-$OSTREE commit -b test2 -s "Another commit with modifier" --tree=ref=test2 --owner-uid=`id -u`
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit with modifier" --tree=ref=test2 --owner-uid=`id -u`
echo "ok commit from ref with modifier"
-$OSTREE commit -b trees/test2 -s 'ref with / in it' --tree=ref=test2
+$OSTREE commit ${COMMIT_ARGS} -b trees/test2 -s 'ref with / in it' --tree=ref=test2
echo "ok commit ref with /"
old_rev=$($OSTREE rev-parse test2)
-$OSTREE commit --skip-if-unchanged -b test2 -s 'should not be committed' --tree=ref=test2
+$OSTREE ls -R -C test2
+$OSTREE commit ${COMMIT_ARGS} --skip-if-unchanged -b trees/test2 -s 'should not be committed' --tree=ref=test2
+$OSTREE ls -R -C test2
new_rev=$($OSTREE rev-parse test2)
assert_streq "${old_rev}" "${new_rev}"
echo "ok commit --skip-if-unchanged"
cd ${test_tmpdir}/checkout-test2-4
-$OSTREE commit -b test2 -s "no xattrs" --no-xattrs
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s "no xattrs" --no-xattrs
echo "ok commit with no xattrs"
mkdir tree-A tree-B
touch tree-A/file-a tree-B/file-b
-$OSTREE commit -b test3-1 -s "Initial tree" --tree=dir=tree-A
-$OSTREE commit -b test3-2 -s "Replacement tree" --tree=dir=tree-B
-$OSTREE commit -b test3-combined -s "combined tree" --tree=ref=test3-1 --tree=ref=test3-2
+$OSTREE commit ${COMMIT_ARGS} -b test3-1 -s "Initial tree" --tree=dir=tree-A
+$OSTREE commit ${COMMIT_ARGS} -b test3-2 -s "Replacement tree" --tree=dir=tree-B
+$OSTREE commit ${COMMIT_ARGS} -b test3-combined -s "combined tree" --tree=ref=test3-1 --tree=ref=test3-2
$OSTREE checkout test3-combined checkout-test3-combined
@@ -235,7 +297,7 @@ cat > test-statoverride.txt < test-skiplist.txt < union-files-count
-$OSTREE checkout --union test2 checkout-test2-union
+$OSTREE checkout --union test2 checkout-test2-union
find checkout-test2-union | wc -l > union-files-count.new
cmp union-files-count{,.new}
cd checkout-test2-union
@@ -280,11 +342,11 @@ assert_file_has_content ./yet/another/tree/green "leaf"
echo "ok checkout union 1"
cd ${test_tmpdir}
-$OSTREE commit -b test-union-add --tree=ref=test2
+$OSTREE commit ${COMMIT_ARGS} -b test-union-add --tree=ref=test2
$OSTREE checkout test-union-add checkout-test-union-add
echo 'file for union add testing' > checkout-test-union-add/union-add-test
echo 'another file for union add testing' > checkout-test-union-add/union-add-test2
-$OSTREE commit -b test-union-add --tree=dir=checkout-test-union-add
+$OSTREE commit ${COMMIT_ARGS} -b test-union-add --tree=dir=checkout-test-union-add
rm checkout-test-union-add -rf
# Check out previous
$OSTREE checkout test-union-add^ checkout-test-union-add
@@ -300,11 +362,11 @@ echo "ok checkout union add"
cd ${test_tmpdir}
rm -rf shadow-repo
mkdir shadow-repo
-${CMD_PREFIX} ostree --repo=shadow-repo init
+ostree_repo_init shadow-repo
${CMD_PREFIX} ostree --repo=shadow-repo config set core.parent $(pwd)/repo
rm -rf test2-checkout
parent_rev_test2=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2)
-${CMD_PREFIX} ostree --repo=shadow-repo checkout "${parent_rev_test2}" test2-checkout
+${CMD_PREFIX} ostree --repo=shadow-repo checkout ${CHECKOUT_U_ARG} "${parent_rev_test2}" test2-checkout
echo "ok checkout from shadow repo"
cd ${test_tmpdir}
@@ -320,7 +382,7 @@ echo "ok subdir noent"
cd ${test_tmpdir}
mkdir repo3
-${CMD_PREFIX} ostree --repo=repo3 init
+ostree_repo_init repo3 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2
${CMD_PREFIX} ostree --repo=repo3 rev-parse aremote/test2
echo "ok pull-local with --remote arg"
@@ -339,7 +401,7 @@ echo "ok prune"
cd ${test_tmpdir}
rm repo3 -rf
-${CMD_PREFIX} ostree --repo=repo3 init --mode=archive
+ostree_repo_init repo3 --mode=archive
${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2
rm repo3/refs/remotes -rf
mkdir repo3/refs/remotes
@@ -353,7 +415,7 @@ echo "ok prune in archive-z2 deleted everything"
cd ${test_tmpdir}
rm -rf test2-checkout
$OSTREE checkout test2 test2-checkout
-(cd test2-checkout && $OSTREE commit --link-checkout-speedup -b test2 -s "tmp")
+(cd test2-checkout && $OSTREE commit ${COMMIT_ARGS} --link-checkout-speedup -b test2 -s "tmp")
echo "ok commit with link speedup"
cd ${test_tmpdir}
@@ -372,7 +434,7 @@ $OSTREE show test2
echo "ok show with non-checksum"
cd $test_tmpdir/checkout-test2
-checksum=$($OSTREE commit -b test4 -s "Third commit")
+checksum=$($OSTREE commit ${COMMIT_ARGS} -b test4 -s "Third commit")
cd ${test_tmpdir}
$OSTREE show test4 > show-output
assert_file_has_content show-output "Third commit"
@@ -380,8 +442,8 @@ assert_file_has_content show-output "commit $checksum"
echo "ok show full output"
cd $test_tmpdir/checkout-test2
-checksum1=$($OSTREE commit -b test5 -s "First commit")
-checksum2=$($OSTREE commit -b test5 -s "Second commit")
+checksum1=$($OSTREE commit ${COMMIT_ARGS} -b test5 -s "First commit")
+checksum2=$($OSTREE commit ${COMMIT_ARGS} -b test5 -s "Second commit")
cd ${test_tmpdir}
$OSTREE log test5 > log-output
assert_file_has_content log-output "First commit"
@@ -391,8 +453,8 @@ assert_file_has_content log-output "commit $checksum2"
echo "ok log output"
cd $test_tmpdir/checkout-test2
-checksum1=$($OSTREE commit -b test6 -s "First commit")
-checksum2=$($OSTREE commit -b test6 -s "Second commit")
+checksum1=$($OSTREE commit ${COMMIT_ARGS} -b test6 -s "First commit")
+checksum2=$($OSTREE commit ${COMMIT_ARGS} -b test6 -s "Second commit")
cd ${test_tmpdir}
$OSTREE show test6 > show-output
assert_file_has_content show-output "commit $checksum2"
@@ -405,11 +467,11 @@ cd ${test_tmpdir}
rm checkout-test2 -rf
$OSTREE checkout test2 checkout-test2
touch checkout-test2/sometestfile
-$OSTREE commit -s sometest -b test2 checkout-test2
+$OSTREE commit ${COMMIT_ARGS} -s sometest -b test2 checkout-test2
echo "ok commit with directory filename"
cd $test_tmpdir/checkout-test2
-$OSTREE commit -b test2 -s "Metadata string" --add-metadata-string=FOO=BAR --add-metadata-string=KITTENS=CUTE --add-detached-metadata-string=SIGNATURE=HANCOCK --tree=ref=test2
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Metadata string" --add-metadata-string=FOO=BAR --add-metadata-string=KITTENS=CUTE --add-detached-metadata-string=SIGNATURE=HANCOCK --tree=ref=test2
cd ${test_tmpdir}
$OSTREE show --print-metadata-key=FOO test2 > test2-meta
assert_file_has_content test2-meta "BAR"
@@ -422,7 +484,7 @@ echo "ok metadata commit with strings"
cd ${test_tmpdir}
rm repo2 -rf
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init
+ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
${CMD_PREFIX} ostree --repo=repo2 show --print-detached-metadata-key=SIGNATURE test2 > test2-meta
assert_file_has_content test2-meta "HANCOCK"
@@ -457,7 +519,7 @@ rm -rf test2-checkout
mkdir -p test2-checkout
cd test2-checkout
mkfifo afifo
-if $OSTREE commit -b test2 -s "Attempt to commit a FIFO" 2>../errmsg; then
+if $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Attempt to commit a FIFO" 2>../errmsg; then
assert_not_reached "Committing a FIFO unexpetedly succeeded!"
assert_file_has_content ../errmsg "Unsupported file type"
fi
@@ -466,7 +528,7 @@ echo "ok commit of fifo was rejected"
cd ${test_tmpdir}
rm repo2 -rf
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init --mode=archive
+ostree_repo_init repo2 --mode=archive
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
rm -rf test2-checkout
${CMD_PREFIX} ostree --repo=repo2 checkout -U --disable-cache test2 test2-checkout
@@ -489,7 +551,7 @@ date > checkout-test2/date.txt
rm repo/tmp/* -rf
export TEST_BOOTID=3072029c-8b10-60d1-d31b-8422eeff9b42
if env OSTREE_REPO_TEST_ERROR=pre-commit OSTREE_BOOTID=${TEST_BOOTID} \
- $OSTREE commit -b test2 -s '' $test_tmpdir/checkout-test2 2>err.txt; then
+ $OSTREE commit ${COMMIT_ARGS} -b test2 -s '' $test_tmpdir/checkout-test2 2>err.txt; then
assert_not_reached "Should have hit OSTREE_REPO_TEST_ERROR_PRE_COMMIT"
fi
assert_file_has_content err.txt OSTREE_REPO_TEST_ERROR_PRE_COMMIT
@@ -511,7 +573,7 @@ if touch overlay/baz/.wh.cow && touch overlay/.wh.deeper; then
touch overlay/anewfile
mkdir overlay/anewdir/
touch overlay/anewdir/blah
- $OSTREE --repo=repo commit -b overlay -s 'overlay' --tree=dir=overlay
+ $OSTREE --repo=repo commit ${COMMIT_ARGS} -b overlay -s 'overlay' --tree=dir=overlay
rm overlay -rf
for branch in test2 overlay; do
@@ -548,7 +610,7 @@ rm -rf test2-checkout
mkdir -p test2-checkout
cd test2-checkout
touch should-not-be-fsynced
-$OSTREE commit -b test2 -s "Unfsynced commit" --fsync=false
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Unfsynced commit" --fsync=false
# Run this test only as non-root user. When run as root, the chmod
# won't have any effect.
@@ -572,7 +634,7 @@ mkdir -p test2-checkout
cd test2-checkout
touch blah
stat --printf="%.Y\n" ${test_tmpdir}/repo > ${test_tmpdir}/timestamp-orig.txt
-$OSTREE commit -b test2 -s "Should bump the mtime"
+$OSTREE commit ${COMMIT_ARGS} -b test2 -s "Should bump the mtime"
stat --printf="%.Y\n" ${test_tmpdir}/repo > ${test_tmpdir}/timestamp-new.txt
cd ..
if cmp timestamp-{orig,new}.txt; then
diff --git a/tests/coccinelle.sh b/tests/coccinelle.sh
new file mode 100755
index 00000000..eb22662d
--- /dev/null
+++ b/tests/coccinelle.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+# Run the .cocci files in the tests directory; these act
+# as a blacklist.
+
+set -euo pipefail
+
+. $(dirname $0)/libtest.sh
+
+if ! spatch --version 2>/dev/null; then
+ skip "no spatch; get it from http://coccinelle.lip6.fr/"
+fi
+
+if test -z "${OSTREE_UNINSTALLED_SRCDIR:-}"; then
+ skip "running installed?"
+fi
+
+coccitests=$(ls $(dirname $0)/coccinelle/*.cocci)
+echo "1.."$(echo ${coccitests} | wc -l)
+
+for cocci in $(dirname $0)/coccinelle/*.cocci; do
+ echo "Running: ${cocci}"
+ spatch --very-quiet --dir ${OSTREE_UNINSTALLED_SRCDIR} ${cocci} > cocci.out
+ if test -s cocci.out; then
+ sed -e 's/^/# /' < cocci.out >&2
+ fatal "Failed semantic patch: ${cocci}"
+ fi
+ echo ok ${cocci}
+done
diff --git a/tests/libostreetest.c b/tests/libostreetest.c
index d0eb3e81..cda1649d 100644
--- a/tests/libostreetest.c
+++ b/tests/libostreetest.c
@@ -21,6 +21,8 @@
#include "config.h"
#include
#include
+#include
+#include
#include "libglnx.h"
#include "libostreetest.h"
@@ -90,12 +92,26 @@ ot_test_setup_sysroot (GCancellable *cancellable,
gboolean ret = FALSE;
g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
glnx_unref_object OstreeSysroot *ret_sysroot = NULL;
+ struct statfs stbuf;
if (!ot_test_run_libtest ("setup_os_repository \"archive-z2\" \"syslinux\"", error))
goto out;
- /* Make sure deployments are mutable */
- g_setenv ("OSTREE_SYSROOT_DEBUG", "mutable-deployments", TRUE);
+ { g_autoptr(GString) buf = g_string_new ("mutable-deployments");
+ if (statfs ("/", &stbuf) < 0)
+ return glnx_throw_errno (error), NULL;
+ /* Keep this in sync with the overlayfs bits in libtest.sh */
+#ifndef OVERLAYFS_SUPER_MAGIC
+#define OVERLAYFS_SUPER_MAGIC 0x794c7630
+#endif
+ if (stbuf.f_type == OVERLAYFS_SUPER_MAGIC)
+ {
+ g_print ("libostreetest: detected overlayfs\n");
+ g_string_append (buf, ",no-xattrs");
+ }
+ /* Make sure deployments are mutable */
+ g_setenv ("OSTREE_SYSROOT_DEBUG", buf->str, TRUE);
+ }
ret_sysroot = ostree_sysroot_new (sysroot_path);
diff --git a/tests/libtest.sh b/tests/libtest.sh
index 0126827e..58351f81 100755
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -86,6 +86,18 @@ chmod -R u+w "${test_tmpdir}"
export TEST_GPG_KEYHOME=${test_tmpdir}/gpghome
export OSTREE_GPG_HOME=${test_tmpdir}/gpghome/trusted
+# See comment in ot-builtin-commit.c and https://github.com/ostreedev/ostree/issues/758
+# Also keep this in sync with the bits in libostreetest.c
+echo evaluating for overlayfs...
+case $(stat -f --printf '%T' /) in
+ overlayfs)
+ echo "overlayfs found; enabling OSTREE_NO_XATTRS"
+ export OSTREE_SYSROOT_DEBUG="${OSTREE_SYSROOT_DEBUG},no-xattrs"
+ export OSTREE_NO_XATTRS=1 ;;
+ *) ;;
+esac
+echo done
+
if test -n "${OT_TESTS_DEBUG:-}"; then
set -x
fi
@@ -194,17 +206,20 @@ setup_test_repository () {
oldpwd=`pwd`
- cd ${test_tmpdir}
- mkdir repo
- cd repo
- ot_repo="--repo=`pwd`"
- export OSTREE="${CMD_PREFIX} ostree ${ot_repo}"
- if test -n "$mode"; then
- $OSTREE init --mode=${mode}
- else
- $OSTREE init
+ COMMIT_ARGS=""
+ if [ $mode == "bare-user-only" ] ; then
+ COMMIT_ARGS="--owner-uid=0 --owner-gid=0 --no-xattrs --canonical-permissions"
fi
+ cd ${test_tmpdir}
+ if test -n "${mode}"; then
+ ostree_repo_init repo --mode=${mode}
+ else
+ ostree_repo_init repo
+ fi
+ ot_repo="--repo=$(pwd)/repo"
+ export OSTREE="${CMD_PREFIX} ostree ${ot_repo}"
+
cd ${test_tmpdir}
mkdir files
cd files
@@ -214,7 +229,7 @@ setup_test_repository () {
echo first > firstfile
cd ${test_tmpdir}/files
- $OSTREE commit -b test2 -s "Test Commit 1" -m "Commit body first"
+ $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Test Commit 1" -m "Commit body first"
mkdir baz
echo moo > baz/cow
@@ -226,12 +241,22 @@ setup_test_repository () {
echo x > baz/another/y
cd ${test_tmpdir}/files
- $OSTREE commit -b test2 -s "Test Commit 2" -m "Commit body second"
+ $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Test Commit 2" -m "Commit body second"
$OSTREE fsck -q
cd $oldpwd
}
+# A wrapper which also possibly disables xattrs for CI testing
+ostree_repo_init() {
+ repo=$1
+ shift
+ ${CMD_PREFIX} ostree --repo=${repo} init "$@"
+ if test -n "${OSTREE_NO_XATTRS:-}"; then
+ echo -e 'disable-xattrs=true\n' >> ${repo}/config
+ fi
+}
+
setup_fake_remote_repo1() {
mode=$1
commit_opts=${2:-}
@@ -241,7 +266,7 @@ setup_fake_remote_repo1() {
mkdir ostree-srv
cd ostree-srv
mkdir gnomerepo
- ${CMD_PREFIX} ostree --repo=gnomerepo init --mode=$mode
+ ostree_repo_init gnomerepo --mode=$mode
mkdir gnomerepo-files
cd gnomerepo-files
echo first > firstfile
@@ -284,8 +309,8 @@ setup_exampleos_repo() {
mkdir -p ostree-srv/exampleos/{repo,build-repo}
export ORIGIN_REPO=ostree-srv/exampleos/repo
export ORIGIN_BUILD_REPO=ostree-srv/exampleos/build-repo
- ${CMD_PREFIX} ostree --repo=${ORIGIN_REPO} init --mode=archive
- ${CMD_PREFIX} ostree --repo=${ORIGIN_BUILD_REPO} init --mode=bare-user
+ ostree_repo_init ${ORIGIN_REPO} --mode=archive
+ ostree_repo_init ${ORIGIN_BUILD_REPO} --mode=bare-user
cd ${test_tmpdir}
rm main -rf
mkdir main
@@ -365,7 +390,7 @@ setup_exampleos_repo() {
cd ${test_tmpdir}
rm repo -rf
- ${CMD_PREFIX} ostree --repo=repo init --mode=bare-user
+ ostree_repo_init repo --mode=bare-user
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat ostree-srv/httpd/address)/exampleos/repo
export OSTREE="${CMD_PREFIX} ostree --repo=repo"
}
@@ -413,9 +438,9 @@ setup_os_repository () {
cd ${test_tmpdir}
mkdir testos-repo
if test -n "$mode"; then
- ${CMD_PREFIX} ostree --repo=testos-repo init --mode=${mode}
+ ostree_repo_init testos-repo --mode=${mode}
else
- ${CMD_PREFIX} ostree --repo=testos-repo init
+ ostree_repo_init testos-repo
fi
cd ${test_tmpdir}
diff --git a/tests/pull-test.sh b/tests/pull-test.sh
index f6176079..f2486c31 100644
--- a/tests/pull-test.sh
+++ b/tests/pull-test.sh
@@ -23,7 +23,7 @@ function repo_init() {
cd ${test_tmpdir}
rm repo -rf
mkdir repo
- ${CMD_PREFIX} ostree --repo=repo init
+ ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
}
@@ -50,7 +50,7 @@ echo "ok pull contents"
cd ${test_tmpdir}
mkdir mirrorrepo
-${CMD_PREFIX} ostree --repo=mirrorrepo init --mode=archive-z2
+ostree_repo_init mirrorrepo --mode=archive-z2
${CMD_PREFIX} ostree --repo=mirrorrepo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=mirrorrepo pull --mirror origin main
${CMD_PREFIX} ostree --repo=mirrorrepo fsck
@@ -96,7 +96,7 @@ echo "ok pull commit metadata only (should not apply deltas)"
cd ${test_tmpdir}
mkdir mirrorrepo-local
-${CMD_PREFIX} ostree --repo=mirrorrepo-local init --mode=archive-z2
+ostree_repo_init mirrorrepo-local --mode=archive-z2
${CMD_PREFIX} ostree --repo=mirrorrepo-local remote add --set=gpg-verify=false origin file://$(pwd)/ostree-srv/gnomerepo
${CMD_PREFIX} ostree --repo=mirrorrepo-local pull --mirror origin main
${CMD_PREFIX} ostree --repo=mirrorrepo-local fsck
@@ -114,7 +114,7 @@ echo "ok pull detached metadata"
cd ${test_tmpdir}
mkdir parentpullrepo
-${CMD_PREFIX} ostree --repo=parentpullrepo init --mode=archive-z2
+ostree_repo_init parentpullrepo --mode=archive-z2
${CMD_PREFIX} ostree --repo=parentpullrepo remote add --set=gpg-verify=false origin file://$(pwd)/ostree-srv/gnomerepo
parent_rev=$(ostree --repo=ostree-srv/gnomerepo rev-parse main^)
rev=$(ostree --repo=ostree-srv/gnomerepo rev-parse main)
diff --git a/tests/test-archivez.sh b/tests/test-archivez.sh
index b8793284..836e9180 100755
--- a/tests/test-archivez.sh
+++ b/tests/test-archivez.sh
@@ -29,7 +29,7 @@ setup_test_repository "archive-z2"
cd ${test_tmpdir}
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init
+ostree_repo_init repo2
${CMD_PREFIX} ostree --repo=repo2 remote add --set=gpg-verify=false aremote file://$(pwd)/repo test2
${CMD_PREFIX} ostree --repo=repo2 pull aremote
${CMD_PREFIX} ostree --repo=repo2 rev-parse aremote/test2
diff --git a/tests/test-basic-user-only.sh b/tests/test-basic-user-only.sh
new file mode 100755
index 00000000..a3e63aac
--- /dev/null
+++ b/tests/test-basic-user-only.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 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.
+
+set -euo pipefail
+
+. $(dirname $0)/libtest.sh
+
+setup_test_repository "bare-user-only"
+. $(dirname $0)/basic-test.sh
diff --git a/tests/test-commit-sign.sh b/tests/test-commit-sign.sh
index f963b104..96608e88 100755
--- a/tests/test-commit-sign.sh
+++ b/tests/test-commit-sign.sh
@@ -33,7 +33,7 @@ oldpwd=`pwd`
mkdir ostree-srv
cd ostree-srv
mkdir gnomerepo
-${CMD_PREFIX} ostree --repo=gnomerepo init --mode="archive-z2"
+ostree_repo_init gnomerepo --mode="archive-z2"
mkdir gnomerepo-files
cd gnomerepo-files
echo first > firstfile
@@ -67,7 +67,7 @@ cp -a ${repopath} ${repopath}.orig
# Set OSTREE_GPG_HOME to a place with no keyrings, we shouldn't trust the signature
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
if env OSTREE_GPG_HOME=${test_tmpdir} ${CMD_PREFIX} ostree --repo=repo pull origin main; then
assert_not_reached "pull with no trusted GPG keys unexpectedly succeeded!"
@@ -77,7 +77,7 @@ rm repo -rf
# And a test case with valid signature
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull origin main
${CMD_PREFIX} ostree --repo=repo show --gpg-verify-remote=origin main | grep -o 'Found [[:digit:]] signature' > show-verify-remote
@@ -90,7 +90,7 @@ find ${test_tmpdir}/ostree-srv/gnomerepo -name '*.commitmeta' | while read fname
echo borkborkbork > ${fname};
done
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
if ${CMD_PREFIX} ostree --repo=repo pull origin main; then
assert_not_reached "pull with corrupted signature unexpectedly succeeded!"
@@ -101,7 +101,7 @@ rm repo -rf
# verification off
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull origin main
rm repo -rf
@@ -114,7 +114,7 @@ echo secret > signme
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "Don't forget to sign me!"
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull origin main
if ${CMD_PREFIX} ostree --repo=repo show main | grep -o 'Found [[:digit:]] signature'; then
diff --git a/tests/test-delta.sh b/tests/test-delta.sh
index b9883830..84320b80 100755
--- a/tests/test-delta.sh
+++ b/tests/test-delta.sh
@@ -29,7 +29,7 @@ morebindatafiles="false ls"
echo '1..12'
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
mkdir files
for bin in ${bindatafiles}; do
@@ -121,7 +121,7 @@ if ${CMD_PREFIX} ostree --repo=repo static-delta generate --from=${origrev} --to
assert_not_reached "static-delta generate --from=${origrev} --empty unexpectedly succeeded"
fi
-${CMD_PREFIX} ostree --repo=temp-repo init --mode=archive
+ostree_repo_init temp-repo --mode=archive
${CMD_PREFIX} ostree --repo=temp-repo pull-local repo
${CMD_PREFIX} ostree --repo=temp-repo static-delta generate --empty --to=${newrev} --filename=some.delta
assert_has_file some.delta
@@ -168,7 +168,7 @@ echo 'ok heuristic endian detection'
${CMD_PREFIX} ostree --repo=repo summary -u
-mkdir repo2 && ${CMD_PREFIX} ostree --repo=repo2 init --mode=bare-user
+mkdir repo2 && ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local --require-static-deltas repo ${newrev}
${CMD_PREFIX} ostree --repo=repo2 fsck
${CMD_PREFIX} ostree --repo=repo2 ls ${newrev} >/dev/null
@@ -176,7 +176,7 @@ ${CMD_PREFIX} ostree --repo=repo2 ls ${newrev} >/dev/null
echo 'ok pull delta'
rm repo2 -rf
-mkdir repo2 && ${CMD_PREFIX} ostree --repo=repo2 init --mode=bare-user
+mkdir repo2 && ostree_repo_init repo2 --mode=bare-user
mkdir deltadir
deltaprefix=$(get_assert_one_direntry_matching repo/deltas '.')
@@ -194,7 +194,7 @@ ${CMD_PREFIX} ostree --repo=repo static-delta generate --from=${origrev} --to=${
assert_not_has_file repo/deltas/${deltaprefix}/${deltadir}/0
rm repo2 -rf
-mkdir repo2 && ostree --repo=repo2 init --mode=bare-user
+ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local repo ${origrev}
${CMD_PREFIX} ostree --repo=repo2 ls ${origrev} >/dev/null
@@ -236,7 +236,7 @@ echo 'ok generate + show empty delta part'
${CMD_PREFIX} ostree --repo=repo summary -u
rm -rf repo2
-mkdir repo2 && ${CMD_PREFIX} ostree --repo=repo2 init --mode=bare-user
+mkdir repo2 && ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local repo ${newrev}
${CMD_PREFIX} ostree --repo=repo2 pull-local --require-static-deltas repo ${samerev}
${CMD_PREFIX} ostree --repo=repo2 fsck
diff --git a/tests/test-demo-buildsystem.sh b/tests/test-demo-buildsystem.sh
index cc926979..99ddc505 100755
--- a/tests/test-demo-buildsystem.sh
+++ b/tests/test-demo-buildsystem.sh
@@ -66,9 +66,9 @@ exampleos_recompose() {
packages="bash systemd"
mkdir build-repo
-${CMD_PREFIX} ostree --repo=build-repo init --mode=bare-user
+ostree_repo_init build-repo --mode=bare-user
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
# Our FUSE mount point
mkdir mnt
diff --git a/tests/test-local-pull-depth.sh b/tests/test-local-pull-depth.sh
index e89d0914..fef2f2dc 100755
--- a/tests/test-local-pull-depth.sh
+++ b/tests/test-local-pull-depth.sh
@@ -27,7 +27,7 @@ echo "1..1"
cd ${test_tmpdir}
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init --mode="archive-z2"
+ostree_repo_init repo2 --mode="archive-z2"
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
find repo2/objects -name '*.commit' | wc -l > commitcount
diff --git a/tests/test-local-pull.sh b/tests/test-local-pull.sh
index 9e8c8a00..43b96010 100755
--- a/tests/test-local-pull.sh
+++ b/tests/test-local-pull.sh
@@ -33,14 +33,14 @@ echo "ok setup"
cd ${test_tmpdir}
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init --mode="bare-user"
+ostree_repo_init repo2 --mode="bare-user"
${CMD_PREFIX} ostree --repo=repo2 pull-local repo
${CMD_PREFIX} ostree --repo=repo2 fsck
echo "ok pull-local z2 to bare-user"
mkdir repo3
-${CMD_PREFIX} ostree --repo=repo3 init --mode="archive-z2"
+ostree_repo_init repo3 --mode="archive-z2"
${CMD_PREFIX} ostree --repo=repo3 pull-local repo2
${CMD_PREFIX} ostree --repo=repo3 fsck
echo "ok pull-local bare-user to z2"
@@ -62,7 +62,7 @@ cmp checkout1.files checkout3.files
echo "ok checkouts same"
mkdir repo4
-${CMD_PREFIX} ostree --repo=repo4 init --mode="archive-z2"
+ostree_repo_init repo4 --mode="archive-z2"
${CMD_PREFIX} ostree --repo=repo4 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
if ${CMD_PREFIX} ostree --repo=repo4 pull-local --remote=origin --gpg-verify repo test2 2>&1; then
assert_not_reached "GPG verification unexpectedly succeeded"
@@ -72,13 +72,13 @@ echo "ok --gpg-verify with no signature"
${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME} test2 ${TEST_GPG_KEYID_1}
mkdir repo5
-${CMD_PREFIX} ostree --repo=repo5 init --mode="archive-z2"
+ostree_repo_init repo5 --mode="archive-z2"
${CMD_PREFIX} ostree --repo=repo5 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
${CMD_PREFIX} ostree --repo=repo5 pull-local --remote=origin --gpg-verify repo test2
echo "ok --gpg-verify"
mkdir repo6
-${CMD_PREFIX} ostree --repo=repo6 init --mode="archive-z2"
+ostree_repo_init repo6 --mode="archive-z2"
${CMD_PREFIX} ostree --repo=repo6 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo
if ${CMD_PREFIX} ostree --repo=repo6 pull-local --remote=origin --gpg-verify-summary repo test2 2>&1; then
assert_not_reached "GPG summary verification with no summary unexpectedly succeeded"
@@ -97,7 +97,7 @@ ${CMD_PREFIX} ostree --repo=repo6 pull-local --remote=origin --gpg-verify-summar
echo "ok --gpg-verify-summary"
mkdir repo7
-${CMD_PREFIX} ostree --repo=repo7 init --mode="archive-z2"
+ostree_repo_init repo7 --mode="archive-z2"
${CMD_PREFIX} ostree --repo=repo7 pull-local repo
${CMD_PREFIX} ostree --repo=repo7 fsck
for src_object in `find repo/objects -name '*.filez'`; do
diff --git a/tests/test-oldstyle-partial.sh b/tests/test-oldstyle-partial.sh
index a578e7d2..08be69d3 100755
--- a/tests/test-oldstyle-partial.sh
+++ b/tests/test-oldstyle-partial.sh
@@ -28,7 +28,7 @@ echo '1..1'
cd ${test_tmpdir}
rm repo -rf
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull origin main --subpath /baz
diff --git a/tests/test-parent.sh b/tests/test-parent.sh
index d1f5d7c9..4d5520dd 100755
--- a/tests/test-parent.sh
+++ b/tests/test-parent.sh
@@ -32,7 +32,7 @@ export OSTREE_GPG_SIGN="${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME}"
cd ${test_tmpdir}
# Create a repo
-${CMD_PREFIX} ostree --repo=repo2 init
+ostree_repo_init repo2
${CMD_PREFIX} ostree --repo=repo2 remote add --gpg-import=${test_tmpdir}/gpghome/trusted/pubring.gpg --set=gpg-verify=true aremote file://$(pwd)/repo test2
# Create a repo with repo2 as parent
diff --git a/tests/test-prune.sh b/tests/test-prune.sh
index 51ec7948..0781b543 100755
--- a/tests/test-prune.sh
+++ b/tests/test-prune.sh
@@ -29,7 +29,7 @@ echo '1..5'
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
mkdir -p tree/root
@@ -142,7 +142,7 @@ assert_file_has_content deltascount "^1$"
echo "ok prune"
rm repo -rf
-${CMD_PREFIX} ostree --repo=repo init --mode=bare-user
+ostree_repo_init repo --mode=bare-user
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull --depth=-1 --commit-metadata-only origin test
${CMD_PREFIX} ostree --repo=repo prune
@@ -158,7 +158,7 @@ assert_has_n_objects() {
cd ${test_tmpdir}
for repo in repo child-repo tmp-repo; do
rm ${repo} -rf
- ${CMD_PREFIX} ostree --repo=${repo} init --mode=archive
+ ostree_repo_init ${repo} --mode=archive
done
echo parent=${test_tmpdir}/repo >> child-repo/config
mkdir files
@@ -189,7 +189,7 @@ echo "ok prune with parent repo"
# would interact. We make a new repo test suite, then clone it
# for "subtests" below with reinitialize_datesnap_repo()
rm repo datetest-snapshot-repo -rf
-${CMD_PREFIX} ostree --repo=datetest-snapshot-repo init --mode=archive
+ostree_repo_init datetest-snapshot-repo --mode=archive
# Some ancient commits on the both a stable/dev branch
for day in $(seq 5); do
${CMD_PREFIX} ostree --repo=datetest-snapshot-repo commit --branch=stable -m test -s "old stable build $day" tree --timestamp="October $day 1985"
@@ -206,7 +206,7 @@ assert_file_has_content commitcount "^16$"
# Snapshot the above
reinitialize_datesnap_repo() {
rm repo -rf
- ${CMD_PREFIX} ostree --repo=repo init --mode=archive
+ ostree_repo_init repo --mode=archive
${CMD_PREFIX} ostree --repo=repo pull-local --depth=-1 datetest-snapshot-repo
}
diff --git a/tests/test-pull-commit-only.sh b/tests/test-pull-commit-only.sh
index 775b2f71..0cbdebc8 100755
--- a/tests/test-pull-commit-only.sh
+++ b/tests/test-pull-commit-only.sh
@@ -27,7 +27,7 @@ echo '1..1'
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull --commit-metadata-only origin main
diff --git a/tests/test-pull-contenturl.sh b/tests/test-pull-contenturl.sh
index d74d619b..5d72fb23 100755
--- a/tests/test-pull-contenturl.sh
+++ b/tests/test-pull-contenturl.sh
@@ -57,7 +57,7 @@ echo "http://127.0.0.1:${content_port}" > ${test_tmpdir}/httpd-content-address
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
if has_gpgme; then VERIFY=true; else VERIFY=false; fi
${CMD_PREFIX} ostree --repo=repo remote add origin \
--set=gpg-verify=$VERIFY --set=gpg-verify-summary=$VERIFY \
diff --git a/tests/test-pull-corruption.sh b/tests/test-pull-corruption.sh
index 646113a1..89d89b75 100755
--- a/tests/test-pull-corruption.sh
+++ b/tests/test-pull-corruption.sh
@@ -38,7 +38,7 @@ do_corrupt_pull_test() {
cd ${test_tmpdir}
rm repo -rf
mkdir repo
- ${CMD_PREFIX} ostree --repo=repo init
+ ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
if ${CMD_PREFIX} ostree --repo=repo pull origin main; then
assert_not_reached "pull unexpectedly succeeded!"
diff --git a/tests/test-pull-depth.sh b/tests/test-pull-depth.sh
index 7a52f9cb..372bef49 100755
--- a/tests/test-pull-depth.sh
+++ b/tests/test-pull-depth.sh
@@ -27,7 +27,7 @@ echo '1..1'
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull --depth=0 origin main
diff --git a/tests/test-pull-large-metadata.sh b/tests/test-pull-large-metadata.sh
index 0fe02031..2fdf0d91 100755
--- a/tests/test-pull-large-metadata.sh
+++ b/tests/test-pull-large-metadata.sh
@@ -32,7 +32,7 @@ dd if=/dev/zero bs=1M count=20 of=ostree-srv/gnomerepo/objects/$(echo $rev | cut
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
if ${CMD_PREFIX} ostree --repo=repo pull origin main 2>pulllog.txt 1>&2; then
diff --git a/tests/test-pull-metalink.sh b/tests/test-pull-metalink.sh
index 07d619df..171c8d4b 100755
--- a/tests/test-pull-metalink.sh
+++ b/tests/test-pull-metalink.sh
@@ -68,7 +68,7 @@ EOF
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin metalink=$(cat metalink-httpd-address)/metalink.xml
${CMD_PREFIX} ostree --repo=repo pull origin:main
${CMD_PREFIX} ostree --repo=repo rev-parse origin:main
@@ -87,7 +87,7 @@ test_metalink_pull_error() {
msg=$1
rm repo -rf
mkdir repo
- ${CMD_PREFIX} ostree --repo=repo init
+ ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin metalink=$(cat metalink-httpd-address)/metalink.xml
if ${CMD_PREFIX} ostree --repo=repo pull origin:main 2>err.txt; then
assert_not_reached "pull unexpectedly succeeded"
@@ -157,7 +157,7 @@ EOF
cd ${test_tmpdir}
rm repo -rf
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin metalink=$(cat metalink-httpd-address)/metalink.xml
${CMD_PREFIX} ostree --repo=repo pull origin:main
${CMD_PREFIX} ostree --repo=repo rev-parse origin:main
diff --git a/tests/test-pull-mirror-summary.sh b/tests/test-pull-mirror-summary.sh
index 1ef6a09c..883c0245 100755
--- a/tests/test-pull-mirror-summary.sh
+++ b/tests/test-pull-mirror-summary.sh
@@ -41,7 +41,7 @@ ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u
prev_dir=`pwd`
cd ${test_tmpdir}
-${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull --mirror origin
assert_has_file repo/summary
@@ -69,15 +69,13 @@ cd $prev_dir
cd ${test_tmpdir}
rm -rf repo
-mkdir repo
-${OSTREE} --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
${OSTREE} --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
echo "ok pull mirror without checking signed summary"
cd ${test_tmpdir}
rm -rf repo
-mkdir repo
-${OSTREE} --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
${OSTREE} --repo=repo remote add --set=gpg-verify-summary=true origin $(cat httpd-address)/ostree/gnomerepo
if ${OSTREE} --repo=repo pull --mirror origin 2>err.txt; then
assert_not_reached "Mirroring unexpectedly succeeded"
@@ -88,8 +86,7 @@ ${OSTREE} --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u ${COMMIT_SIGN}
cd ${test_tmpdir}
rm -rf repo
-mkdir repo
-${OSTREE} --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
${OSTREE} --repo=repo remote add --set=gpg-verify-summary=true origin $(cat httpd-address)/ostree/gnomerepo
${OSTREE} --repo=repo pull --mirror origin
assert_has_file repo/summary
@@ -102,7 +99,7 @@ truncate --size=1 ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig
cd ${test_tmpdir}
rm -rf repo
mkdir repo
-${OSTREE} --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
${OSTREE} --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
${OSTREE} --repo=repo pull --mirror origin
assert_has_file repo/summary
diff --git a/tests/test-pull-mirrorlist.sh b/tests/test-pull-mirrorlist.sh
index 13f40e7a..35320506 100755
--- a/tests/test-pull-mirrorlist.sh
+++ b/tests/test-pull-mirrorlist.sh
@@ -72,7 +72,7 @@ EOF
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add origin --no-gpg-verify \
mirrorlist=$(cat httpd-address)/ostree/mirrorlist
${CMD_PREFIX} ostree --repo=repo pull origin:main
@@ -84,7 +84,7 @@ echo "ok pull objects from mirrorlist"
cd ${test_tmpdir}
rm -rf repo
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add origin --no-gpg-verify \
--contenturl=mirrorlist=$(cat httpd-address)/ostree/mirrorlist \
$(cat httpd-address)/ostree/gnomerepo
@@ -97,7 +97,7 @@ echo "ok pull objects from contenturl mirrorlist"
cd ${test_tmpdir}
rm -rf repo
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add origin --no-gpg-verify \
--contenturl=mirrorlist=$(cat httpd-address)/ostree/mirrorlist \
mirrorlist=$(cat httpd-address)/ostree/mirrorlist
diff --git a/tests/test-pull-override-url.sh b/tests/test-pull-override-url.sh
index 928013a5..16f79a02 100755
--- a/tests/test-pull-override-url.sh
+++ b/tests/test-pull-override-url.sh
@@ -34,7 +34,7 @@ gnomerepo_url="$(cat httpd-address)/ostree/gnomerepo"
mkdir mirror-srv
cd mirror-srv
mkdir gnomerepo
-${CMD_PREFIX} ostree --repo=gnomerepo init --mode "archive-z2"
+ostree_repo_init gnomerepo --mode "archive-z2"
${CMD_PREFIX} ostree --repo=gnomerepo remote add --set=gpg-verify=false origin ${gnomerepo_url}
${CMD_PREFIX} ostree --repo=gnomerepo pull --mirror --depth=-1 origin main
@@ -57,7 +57,7 @@ echo "http://127.0.0.1:${port}" > ${test_tmpdir}/mirror-httpd-address
cd ${test_tmpdir}
mirrorrepo_url="$(cat mirror-httpd-address)/ostree/gnomerepo"
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin ${gnomerepo_url}
rm -rf ${test_tmpdir}/ostree-srv/gnomerepo
if ${CMD_PREFIX} ostree --repo=repo pull --depth=-1 origin main
diff --git a/tests/test-pull-repeated.sh b/tests/test-pull-repeated.sh
index 8934e430..108c2057 100755
--- a/tests/test-pull-repeated.sh
+++ b/tests/test-pull-repeated.sh
@@ -27,7 +27,7 @@ COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}" --random-500s=50
cd ${test_tmpdir}
-${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
for x in $(seq 200); do
if ${CMD_PREFIX} ostree --repo=repo pull --mirror origin main 2>err.txt; then
diff --git a/tests/test-pull-resume.sh b/tests/test-pull-resume.sh
index 06cd0793..51746b9c 100755
--- a/tests/test-pull-resume.sh
+++ b/tests/test-pull-resume.sh
@@ -31,7 +31,7 @@ cp -a ${repopath} ${repopath}.orig
cd ${test_tmpdir}
rm repo -rf
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
maxtries=`find ${repopath}/objects | wc -l`
diff --git a/tests/test-pull-subpath.sh b/tests/test-pull-subpath.sh
index dba8b495..27eb64be 100755
--- a/tests/test-pull-subpath.sh
+++ b/tests/test-pull-subpath.sh
@@ -33,7 +33,7 @@ for remoteurl in $(cat httpd-address)/ostree/gnomerepo \
cd ${test_tmpdir}
rm repo -rf
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin ${remoteurl}
${CMD_PREFIX} ostree --repo=repo pull --subpath=/baz/deeper --subpath=/baz/another origin main
@@ -58,7 +58,7 @@ echo "ok subpaths"
rm -rf repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin ${remoteurl}
# Pull a directory which is not the first in the commit (/baz/another is before)
diff --git a/tests/test-pull-summary-sigs.sh b/tests/test-pull-summary-sigs.sh
index 2dcfbd65..016ee4b9 100755
--- a/tests/test-pull-summary-sigs.sh
+++ b/tests/test-pull-summary-sigs.sh
@@ -41,7 +41,7 @@ ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u
prev_dir=`pwd`
cd ${test_tmpdir}
-${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2
+ostree_repo_init repo --mode=archive-z2
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=repo pull --mirror origin
assert_has_file repo/summary
@@ -66,7 +66,7 @@ repo_reinit () {
cd ${test_tmpdir}
rm -rf repo
mkdir repo
- ${OSTREE} --repo=repo init --mode=archive-z2
+ ostree_repo_init repo --mode=archive-z2
${OSTREE} --repo=repo remote add --set=gpg-verify-summary=true origin $(cat httpd-address)/ostree/gnomerepo
}
diff --git a/tests/test-pull-untrusted.sh b/tests/test-pull-untrusted.sh
index 53636224..247a34f9 100755
--- a/tests/test-pull-untrusted.sh
+++ b/tests/test-pull-untrusted.sh
@@ -28,7 +28,7 @@ setup_test_repository "bare"
cd ${test_tmpdir}
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init --mode="bare"
+ostree_repo_init repo2 --mode="bare"
${CMD_PREFIX} ostree --repo=repo2 --untrusted pull-local repo
@@ -52,7 +52,7 @@ done
rm -rf repo2
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init --mode="bare"
+ostree_repo_init repo2 --mode="bare"
if ${CMD_PREFIX} ostree --repo=repo2 pull-local repo; then
echo "ok trusted pull with corruption succeeded"
else
@@ -61,7 +61,7 @@ fi
rm -rf repo2
mkdir repo2
-${CMD_PREFIX} ostree --repo=repo2 init --mode="bare"
+ostree_repo_init repo2 --mode="bare"
if ${CMD_PREFIX} ostree --repo=repo2 pull-local --untrusted repo; then
assert_not_reached "corrupted untrusted pull unexpectedly failed!"
else
diff --git a/tests/test-refs.sh b/tests/test-refs.sh
index ee7841bd..d4db0013 100755
--- a/tests/test-refs.sh
+++ b/tests/test-refs.sh
@@ -27,7 +27,7 @@ echo '1..1'
cd ${test_tmpdir}
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
mkdir -p tree/root
touch tree/root/a
diff --git a/tests/test-remote-cookies.sh b/tests/test-remote-cookies.sh
index ab2bf263..14e3dd12 100755
--- a/tests/test-remote-cookies.sh
+++ b/tests/test-remote-cookies.sh
@@ -36,7 +36,7 @@ assert_fail (){
cd ${test_tmpdir}
rm repo -rf
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
# Sanity check the setup, without cookies the pull should fail
diff --git a/tests/test-remote-gpg-import.sh b/tests/test-remote-gpg-import.sh
index 4429d8bc..a5803785 100755
--- a/tests/test-remote-gpg-import.sh
+++ b/tests/test-remote-gpg-import.sh
@@ -30,7 +30,7 @@ echo "1..4"
cd ${test_tmpdir}
mkdir repo
-${OSTREE} init
+ostree_repo_init repo
#----------------------------------------------
# Test synchronicity of keyring file and remote
diff --git a/tests/test-remote-headers.sh b/tests/test-remote-headers.sh
index bca46204..6902cefb 100755
--- a/tests/test-remote-headers.sh
+++ b/tests/test-remote-headers.sh
@@ -38,7 +38,7 @@ assert_fail (){
cd ${test_tmpdir}
rm repo -rf
mkdir repo
-${CMD_PREFIX} ostree --repo=repo init
+ostree_repo_init repo
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
# Sanity check the setup, without headers the pull should fail
diff --git a/tests/test-rollsum-cli.c b/tests/test-rollsum-cli.c
index 4f24477c..256c79fe 100644
--- a/tests/test-rollsum-cli.c
+++ b/tests/test-rollsum-cli.c
@@ -21,13 +21,13 @@
#include "config.h"
#include "ostree-rollsum.h"
-#include
-#include
+
+#include "libglnx.h"
int
main (int argc, char **argv)
{
- GError *local_error = NULL;
+ g_autoptr(GError) local_error = NULL;
GError **error = &local_error;
GBytes *from_bytes = NULL;
GBytes *to_bytes = NULL;
@@ -39,7 +39,7 @@ main (int argc, char **argv)
g_setenv ("GIO_USE_VFS", "local", TRUE);
if (argc < 3)
- exit (EXIT_FAILURE);
+ return 1;
from_path = argv[1];
to_path = argv[2];
@@ -66,7 +66,6 @@ main (int argc, char **argv)
if (local_error)
{
g_printerr ("%s\n", local_error->message);
- g_error_free (local_error);
return 1;
}
return 0;
diff --git a/tests/test-xattrs.sh b/tests/test-xattrs.sh
index cdc06e87..ae7ae39f 100755
--- a/tests/test-xattrs.sh
+++ b/tests/test-xattrs.sh
@@ -21,6 +21,9 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
+skip "We don't really have a use case for committing user. xattrs right now. See also https://github.com/ostreedev/ostree/issues/758"
+
+# Dead code below
skip_without_user_xattrs
echo "1..2"