diff --git a/go.mod b/go.mod index 4c151bad..354a1307 100644 --- a/go.mod +++ b/go.mod @@ -284,6 +284,6 @@ require ( ) replace ( - github.com/opencontainers/umoci => github.com/project-stacker/umoci v0.0.0-20240417195808-16c510104378 + github.com/opencontainers/umoci => github.com/rchincha/umoci v0.0.0-20240624222738-f537fd2733f9 stackerbuild.io/stacker-bom => github.com/project-stacker/stacker-bom v0.0.0-20240509203427-4d685e046780 ) diff --git a/go.sum b/go.sum index b0cc8ad9..bda24529 100644 --- a/go.sum +++ b/go.sum @@ -795,8 +795,6 @@ github.com/proglottis/gpgme v0.1.3 h1:Crxx0oz4LKB3QXc5Ea0J19K/3ICfy3ftr5exgUK1AU github.com/proglottis/gpgme v0.1.3/go.mod h1:fPbW/EZ0LvwQtH8Hy7eixhp1eF3G39dtx7GUN+0Gmy0= github.com/project-stacker/stacker-bom v0.0.0-20240509203427-4d685e046780 h1:VJQ/G6xlNQqEvdzTdtXJ/XNvxv9LQTDJORik1wuxXJU= github.com/project-stacker/stacker-bom v0.0.0-20240509203427-4d685e046780/go.mod h1:S7hlUdKwPKIMNx2ceiqmLKyXq+FOVaVnAuk77AzdhtI= -github.com/project-stacker/umoci v0.0.0-20240417195808-16c510104378 h1:NHGVwIe0Icrbn8b7WW55FQjETHm5B0i6Gt6UZmzaF9A= -github.com/project-stacker/umoci v0.0.0-20240417195808-16c510104378/go.mod h1:XUXUpCpA/Y8aJWezK1i8o4WDR0Y/vhMcWg+FUNQkKMQ= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= @@ -818,6 +816,8 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/rchincha/umoci v0.0.0-20240624222738-f537fd2733f9 h1:zVLb+d07fy3soRSqjhreRNkfQjYqoEF4bNnoVLMC9DE= +github.com/rchincha/umoci v0.0.0-20240624222738-f537fd2733f9/go.mod h1:XUXUpCpA/Y8aJWezK1i8o4WDR0Y/vhMcWg+FUNQkKMQ= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= diff --git a/pkg/overlay/overlay-dirs.go b/pkg/overlay/overlay-dirs.go index 249642f5..9f4d46b5 100644 --- a/pkg/overlay/overlay-dirs.go +++ b/pkg/overlay/overlay-dirs.go @@ -48,7 +48,7 @@ func generateOverlayDirLayer(name string, layerType types.LayerType, overlayDir defer oci.Close() contents := path.Join(config.RootFSDir, name, "overlay_dirs", path.Base(overlayDir.Source)) - blob, mediaType, rootHash, err := generateBlob(layerType, contents, config.OCIDir) + blob, mediaType, rootHash, err := generateBlob(layerType, contents, config.OCIDir, nil) if err != nil { return ispec.Descriptor{}, err } diff --git a/pkg/overlay/pack.go b/pkg/overlay/pack.go index 3a6cc7d7..2f32179d 100644 --- a/pkg/overlay/pack.go +++ b/pkg/overlay/pack.go @@ -135,7 +135,7 @@ func ConvertAndOutput(config types.StackerConfig, tag, name string, layerType ty bundlePath := overlayPath(config.RootFSDir, theLayer.Digest) overlayDir := path.Join(bundlePath, "overlay") // generate blob - blob, mediaType, rootHash, err := generateBlob(layerType, overlayDir, config.OCIDir) + blob, mediaType, rootHash, err := generateBlob(layerType, overlayDir, config.OCIDir, nil) if err != nil { return err } @@ -293,13 +293,13 @@ func (o *overlay) Repack(name string, layerTypes []types.LayerType, sfm types.St } // generateBlob generates either a tar blob or a squashfs blob based on layerType -func generateBlob(layerType types.LayerType, contents string, ociDir string) (io.ReadCloser, string, string, error) { +func generateBlob(layerType types.LayerType, contents string, ociDir string, lowerDirs []string) (io.ReadCloser, string, string, error) { var blob io.ReadCloser var err error var mediaType string var rootHash string if layerType.Type == "tar" { - packOptions := layer.RepackOptions{TranslateOverlayWhiteouts: true} + packOptions := layer.RepackOptions{TranslateOverlayWhiteouts: true, OverlayLowerDirs: lowerDirs} blob = layer.GenerateInsertLayer(contents, "/", false, &packOptions) mediaType = ispec.MediaTypeImageLayer } else { @@ -430,12 +430,22 @@ func generateLayer(config types.StackerConfig, oci casext.Engine, mutators []*mu return false, err } + ovl, err := readOverlayMetadata(config.RootFSDir, name) + if err != nil { + return false, err + } + descs := []ispec.Descriptor{} for i, layerType := range layerTypes { mutator := mutators[i] var desc ispec.Descriptor - blob, mediaType, rootHash, err := generateBlob(layerType, dir, config.OCIDir) + lowerDirs := []string{} + for i := len(ovl.Manifests[layerType].Layers) - 1; i >= 0; i-- { + lowerDirs = append(lowerDirs, overlayPath(config.RootFSDir, ovl.Manifests[layerType].Layers[i].Digest)) + } + + blob, mediaType, rootHash, err := generateBlob(layerType, dir, config.OCIDir, lowerDirs) if err != nil { return false, err }