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 <aadagarwal@microsoft.com>
This commit is contained in:
Aadhar Agarwal
2026-01-12 23:09:34 +00:00
parent cb15e731a1
commit 52a92e83f0
2 changed files with 7 additions and 3 deletions

View File

@@ -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

View File

@@ -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)