rootfs: Add support for rootfs-overlay and bump to buildah v1.22.1-0.202108

Allows users to specify a readonly rootfs with :O, in exchange podman will create a writable overlay.

bump builah to v1.22.1-0.20210823173221-da2b428c56ce

[NO TESTS NEEDED]

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
This commit is contained in:
flouthoc
2021-08-25 16:13:17 +05:30
committed by Aditya Rajan
parent b603c7a4b9
commit a55e2a00fc
54 changed files with 1868 additions and 412 deletions

View File

@@ -20,7 +20,6 @@ import (
// TempDir generates an overlay Temp directory in the container content
func TempDir(containerDir string, rootUID, rootGID int) (string, error) {
contentDir := filepath.Join(containerDir, "overlay")
if err := idtools.MkdirAllAs(contentDir, 0700, rootUID, rootGID); err != nil {
return "", errors.Wrapf(err, "failed to create the overlay %s directory", contentDir)
@@ -30,20 +29,36 @@ func TempDir(containerDir string, rootUID, rootGID int) (string, error) {
if err != nil {
return "", errors.Wrapf(err, "failed to create the overlay tmpdir in %s directory", contentDir)
}
upperDir := filepath.Join(contentDir, "upper")
workDir := filepath.Join(contentDir, "work")
return generateOverlayStructure(contentDir, rootUID, rootGID)
}
// GenerateStructure generates an overlay directory structure for container content
func GenerateStructure(containerDir, containerID, name string, rootUID, rootGID int) (string, error) {
contentDir := filepath.Join(containerDir, "overlay-containers", containerID, name)
if err := idtools.MkdirAllAs(contentDir, 0700, rootUID, rootGID); err != nil {
return "", errors.Wrapf(err, "failed to create the overlay %s directory", contentDir)
}
return generateOverlayStructure(contentDir, rootUID, rootGID)
}
// generateOverlayStructure generates upper, work and merge directory structure for overlay directory
func generateOverlayStructure(containerDir string, rootUID, rootGID int) (string, error) {
upperDir := filepath.Join(containerDir, "upper")
workDir := filepath.Join(containerDir, "work")
if err := idtools.MkdirAllAs(upperDir, 0700, rootUID, rootGID); err != nil {
return "", errors.Wrapf(err, "failed to create the overlay %s directory", upperDir)
}
if err := idtools.MkdirAllAs(workDir, 0700, rootUID, rootGID); err != nil {
return "", errors.Wrapf(err, "failed to create the overlay %s directory", workDir)
}
mergeDir := filepath.Join(contentDir, "merge")
mergeDir := filepath.Join(containerDir, "merge")
if err := idtools.MkdirAllAs(mergeDir, 0700, rootUID, rootGID); err != nil {
return "", errors.Wrapf(err, "failed to create the overlay %s directory", mergeDir)
}
return contentDir, nil
return containerDir, nil
}
// Mount creates a subdir of the contentDir based on the source directory