aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorGravatar Yann E. MORIN <yann.morin.1998@free.fr>2018-03-31 11:05:59 +0200
committerGravatar Peter Korsgaard <peter@korsgaard.com>2018-03-31 20:53:06 +0200
commitbb2a57a17a71a53f823e2609ba08fa8c6bebe24a (patch)
tree20f436fbdf2f501c20c3bf262f2b2ed7f6a9af3b /fs
parent118534fe54b48532024b7883a46988b4e08671bc (diff)
downloadbuildroot-bb2a57a17a71a53f823e2609ba08fa8c6bebe24a.tar.gz
buildroot-bb2a57a17a71a53f823e2609ba08fa8c6bebe24a.tar.bz2
fs: run packages' filesystem hooks in a copy of target/
Currently, some packages may register hooks to be run just before and just after the generic tarball image is generated, because they need to prepare the filesystem for read-only or read-write operation. However, this means that, if any of the hooks or the image generation fails, the target directory is left in a dangling, inconsistent state. We fix that by doing a copy of target/, run the hooks on that copy, generate the generic tarball image out of that, and get rid of the copy. This way, we can guarantee consistency of the target directory, and we can even ditch support for post-fs hooks (those that restore target/). Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Cc: Arnout Vandecappelle <arnout@mind.be> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/common.mk7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/common.mk b/fs/common.mk
index 224ea5ab69..1d7c78dd45 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -58,17 +58,20 @@ endef
.PHONY: rootfs-common
rootfs-common: $(ROOTFS_COMMON_TAR)
+# Emulate being in a filesystem, so that we can have our own TARGET_DIR.
+ROOTFS_COMMON_TARGET_DIR = $(FS_DIR)/target
+
ROOTFS_COMMON_DEPENDENCIES = \
host-fakeroot host-makedevs \
$(if $(PACKAGES_USERS)$(ROOTFS_USERS_TABLES),host-mkpasswd)
-# When doing the common tarball, we're not really doing a rootfs.
-$(ROOTFS_COMMON_TAR): ROOTFS=
+$(ROOTFS_COMMON_TAR): ROOTFS=COMMON
$(ROOTFS_COMMON_TAR): FAKEROOT_SCRIPT=$(FS_DIR)/fakeroot.fs
$(ROOTFS_COMMON_TAR): $(ROOTFS_COMMON_DEPENDENCIES) target-finalize
@$(call MESSAGE,"Generating common rootfs tarball")
rm -rf $(FS_DIR)
mkdir -p $(FS_DIR)
+ rsync -au $(BASE_TARGET_DIR)/ $(TARGET_DIR)
echo '#!/bin/sh' > $(FAKEROOT_SCRIPT)
echo "set -e" >> $(FAKEROOT_SCRIPT)
echo "chown -h -R 0:0 $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)