Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] system: add optional rsync with preserved permissions
@ 2021-10-04  6:41 José Pekkarinen
  2021-10-04  7:00 ` Thomas Petazzoni
  0 siblings, 1 reply; 6+ messages in thread
From: José Pekkarinen @ 2021-10-04  6:41 UTC (permalink / raw)
  To: buildroot; +Cc: José Pekkarinen

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@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

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-04 15:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-04  6:41 [Buildroot] [PATCH] system: add optional rsync with preserved permissions José Pekkarinen
2021-10-04  7:00 ` Thomas Petazzoni
2021-10-04  7:08   ` José Pekkarinen
2021-10-04  7:30     ` Thomas Petazzoni
2021-10-04 15:15     ` Yann E. MORIN
2021-10-04 15:10   ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox