Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crane: In Windows versions, the tarball archive is not exported correctly #1961

Open
vGhost2000 opened this issue Jun 18, 2024 · 0 comments · May be fixed by #1967
Open

crane: In Windows versions, the tarball archive is not exported correctly #1961

vGhost2000 opened this issue Jun 18, 2024 · 0 comments · May be fixed by #1967
Labels
bug Something isn't working

Comments

@vGhost2000
Copy link

Describe the bug

In Windows versions, the tarball archive is not exported correctly. During the export, the file at:

header.Name = filepath.Clean(header.Name)
uses filepath.Clean, which on Windows replaces all "/" with "\\". This is incorrect for tarball archives. Such archives cannot then be used or imported.

To Reproduce

Simply execute:
crane.exe export docker:dind docker-dind.tar
and then try to open this archive under Linux, you will see the following:

Screenshot_28
Screenshot_29
Screenshot_30

Expected behavior

A correctly formed tarball archive.

Additional context

  • Output of crane version: 0.19.2 but it is relevant for any version.

Adding the following three lines of code after the line at

header.Name = filepath.Clean(header.Name)

solves the problem:

			// Some tools prepend everything with "./", so if we don't Clean the
			// name, we may have duplicate entries, which angers tar-split.
			header.Name = filepath.Clean(header.Name)
// + this >>>			
			if runtime.GOOS == "windows" {
				header.Name = strings.ReplaceAll(header.Name, "\\", "/")
			}
@vGhost2000 vGhost2000 added the bug Something isn't working label Jun 18, 2024
@vGhost2000 vGhost2000 changed the title crane: crane: In Windows versions, the tarball archive is not exported correctly Jun 18, 2024
A2uria added a commit to A2uria/go-containerregistry that referenced this issue Jun 28, 2024
@A2uria A2uria linked a pull request Jun 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant