Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
rchincha committed Jun 27, 2024
1 parent 5cf9fe0 commit a23be18
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ require (
)

replace (
github.com/opencontainers/umoci => github.com/rchincha/umoci v0.0.0-20240626041051-8a70aa6ab09f
github.com/opencontainers/umoci => github.com/rchincha/umoci v0.0.0-20240626163940-d5817dc92d4c
stackerbuild.io/stacker-bom => github.com/project-stacker/stacker-bom v0.0.0-20240509203427-4d685e046780
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +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-20240626041051-8a70aa6ab09f h1:kb6KNqJtAu7bF//luRE42U3ySX79bn0iO+5FVXuEnLo=
github.com/rchincha/umoci v0.0.0-20240626041051-8a70aa6ab09f/go.mod h1:XUXUpCpA/Y8aJWezK1i8o4WDR0Y/vhMcWg+FUNQkKMQ=
github.com/rchincha/umoci v0.0.0-20240626163940-d5817dc92d4c h1:aqbiVMze/TB97xVPAbuu1ryhEK7bKhCU3LAQmT8Pnkw=
github.com/rchincha/umoci v0.0.0-20240626163940-d5817dc92d4c/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=
Expand Down
21 changes: 14 additions & 7 deletions pkg/overlay/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ func (o *overlay) initializeBasesInOutput(name string, layerTypes []types.LayerT
return nil
}

func (o *overlay) Repack(name string, layerTypes []types.LayerType, sfm types.StackerFiles) error {
func (o *overlay) Repack(name string, layer types.Layer, layerTypes []types.LayerType, sfm types.StackerFiles) error {
err := o.initializeBasesInOutput(name, layerTypes, sfm)
if err != nil {
return err
}

return repackOverlay(o.config, name, layerTypes)
return repackOverlay(o.config, name, layer, layerTypes)
}

// generateBlob generates either a tar blob or a squashfs blob based on layerType
Expand Down Expand Up @@ -382,7 +382,9 @@ func stripOverlayAttrsUnder(dirPath string) error {
})
}

func generateLayer(config types.StackerConfig, oci casext.Engine, mutators []*mutate.Mutator, name string, layerTypes []types.LayerType) (bool, error) {
func generateLayer(config types.StackerConfig, oci casext.Engine, mutators []*mutate.Mutator,
name string, layer types.Layer, layerTypes []types.LayerType,
) (bool, error) {
dir := path.Join(config.RootFSDir, name, "overlay")
ents, err := os.ReadDir(dir)
if err != nil {
Expand Down Expand Up @@ -430,7 +432,12 @@ func generateLayer(config types.StackerConfig, oci casext.Engine, mutators []*mu
return false, err
}

ovl, err := readOverlayMetadata(config.RootFSDir, name)
var ovl overlayMetadata
if layer.From.Type != types.BuiltLayer {
ovl, err = readOverlayMetadata(config.RootFSDir, name)
} else {
ovl, err = readOverlayMetadata(config.RootFSDir, layer.From.Tag)
}
if err != nil {
return false, err
}
Expand Down Expand Up @@ -557,7 +564,7 @@ func generateLayer(config types.StackerConfig, oci casext.Engine, mutators []*mu
return true, nil
}

func repackOverlay(config types.StackerConfig, name string, layerTypes []types.LayerType) error {
func repackOverlay(config types.StackerConfig, name string, layer types.Layer, layerTypes []types.LayerType) error {
oci, err := umoci.OpenLayout(config.OCIDir)
if err != nil {
return err
Expand Down Expand Up @@ -612,7 +619,7 @@ func repackOverlay(config types.StackerConfig, name string, layerTypes []types.L
// generate blobs for each build layer
for _, buildLayer := range ovl.BuiltLayers {

didMutate, err := generateLayer(config, oci, mutators, buildLayer, layerTypes)
didMutate, err := generateLayer(config, oci, mutators, buildLayer, layer, layerTypes)
if err != nil {
return err
}
Expand Down Expand Up @@ -647,7 +654,7 @@ func repackOverlay(config types.StackerConfig, name string, layerTypes []types.L
return err
}

didMutate, err := generateLayer(config, oci, mutators, name, layerTypes)
didMutate, err := generateLayer(config, oci, mutators, name, layer, layerTypes)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/stacker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (b *Builder) build(s types.Storage, file string) error {
continue
}

err = s.Repack(name, opts.LayerTypes, b.builtStackerfiles)
err = s.Repack(name, l, opts.LayerTypes, b.builtStackerfiles)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Storage interface {
Unpack(tag, name string) error

// Repack repacks the specified working dir into the specified OCI dir.
Repack(name string, layerTypes []LayerType, sfm StackerFiles) error
Repack(name string, layer Layer, layerTypes []LayerType, sfm StackerFiles) error

// GetLXCRootfsConfig returns the string that should be set as
// lxc.rootfs.path in the LXC container's config.
Expand Down

0 comments on commit a23be18

Please sign in to comment.