From d43acf09f4978e61f9a8a37ba082cfb606834dbb Mon Sep 17 00:00:00 2001 From: Kevin Ha Date: Sun, 3 May 2026 15:32:20 +1000 Subject: [PATCH] feat(raw-unpack): Add --start-from-digest flag Signed-off-by: Kevin Ha --- cmd/umoci/raw-unpack.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/umoci/raw-unpack.go b/cmd/umoci/raw-unpack.go index e4aa79e3..0828cf14 100644 --- a/cmd/umoci/raw-unpack.go +++ b/cmd/umoci/raw-unpack.go @@ -52,6 +52,11 @@ is the destination to unpack the image to.`, Name: "keep-dirlinks", Usage: "don't clobber underlying symlinks to directories", }, + cli.StringFlag{ + Name: "start-from-digest", + Usage: "start unpacking from the given layer digest", + Value: "", + }, }, Action: rawUnpack, @@ -134,6 +139,19 @@ func rawUnpack(ctx *cli.Context) (Err error) { return fmt.Errorf("[internal error] unknown manifest blob type: %s", manifestBlob.Descriptor.MediaType) } + startFromDigest := ctx.String("start-from-digest") + if startFromDigest != "" { + for _, layer := range manifest.Layers { + if layer.Digest.String() == startFromDigest { + unpackOptions.StartFrom = layer + break + } + } + if unpackOptions.StartFrom.MediaType == "" { + return fmt.Errorf("start-from-digest: %s not found in manifest", startFromDigest) + } + } + log.Warnf("unpacking rootfs ...") if err := layer.UnpackRootfs(context.Background(), engineExt, rootfsPath, manifest, &unpackOptions); err != nil { return fmt.Errorf("create rootfs: %w", err)