Skip to contentSkip to conversation

overlay: Allow overlay to be a tar archive.

PATCH New Cam Hutchison 2 participants 6 messages Jan 25, 2016 – Mar 9, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 overlay: Allow overlay to be a tar archive.

When installing an overlay, check if the source is a directory. If it is, continue to use rsync to install it to the target. If it is not a directory, assume it is an archive extractable by GNU tar(1) and use that to install it to the target.

This allows an overlay specified with BR2_ROOTFS_OVERLAY to be a tar archive instead of a directory, which is useful when an external build process produces rootfs archives and not directories.

---
 Makefile         | 14 +++++++++-----
 system/Config.in | 14 ++++++++------
 2 files changed, 17 insertions(+), 11 deletions(-)
Makefile +9 -5
index 17c181b..803be0c 100644
@@ -653,11 +653,15 @@ endif
 		echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
 	) >  $(TARGET_DIR)/etc/os-release
 
-	@$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
-		$(call MESSAGE,"Copying overlay $(d)"); \
-		rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
-			--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
-			$(d)/ $(TARGET_DIR)$(sep))
+	@$(foreach overlay, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
+		$(call MESSAGE,"Copying overlay $(overlay)"); \
+		if test -d $(overlay); then \
+			rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
+				--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
+				$(overlay)/ $(TARGET_DIR); \
+		else \
+			tar -a -x -C $(TARGET_DIR) -f $(overlay); \
+		fi$(sep))
 
 	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
 		$(call MESSAGE,"Executing post-build script $(s)"); \
system/Config.in +8 -6
index 2e14971..ef65d98 100644
@@ -419,15 +419,17 @@ config BR2_ROOTFS_USERS_TABLES
 	  See manual for details on the usage and syntax of these files.
 
 config BR2_ROOTFS_OVERLAY
-	string "Root filesystem overlay directories"
+	string "Root filesystem overlay directories or archives"
 	default ""
 	help
-	  Specify a list of directories that are copied over the target
-	  root filesystem after the build has finished and before it is
-	  packed into the selected filesystem images.
+	  Specify a list of directories or archives that are copied over
+	  the target root filesystem after the build has finished and
+	  before it is packed into the selected filesystem images.
 
-	  They are copied as-is into the rootfs, excluding files ending with
-	  ~ and .git, .svn and .hg directories.
+	  Directories are copied as-is into the rootfs, excluding files ending
+	  with ~ and .git, .svn and .hg directories.
+
+	  Archives are extracted as-is into the rootfs with no modifications.
 
 config BR2_ROOTFS_POST_BUILD_SCRIPT
 	string "Custom scripts to run before creating filesystem images"
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 overlay: Allow overlay to be a tar archive.

Quoted 28 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Cam" == Cam Hutchison <[email protected]> writes:

When installing an overlay, check if the source is a directory. If it is, continue to use rsync to install it to the target. If it is not a directory, assume it is an archive extractable by GNU tar(1) and use that to install it to the target.

This allows an overlay specified with BR2_ROOTFS_OVERLAY to be a tar archive instead of a directory, which is useful when an external build process produces rootfs archives and not directories.

---
 Makefile         | 14 +++++++++-----
 system/Config.in | 14 ++++++++------
 2 files changed, 17 insertions(+), 11 deletions(-)
Makefile +0 -3
index 17c181b..803be0c 100644
@@ -653,11 +653,15 @@ endif
 		echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
 	) >  $(TARGET_DIR)/etc/os-release
 
-	@$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
-		$(call MESSAGE,"Copying overlay $(d)"); \
-		rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \

Makefile endif · line 663

