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

ExtUtils::MakeMaker calls by default /bin/tar which creates problematic PAX archives #349

Open
pali opened this issue Feb 21, 2020 · 3 comments

Comments

@pali
Copy link

pali commented Feb 21, 2020

ExtUtils::MakeMaker uses by default system /bin/tar binary for creating distribution archives when invoking make dist. On more systems /bin/tar binary by default creates PAX archives instead of classic TAR archives. When you try to unpack PAX archive by a program which understands only ustar (and not pax), it creates PaxHeader subdirectory and in this subdirectory creates random files and their content has raw PAX extended attributes. So it is common that such tar program creates PaxHeader/Makefile.PL with some random garbage. It is not valid Perl code and existing it fails. So on such systems it is not possible to install perl distributions from PAX archives. There are more bug reports about this issue, e.g.:
Dual-Life/Devel-PPPort#183
https://huntingbears.nl/2015/02/17/new-tar-paxheaders-and-installing-from-cpan/
http://www.perlmonks.org/?node_id=1004571

So correct way to generate a new distribution is to use ustar archive and not PAX archive.

Perl since 5.10 has in Core module Archive::Tar and ptar binary which creates TAR archives, not PAX. So ExtUtils::MakeMaker could switch from /bin/tar to ptar by default to fix this problem and prevent creating of PAX archives on systems which /bin/tar binary by default creates PAX and not ustar. IIRC new versions of GNU tar already switched default to PAX, so Perl core ptar looks like a solution for this problem.

There is already proposed change to use --format=ustar flag for /bin/tar, but in discussion was a point that this option works correctly only for GNU tar implementation. For BSD tar implementation it in some cases creates empty tar archives... See discussion: xsawyerx/module-starter#73

@johannessen
Copy link

ptar does look like a solution here. However, a change to use it by default may break the Makefile.PL of users who tried to work around this issue by adding --format=ustar to their TARFLAGS.

Perhaps Archive::Tar’s ptar should be changed so that it accepts (and ignores) an argument --format=ustar?

Or ExtUtils::MakeMaker could remove --format=ustar from TARFLAGS when TAR isn’t defined (and defaults to ptar)?

@Leont
Copy link
Member

Leont commented Jun 17, 2024

Perhaps Archive::Tar’s ptar should be changed so that it accepts (and ignores) an argument --format=ustar?

Sounds reasonable regardless of what we do with MakeMaker. https://github.com/jib/archive-tar-new

Or ExtUtils::MakeMaker could remove --format=ustar from TARFLAGS when TAR isn’t defined (and defaults to ptar)?

That would require detecting exactly what tar we're working with here, and only add it for tars where it's needed/supported.

@johannessen
Copy link

Or ExtUtils::MakeMaker could remove --format=ustar from TARFLAGS when TAR isn’t defined (and defaults to ptar)?

That would require detecting exactly what tar we're working with here, and only add it for tars where it's needed/supported.

I don’t think it would – we’d know we’d be working with ptar. But if jib/archive-tar-new#45 is accepted, I suppose it doesn’t matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants