diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..e5084aff --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libglnx"] + path = libglnx + url = https://git.gnome.org/browse/libglnx diff --git a/Makefile-rpm-ostree.am b/Makefile-rpm-ostree.am index 78821a3e..8716fdc6 100644 --- a/Makefile-rpm-ostree.am +++ b/Makefile-rpm-ostree.am @@ -46,8 +46,8 @@ librpmostree_la_SOURCES += \ src/rpmostree-treepkgdiff.h \ $(NULL) endif -librpmostree_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS) -librpmostree_la_LIBADD = $(AM_LDFLAGS) $(PKGDEP_RPMOSTREE_LIBS) $(CAP_LIBS) +librpmostree_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src -I$(libglnx_srcpath) -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS) +librpmostree_la_LIBADD = $(AM_LDFLAGS) $(PKGDEP_RPMOSTREE_LIBS) libglnx.la $(CAP_LIBS) rpm_ostree_SOURCES = src/main.c \ src/rpmostree-builtins.h \ @@ -70,7 +70,7 @@ rpm_ostree_SOURCES += \ $(NULL) endif -rpm_ostree_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS) +rpm_ostree_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src -I$(libglnx_srcpath) -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS) rpm_ostree_LDADD = $(AM_LDFLAGS) $(PKGDEP_RPMOSTREE_LIBS) librpmostree.la privdatadir=$(pkglibdir) diff --git a/Makefile.am b/Makefile.am index a24a5642..1d05be4a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,6 +29,12 @@ AM_CFLAGS += $(WARN_CFLAGS) EXTRA_DIST += autogen.sh COPYING +libglnx_srcpath := $(srcdir)/libglnx +libglnx_cflags := $(PKGDEP_GIO_UNIX_CFLAGS) -I$(libglnx_srcpath) +libglnx_libs := $(PKGDEP_GIO_UNIX_LIBS) + +include libglnx/Makefile-libglnx.am +noinst_LTLIBRARIES += libglnx.la include Makefile-rpm-ostree.am include Makefile-tests.am include Makefile-man.am diff --git a/libglnx b/libglnx new file mode 160000 index 00000000..ba67dd39 --- /dev/null +++ b/libglnx @@ -0,0 +1 @@ +Subproject commit ba67dd39a7d5cc779f83bb22512740cdb4c61b33 diff --git a/src/rpmostree-cleanup.h b/src/rpmostree-cleanup.h index 81836290..d7efc859 100644 --- a/src/rpmostree-cleanup.h +++ b/src/rpmostree-cleanup.h @@ -34,6 +34,7 @@ #include "rpmostree-util.h" #include "libgsystem.h" +#include "libglnx.h" GS_DEFINE_CLEANUP_FUNCTION0(HySack, _cleanup_hy_sack_free, hy_sack_free); GS_DEFINE_CLEANUP_FUNCTION0(HyQuery, _cleanup_hy_query_free, hy_query_free); diff --git a/src/rpmostree-compose-builtin-tree.c b/src/rpmostree-compose-builtin-tree.c index 5d1127b7..ab73d017 100644 --- a/src/rpmostree-compose-builtin-tree.c +++ b/src/rpmostree-compose-builtin-tree.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "rpmostree-compose-builtins.h" @@ -87,6 +88,7 @@ typedef struct { GPtrArray *treefile_context_dirs; GFile *workdir; + int workdir_dfd; OstreeRepo *repo; char *previous_checksum; @@ -595,7 +597,6 @@ rpmostree_compose_builtin_tree (int argc, gs_unref_object GFile *previous_root = NULL; gs_free char *previous_checksum = NULL; gs_unref_object GFile *yumroot = NULL; - gs_unref_object GFile *targetroot = NULL; gs_unref_object GFile *yumroot_varcache = NULL; gs_unref_object OstreeRepo *repo = NULL; gs_unref_ptrarray GPtrArray *bootstrap_packages = NULL; @@ -703,6 +704,10 @@ rpmostree_compose_builtin_tree (int argc, } } + if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (self->workdir), + FALSE, &self->workdir_dfd, error)) + goto out; + if (opt_cachedir) { cachedir = g_file_new_for_path (opt_cachedir); @@ -717,12 +722,9 @@ rpmostree_compose_builtin_tree (int argc, goto out; } - if (chdir (gs_file_get_path_cached (self->workdir)) != 0) + if (fchdir (self->workdir_dfd) != 0) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "Failed to chdir to '%s': %s", - gs_file_get_path_cached (self->workdir), - strerror (errno)); + glnx_set_error_from_errno (error); goto out; } @@ -782,9 +784,8 @@ rpmostree_compose_builtin_tree (int argc, self->previous_checksum = previous_checksum; yumroot = g_file_get_child (self->workdir, "rootfs.tmp"); - if (!gs_shutil_rm_rf (yumroot, cancellable, error)) + if (!glnx_shutil_rm_rf_at (self->workdir_dfd, "rootfs.tmp", cancellable, error)) goto out; - targetroot = g_file_get_child (self->workdir, "rootfs"); if (json_object_has_member (treefile, "automatic_version_prefix") && !compose_strv_contains_prefix (opt_metadata_strings, "version="))