summaryrefslogtreecommitdiff
path: root/Makefile-switchroot.am
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2017-05-11 14:54:12 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2017-05-16 16:13:05 +0000
commit30705889cb867c18cdb7fed8e55dc46477c069fa (patch)
treeb6247fa4e4d51ad7a44bfef90381f3aad47c9d52 /Makefile-switchroot.am
parentd815ba2a81ad14d9d4edc31dcd282dcc2a3a8fb9 (diff)
downloadostree-30705889cb867c18cdb7fed8e55dc46477c069fa.tar.gz
Switch to using a systemd generator for /var
If one wants to set up a mount for `/var` in `/etc/fstab`, it won't be mounted since `ostree-prepare-root` set up a bind mount for `/var` to `/sysroot/ostree/$stateroot/var`, and systemd will take the already extant mount over what's in `/etc/fstab`. There are a few options to fix this, but what I settled on is parsing `/etc/fstab` in a generator (exactly like `systemd-fstab-generator` does), except here we look for an explicit mount for `/var`, and if one *isn't* found, synthesize the default ostree mount to the stateroot. Another nice property is that if an admin creates a `var.mount` unit in `/etc` for example, that will also override our mount. Note that today ostree doesn't hard depend on systemd, so this behavior only kicks in if we're built with systemd *and* libmount support (for parsing `/etc/fstab`). I didn't really test that case though. Initially I started writing this as a "pure libc" program, but at one point decided to use `libostree.so` to find the booted deployment. That didn't work out because `/boot` wasn't necessarily mounted and hence we couldn't find the bootloader config. A leftover artifact from this is that the generator code calls into libostree via the "cmd private" infrastructure. But it's an easy way to share code, and doesn't hurt. Closes: #859 Approved by: jlebon
Diffstat (limited to 'Makefile-switchroot.am')
-rw-r--r--Makefile-switchroot.am19
1 files changed, 17 insertions, 2 deletions
diff --git a/Makefile-switchroot.am b/Makefile-switchroot.am
index 6fd2f820..dd24010e 100644
--- a/Makefile-switchroot.am
+++ b/Makefile-switchroot.am
@@ -27,6 +27,7 @@ ostree_prepare_root_SOURCES = \
src/switchroot/ostree-mount-util.h \
src/switchroot/ostree-prepare-root.c \
$(NULL)
+ostree_prepare_root_CPPFLAGS = $(AM_CPPFLAGS)
if BUILDOPT_USE_STATIC_COMPILER
# ostree-prepare-root can be used as init in a system without a populated /lib.
@@ -45,7 +46,6 @@ ostree-prepare-root : $(ostree_prepare_root_SOURCES)
$(STATIC_COMPILER) -o $@ -static $(ostree_prepare_root_SOURCES) $(AM_CPPFLAGS) $(AM_CFLAGS) $(DEFAULT_INCLUDES)
else
ostree_boot_PROGRAMS += ostree-prepare-root
-
ostree_prepare_root_CFLAGS = $(AM_CFLAGS) -Isrc/switchroot
endif
@@ -53,4 +53,19 @@ ostree_remount_SOURCES = \
src/switchroot/ostree-mount-util.h \
src/switchroot/ostree-remount.c \
$(NULL)
-ostree_remount_CFLAGS = $(AM_CFLAGS) -Isrc/switchroot
+ostree_remount_CPPFLAGS = $(AM_CPPFLAGS) -Isrc/switchroot
+
+# This is the "new mode" of using a generator for /var; see
+# https://github.com/ostreedev/ostree/issues/855
+if BUILDOPT_SYSTEMD_AND_LIBMOUNT
+ostree_prepare_root_CPPFLAGS += -DHAVE_SYSTEMD_AND_LIBMOUNT=1
+ostree_remount_CPPFLAGS += -DHAVE_SYSTEMD_AND_LIBMOUNT=1
+
+systemdsystemgenerator_PROGRAMS = ostree-system-generator
+GITIGNOREFILES += $(systemdsystemgenerator_PROGRAMS)
+ostree_system_generator_SOURCES = src/switchroot/ostree-mount-util.h \
+ src/switchroot/ostree-system-generator.c
+ostree_system_generator_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libostree
+ostree_system_generator_CFLAGS = $(AM_CFLAGS) $(OT_INTERNAL_GIO_UNIX_CFLAGS)
+ostree_system_generator_LDADD = $(AM_LDFLAGS) libglnx.la libostree-1.la $(OT_INTERNAL_GIO_UNIX_LIBS)
+endif