Quoted 10 lines
Makefile +8 -2
-			--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
-			$(d)/ $(TARGET_DIR)$(sep))
+	@$(foreach overlay, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
+		$(call MESSAGE,"Copying overlay $(overlay)"); \
+		if test -d $(overlay); then \
+			rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
+				--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
+				$(overlay)/ $(TARGET_DIR); \
+		else \
+			tar -a -x -C $(TARGET_DIR) -f $(overlay); \

In concept I'm ok with this, but how portable and generic is this?

Looking at the tar homepage, -a / --auto-compress was added in tar 1.20 from early 2008, so this presumably breaks on older enterprise distributions like RHEL 5.

Another potential issue that you assume that the tarball directly contains the rootfs overlay content (E.G. no subdirs). This is true for the Buildroot rootfs tarballs, but how common is this?

I'm not sure this is a common enough usecase to explicitly support versus just adding a simple post-image script.

Anybody else having an opinion on this?

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH 1/1 overlay: Allow overlay to be a tar archive.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Peter" == Peter Korsgaard <[email protected]> writes:

Hi,

Quoted 2 lines

I'm not sure this is a common enough usecase to explicitly support versus just adding a simple post-image script.

Ehh, post-build, not post-image.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 1/1 overlay: Allow overlay to be a tar archive.

In reply to Peter Korsgaard
Quoted 39 lines · Peter Korsgaard
Quoted 28 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Cam" == Cam Hutchison <[email protected]> writes:

When installing an overlay, check if the source is a directory. If it is, continue to use rsync to install it to the target. If it is not a directory, assume it is an archive extractable by GNU tar(1) and use that to install it to the target.

This allows an overlay specified with BR2_ROOTFS_OVERLAY to be a tar archive instead of a directory, which is useful when an external build process produces rootfs archives and not directories.

---
 Makefile         | 14 +++++++++-----
 system/Config.in | 14 ++++++++------
 2 files changed, 17 insertions(+), 11 deletions(-)
Makefile +0 -3
index 17c181b..803be0c 100644
@@ -653,11 +653,15 @@ endif
             echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
     ) >  $(TARGET_DIR)/etc/os-release
 
-    @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
-            $(call MESSAGE,"Copying overlay $(d)"); \
-            rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \

Makefile endif · line 663

Quoted 10 lines
Makefile +8 -2
-                    --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
-                    $(d)/ $(TARGET_DIR)$(sep))
+    @$(foreach overlay, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
+            $(call MESSAGE,"Copying overlay $(overlay)"); \
+            if test -d $(overlay); then \
+                    rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
+                            --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
+                            $(overlay)/ $(TARGET_DIR); \
+            else \
+                    tar -a -x -C $(TARGET_DIR) -f $(overlay); \
Quoted 5 lines

In concept I'm ok with this, but how portable and generic is this?

Looking at the tar homepage, -a / --auto-compress was added in tar 1.20 from early 2008, so this presumably breaks on older enterprise distributions like RHEL 5.

I did check when -a went in, but I figured 8 years ago was old enough. I don't know much about the release dates of various distros or what buildroot wants to support. Is there a guide as to what the cutoff should be for host features?

Quoted 3 lines

Another potential issue that you assume that the tarball directly contains the rootfs overlay content (E.G. no subdirs). This is true for the Buildroot rootfs tarballs, but how common is this?

My use case is for using buildroot rootfs tarballs from other phases of a larger build, both where some developers are responsible for some parts (kernel/bootloader, common rootfs, specific applications, integration), and where there are multiple boards to develop for that have a large amount of commonality for which it is wasteful to rebuild the same parts over and over.

However, it strikes me now as I write this reply that the patch is wrong. Any of the parts done under fakeroot that is captured in the tarball will be lost when merged as an overlay tarball as the extraction is not done under the fakeroot. I have no direct need for this but it was my intention that this work - the rootfs in the tarball would be faithfully represented in the enclosing rootfs.

Quoted 2 lines

I'm not sure this is a common enough usecase to explicitly support versus just adding a simple post-image script.

Probably not. I've been carrying this patch or a variant for the last 6 years, so I thought I'd submit the simplest version of it I have. But given the questionable use case and that it is subtly wrong as noted above, I'd suggest you just drop this patch.

Quoted 5 lines

Anybody else having an opinion on this?

--
Bye, Peter Korsgaard

#4 lore raw

PATCH 1/1 overlay: Allow overlay to be a tar archive.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Cam" == Cam Hutchison <[email protected]> writes:

Hi,

Quoted 10 lines · Peter Korsgaard
Quoted 4 lines

Looking at the tar homepage, -a / --auto-compress was added in tar 1.20 from early 2008, so this presumably breaks on older enterprise distributions like RHEL 5.

I did check when -a went in, but I figured 8 years ago was old enough. I don't know much about the release dates of various distros or what buildroot wants to support. Is there a guide as to what the cutoff should be for host features?

We don't have anything fixed written down or set in stone, but I do know that that we have users on RHEL 5.x, E.G. see these commits:

- 0bbd1dbc156cc81e6f9986c79774c67d537832a8
- cc7da4743e779d9792df0a91e1391112e88968b9
- 53223cbb4e775ce88c036ddbfcca260e23c5739e

I don't have access to a RHEL5 machine, so I cannot easily check the tar version, but as it was released in ~2006, it presumably doesn't have tar 1.20 ;)

