miyagawa / cpanminus

cpanminus - get, unpack, build and install modules from CPAN
http://cpanmin.us
752 stars 213 forks source link

Choosing how to untar #630

Open DrHyde opened 3 years ago

DrHyde commented 3 years ago

I have a problem with cpanm on Solaris. I'm using cpanm 1.7044 on perl 5.32.0. Solaris has a rather out-of-date tar which creatively misinterprets some modern tar-isms, and while I also have a more modern gtar and also Archive::Tar installed, there seems to be no way of telling cpanm to use either of them:

~/.cpanm/latest-build $ cat build.log
cpanm (App::cpanminus) 1.7044 on perl 5.032000 built for i86pc-solaris-64
Work directory is /home/david/.cpanm/work/1625786526.1058
You have make /usr/bin/make
You have LWP 6.49
You have /usr/bin/tar, /usr/bin/gzip and /usr/bin/bzip2
You have /usr/bin/unzip
Searching Test::Most () on cpanmetadb ...
--> Working on Test::Most
Fetching http://www.cpan.org/authors/id/O/OV/OVID/Test-Most-0.37.tar.gz
-> OK
Unpacking Test-Most-0.37.tar.gz
Entering Test-Most-0.37
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.44)
Configuring Test-Most-0.37
Running Makefile.PL
Warning: prerequisite Exception::Class 1.14 not found.
Warning: prerequisite Test::Differences 0.64 not found.
Warning: prerequisite Test::Warn 0.30 not found.
Checking if your kit is complete...
Looks good
Bareword found where operator expected at ./Makefile.PL line 1, near "30 mtime"
        (Missing operator before mtime?)
ERROR from evaluation of /home/david/.cpanm/work/1625786526.1058/Test-Most-0.37/PaxHeader/Makefile.PL: syntax error at ./Makefile.PL line 1, near "30 mtime"

If instead I do the install manually, using GNU tar to unpack the tarball:

~/.cpanm/latest-build $ rm -rf Test-Most-0.37
~/.cpanm/latest-build $ gtar xzf Test-Most-0.37.tar.gz
~/.cpanm/latest-build $ cd Test-Most-0.37
~/.cpanm/latest-build/Test-Most-0.37 $ perl Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite Exception::Class 1.14 not found.
Warning: prerequisite Test::Differences 0.64 not found.
Warning: prerequisite Test::Warn 0.30 not found.
Generating a Unix-style Makefile
Writing Makefile for Test::Most
Writing MYMETA.yml and MYMETA.json

Can I ask that the default be changed to GNU tar if available? If it's not installed as tar it can often be found as gtar, and can be distinguished from other tars by the output from $tar --version.

Or alternatively that a new option be introduced to choose which tar executable to use.

XSven commented 1 year ago

For AIX the problem was reported already 10 years ago and became an issue 2019 #597. I was trapped by this problem yesterday on an AIX host and investigated it a little deeper. I have noticed that solaris is classified as an operating system with a bad tar:

use constant BAD_TAR => ($^O eq 'solaris' || $^O eq 'hpux');

This leads to a special untar backend (anonymous subroutine) that is indicated by the line

You have /usr/bin/tar, /usr/bin/gzip and /usr/bin/bzip2

You would reach the fallback untar backend Archive::Tar only if either gzip or bzip2 or both could not be located. Maybe you want to give it a try to see if Archive::Tar would work for you. I can solve my problem, if I am classifying AIX as an operating system with a bad tar too (#660).