[Buildroot] [PATCH] system: add optional rsync with preserved permissions
José Pekkarinen
jose.pekkarinen at unikie.com
Mon Oct 4 06:41:43 UTC 2021
The following patch adds a config flag to let the user
rely in rsync to pressume actual file permissions and
let it populate destination files with closer results
to what the original overlay have.
Signed-off-by: José Pekkarinen <jose.pekkarinen at unikie.com>
---
Makefile | 6 ++++++
system/Config.in | 7 +++++++
system/system.mk | 8 ++++++++
3 files changed, 21 insertions(+)
diff --git a/Makefile b/Makefile
index 259706719a..3746f276ec 100644
--- a/Makefile
+++ b/Makefile
@@ -814,9 +814,15 @@ ifeq ($(BR2_ROOTFS_MERGED_USR),y)
endif # merged /usr
+ifeq ($(BR2_ROOTFS_OVERLAY_PRESERVED_PERMISSION),y))
+ $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
+ @$(call MESSAGE,"Copying overlay $(d)")$(sep) \
+ $(Q)$(call SYSTEM_OVERLAY_RSYNC,$(d),$(TARGET_DIR))$(sep))
+else
$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
@$(call MESSAGE,"Copying overlay $(d)")$(sep) \
$(Q)$(call SYSTEM_RSYNC,$(d),$(TARGET_DIR))$(sep))
+endif
$(Q)$(if $(TARGET_DIR_FILES_LISTS), \
cat $(TARGET_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list.txt
diff --git a/system/Config.in b/system/Config.in
index b3abeddd68..a9b27f88b5 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -533,6 +533,13 @@ config BR2_ROOTFS_OVERLAY
They are copied as-is into the rootfs, excluding files ending
with ~ and .git, .svn and .hg directories.
+config BR2_ROOTFS_OVERLAY_PRESERVED_PERMISSION
+ string "Preserve permissions of overlay directories"
+ depends on BR2_ROOTFS_OVERLAY
+ default "n"
+ help
+ Preserve file permissions of specified overlay.
+
config BR2_ROOTFS_POST_BUILD_SCRIPT
string "Custom scripts to run before creating filesystem images"
default ""
diff --git a/system/system.mk b/system/system.mk
index 8fe2c138b0..61b6e1c34e 100644
--- a/system/system.mk
+++ b/system/system.mk
@@ -55,6 +55,14 @@ define SYSTEM_RSYNC
$(1)/ $(2)/
endef
+# This function rsyncs the overlay directory in $(1) to the destination
+# in $(2), which should be either $(TARTGET_DIR) or $(STAGING_DIR)
+define SYSTEM_OVERLAY_RSYNC
+ rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
+ --exclude .empty --exclude '*~' \
+ $(1)/ $(2)/
+endef
+
# Make a symlink lib32->lib or lib64->lib as appropriate.
# MIPS64/n32 requires lib32 even though it's a 64-bit arch. However, since gcc
# 5.1.0 internal compiler paths in sysroot are relative to lib64, so we must
--
2.25.1
More information about the buildroot
mailing list