Quoted 10 lines
Quoted 3 lines

Another potential issue that you assume that the tarball directly contains the rootfs overlay content (E.G. no subdirs). This is true for the Buildroot rootfs tarballs, but how common is this?

My use case is for using buildroot rootfs tarballs from other phases of a larger build, both where some developers are responsible for some parts (kernel/bootloader, common rootfs, specific applications, integration), and where there are multiple boards to develop for that have a large amount of commonality for which it is wasteful to rebuild the same parts over and over.

Ok, and you use Buildroot as the toplevel (E.G. the thing that integrates everything) buildsystem?

Quoted 6 lines

However, it strikes me now as I write this reply that the patch is wrong. Any of the parts done under fakeroot that is captured in the tarball will be lost when merged as an overlay tarball as the extraction is not done under the fakeroot. I have no direct need for this but it was my intention that this work - the rootfs in the tarball would be faithfully represented in the enclosing rootfs.

Ahh yes.

Quoted 4 lines
Quoted 2 lines

I'm not sure this is a common enough usecase to explicitly support versus just adding a simple post-image script.

Probably not. I've been carrying this patch or a variant for the last 6 years,

Wow, the rootfs-overlay stuff is afaik only from 2013 or so (before that people did it manually in post-build scripts).

Quoted 3 lines

so I thought I'd submit the simplest version of it I have. But given the questionable use case and that it is subtly wrong as noted above, I'd suggest you just drop this patch.

Ok, I'll mark it as rejected in patchwork.

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#5 lore raw

PATCH 1/1 overlay: Allow overlay to be a tar archive.

Quoted 11 lines · Peter Korsgaard
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Cam" == Cam Hutchison <[email protected]> writes:

My use case is for using buildroot rootfs tarballs from other phases of a larger build, both where some developers are responsible for some parts (kernel/bootloader, common rootfs, specific applications, integration), and where there are multiple boards to develop for that have a large amount of commonality for which it is wasteful to rebuild the same parts over and over.

Ok, and you use Buildroot as the toplevel (E.G. the thing that integrates everything) buildsystem?

These days I do. I originally had a front-end shell script that split the build up into phases (boot loader, kernel, base rootfs, custom apps) as that is how my client wanted to develop - most of the developers were not familiar with buildroot and they didn't want the app developers to have to wait for kernel compiles, etc. The final phase of the script was to pull together all the rootfs tarballs from each phase into a single rootfs and make an image. That was six years ago.

These days I still have a front-end script that maintains separate configs for each phase, but the final phase pulls it together using the overlay tarballs from this patch and using genimage in a post-image script. The final phase is just a buildroot config, and the front-end script just makes it easier to launch the build with different configs.

I still find this phased build useful - right now I'm building a cluster of raspberry pi 1, 2 & 3, orange pi pc & plus and pcduino nano lites (just for fun). I do the base rootfs as a common build (except pi 1) and each board has a custom uboot/kernel phase that pulls in the common tarball rootfs.

I have another local patch that generates images without the skeleton which is what makes these tarball rootfs's able to overlay properly. I also plan to use this to generate single app tarballs that can be turned into container images for the cluster, but this all starts to get outside the scope of buildroot that I'm not submitting that patch.