From 52a92e83f0cc9ff262e4fe2f64e7454ed3959682 Mon Sep 17 00:00:00 2001 From: Aadhar Agarwal Date: Mon, 12 Jan 2026 23:09:34 +0000 Subject: [PATCH] erofs-differ: use same UUID append style in tar index mode as tar conversion mode Use the same approach for appending UUID arguments in GenerateTarIndexAndAppendTar as done in ConvertTarErofs for consistency between the two modes. Signed-off-by: Aadhar Agarwal --- internal/erofsutils/mount.go | 5 ++++- plugins/diff/erofs/differ.go | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/erofsutils/mount.go b/internal/erofsutils/mount.go index d99e979e2..35c469904 100644 --- a/internal/erofsutils/mount.go +++ b/internal/erofsutils/mount.go @@ -54,7 +54,7 @@ func ConvertTarErofs(ctx context.Context, r io.Reader, layerPath, uuid string, m // The `--tar=i` option instructs mkfs.erofs to only generate the tar index // for the tar content. The resulting file structure is: // [Tar index][Original tar content] -func GenerateTarIndexAndAppendTar(ctx context.Context, r io.Reader, layerPath string, mkfsExtraOpts []string) error { +func GenerateTarIndexAndAppendTar(ctx context.Context, r io.Reader, layerPath, uuid string, mkfsExtraOpts []string) error { // Create a temporary file for storing the tar content tarFile, err := os.CreateTemp("", "erofs-tar-*") if err != nil { @@ -68,6 +68,9 @@ func GenerateTarIndexAndAppendTar(ctx context.Context, r io.Reader, layerPath st // Generate tar index directly to layerPath using --tar=i option args := append([]string{"--tar=i", "--aufs", "--quiet"}, mkfsExtraOpts...) + if uuid != "" { + args = append(args, []string{"-U", uuid}...) + } args = append(args, layerPath) cmd := exec.CommandContext(ctx, "mkfs.erofs", args...) cmd.Stdin = teeReader diff --git a/plugins/diff/erofs/differ.go b/plugins/diff/erofs/differ.go index b4bccbee5..6ad99b555 100644 --- a/plugins/diff/erofs/differ.go +++ b/plugins/diff/erofs/differ.go @@ -174,16 +174,17 @@ func (s erofsDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts [] } // Choose between tar index or tar conversion mode + // Generate deterministic UUID from layer digest + u := uuid.NewSHA1(uuid.NameSpaceURL, []byte("erofs:blobs/"+desc.Digest)) if s.enableTarIndex { // Use the tar index method: generate tar index and append tar - err = erofsutils.GenerateTarIndexAndAppendTar(ctx, rc, layerBlobPath, s.mkfsExtraOpts) + err = erofsutils.GenerateTarIndexAndAppendTar(ctx, rc, layerBlobPath, u.String(), s.mkfsExtraOpts) if err != nil { return emptyDesc, fmt.Errorf("failed to generate tar index: %w", err) } log.G(ctx).WithField("path", layerBlobPath).Debug("Applied layer using tar index mode") } else { // Use the tar method: fully convert tar to EROFS - u := uuid.NewSHA1(uuid.NameSpaceURL, []byte("erofs:blobs/"+desc.Digest)) err = erofsutils.ConvertTarErofs(ctx, rc, layerBlobPath, u.String(), s.mkfsExtraOpts) if err != nil { return emptyDesc, fmt.Errorf("failed to convert tar to erofs: %w", err)