Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 524 forks source link

ExtUtils::MM_Unix gets perl version wrong #3388

Closed p5pRT closed 20 years ago

p5pRT commented 23 years ago

Migrated from rt.perl.org#5773 (status was 'resolved')

Searchable as RT5773$

p5pRT commented 23 years ago

From andrew@tki.org.nz

In order to upgrade perl on a production server without downtime\, it is necessary to install library files into the library areas for the new perl version before changing the aliases at /usr/bin/perl and /usr/local/bin/perl.

Fortunately this is relatively straightforward in most cases​:

perl5.6.0 Makefile.PL make make test make install

This should set up the created Makefile to install into the correct directories. It worked fine in the past\, but does not appear to work now.

In the case of URI-1.10 for example this fails.

chips​:/usr/local/src/CPAN/URI/URI-1.10# perl5.6.0 Makefile.PL Writing Makefile for URI chips​:/usr/local/src/CPAN/URI/URI-1.10# make Perl 5.00564 required--this is only version 5.00503\, stopped at /usr/local/lib/perl5/5.6.0/ExtUtils/Command.pm line 3. BEGIN failed--compilation aborted at /usr/local/lib/perl5/5.6.0/ExtUtils/Command.pm line 3. BEGIN failed--compilation aborted. make​: *** [blib/lib/.exists] Error 255

Modifying the generated Makefile so that PERL and FULLPERL (twice) point to the perl version that ran Makefile.PL allows the install to proceed correctly.

The actual bug appears to be in ExtUtils​::MM_Unix (and platform equivalents presumably)​:

Looking for perl 5 by these names​: perl5.6.0 miniperl perl perl5 perl5.6.0 in these dirs​: /sbin /bin /usr/sbin /usr/bin /usr/bin/X11 /usr/local/sbin /usr/local/bin /usr/local/bin Checking /sbin/perl5.6.0 Checking /sbin/miniperl Checking /sbin/perl Checking /sbin/perl5 Checking /sbin/perl5.6.0 Checking /bin/perl5.6.0 Checking /bin/miniperl Checking /bin/perl Checking /bin/perl5 Checking /bin/perl5.6.0 Checking /usr/sbin/perl5.6.0 Checking /usr/sbin/miniperl Checking /usr/sbin/perl Checking /usr/sbin/perl5 Checking /usr/sbin/perl5.6.0 Checking /usr/bin/perl5.6.0 Checking /usr/bin/miniperl Checking /usr/bin/perl Executing /usr/bin/perl Using PERL=/usr/bin/perl

The problem is that it searches for /usr/bin/perl before /usr/local/bin/perl5.6.0

This could be corrected by putting the loop-by-name around the loop-by-directory\, currently the other way around.

==========================================================================

Inline Patch ```diff --- MM_Unix.pm.orig Wed Feb 7 17:39:16 2001 +++ MM_Unix.pm Wed Feb 7 17:43:13 2001 @@ -1147,9 +1147,9 @@ @$dirs "; } - foreach $dir (@$dirs){ - next unless defined $dir; # $self->{PERL_SRC} may be undefined - foreach $name (@$names){ + foreach $name (@$names){ + foreach $dir (@$dirs){ + next unless defined $dir; # $self->{PERL_SRC} may be undefined my ($abs, $val); if ($self->file_name_is_absolute($name)) { # /foo/bar $abs = $name; ```

==========================================================================

I don't know if this has any unwanted side effects\, but it appears to be in keeping with the intent of the code involved.

Andrew McNaughton

Perl Info ``` This perlbug was built using Perl 5.00503 - $Date: 1999/05/05 19:42:40 $ It is being executed now by Perl 5.006 - Wed Jun 28 23:41:06 NZST 2000. Site configuration information for perl 5.006: Configured by andrew at Wed Jun 28 23:41:06 NZST 2000. Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=freebsd, osvers=3.4-stable, archname=i386-freebsd uname='freebsd sub.internal.cwa.co.nz 3.4-stable freebsd 3.4-stable #1: tue may 16 20:48:22 nzst 2000 andrew@sub.internal.cwa.co.nz:usrsrcsyscompilesub-2000012101 i386 ' config_args='-de -Uuselargefiles' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=undef use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='cc', optimize='-O', gccversion=2.7.2.3 cppflags='-I/usr/local/include' ccflags ='-I/usr/local/include' stdchar='char', d_stdstdio=undef, usevfork=true intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lm -lc -lcrypt libc=/usr/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-DPIC -fpic', lddlflags='-shared -L/usr/local/lib' Locally applied patches: @INC for perl 5.006: /usr/local/lib/perl5/5.6.0/i386-freebsd /usr/local/lib/perl5/5.6.0 /usr/local/lib/perl5/site_perl/5.6.0/i386-freebsd /usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl . Environment for perl 5.006: HOME=/home/andrew LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/andrew/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/X11R6/bin:/usr/local/snns/bin PERL_BADLANG (unset) SHELL=/usr/local/bin/bash ```
p5pRT commented 23 years ago

From @andk

On Thu\, 8 Feb 2001 00​:28​:33 +1300 (NZDT)\, andrew@​tki.org.nz said​:

--- MM_Unix.pm.orig Wed Feb 7 17​:39​:16 2001 +++ MM_Unix.pm Wed Feb 7 17​:43​:13 2001 @​@​ -1147\,9 +1147\,9 @​@​ @​$dirs "; } - foreach $dir (@​$dirs){ - next unless defined $dir; # $self->{PERL_SRC} may be undefined - foreach $name (@​$names){ + foreach $name (@​$names){ + foreach $dir (@​$dirs){ + next unless defined $dir; # $self->{PERL_SRC} may be undefined my ($abs\, $val); if ($self->file_name_is_absolute($name)) { # /foo/bar $abs = $name;

I recognize patch number 7189 from the repository. It will be part of 5.7.1 and 5.6.1.

Bug can be closed.

Thanks for the report!

p5pRT commented 23 years ago

From [Unknown Contact. See original ticket]

\andrew@​tki\.org\.nz writes​:

This is a bug report for perl from andrew@​sub.internal.cwa.co.nz\, generated with the help of perlbug 1.26 running under perl 5.006.

chips​:/usr/local/src/CPAN/URI/URI-1.10# perl5.6.0 Makefile.PL Writing Makefile for URI chips​:/usr/local/src/CPAN/URI/URI-1.10# make Perl 5.00564 required--this is only version 5.00503\, stopped at /usr/local/lib/perl5/5.6.0/ExtUtils/Command.pm line 3. BEGIN failed--compilation aborted at /usr/local/lib/perl5/5.6.0/ExtUtils/Command.pm line 3. BEGIN failed--compilation aborted. make​: *** [blib/lib/.exists] Error 255

Modifying the generated Makefile so that PERL and FULLPERL (twice) point to the perl version that ran Makefile.PL allows the install to proceed correctly.

The actual bug appears to be in ExtUtils​::MM_Unix (and platform equivalents presumably)​:

Looking for perl 5 by these names​: perl5.6.0 miniperl perl perl5 perl5.6.0 in these dirs​:

This would all be a lot simpler of $^X was (reliably) a full path. (Which is not to say that we cannot do better without.)

Linux could get that right with   readlink("/proc/$$/exe")

Solaris could get something-that-worked with   /proc/$$/object/a.out

Do freebsd and other systems have anything similar?

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration​: Platform​: osname=freebsd\, osvers=3.4-stable\, archname=i386-freebsd uname='freebsd sub.internal.cwa.co.nz 3.4-stable freebsd 3.4-stable #1​: tue may 16 20​:48​:22 nzst 2000 andrew@​sub.internal.cwa.co.nz​:usrsrcsyscompilesub-2000012101 i386 '

p5pRT commented 23 years ago

From @nwc10

On Wed\, Feb 07\, 2001 at 06​:12​:41PM +0000\, Nick Ing-Simmons wrote​:

\andrew@​tki\.org\.nz writes​:

The actual bug appears to be in ExtUtils​::MM_Unix (and platform equivalents presumably)​:

Looking for perl 5 by these names​: perl5.6.0 miniperl perl perl5 perl5.6.0 in these dirs​:

This would all be a lot simpler of $^X was (reliably) a full path. (Which is not to say that we cannot do better without.)

Linux could get that right with readlink("/proc/$$/exe")

Solaris could get something-that-worked with /proc/$$/object/a.out

Do freebsd and other systems have anything similar?

As best I could tell freebsd is nice and already puts the full path of the "shell" in argv[0]

nick@​roast [test]$ cat argv.pl #!/usr/bin/perl -w print "$^X\n"; print "$0\n"; nick@​roast [test]$ ./argv.pl /usr/bin/perl ./argv.pl

linux 2.2 gives me

nick@​liam [test]$ ./argv.pl perl ./argv.pl

linux 2.4 gives me

nick@​fruitbat [8692-src]$ /mnt/liam/nick/test/argv.pl /usr/bin/perl /mnt/liam/nick/test/argv.pl

[Should be same perl binary and same /bin/sh from Debain]

Hmm. FreeBSD 4 is "better" than Linux 2.2 here

Nicholas Clark

p5pRT commented 23 years ago

From [Unknown Contact. See original ticket]

Nicholas Clark \nick@​ccl4\.org writes​:

Linux could get that right with readlink("/proc/$$/exe")

Solaris could get something-that-worked with /proc/$$/object/a.out

Do freebsd and other systems have anything similar?

As best I could tell freebsd is nice and already puts the full path of the "shell" in argv[0]

nick@​roast [test]$ cat argv.pl #!/usr/bin/perl -w print "$^X\n"; print "$0\n"; nick@​roast [test]$ ./argv.pl /usr/bin/perl ./argv.pl

Which while useful to know\, does not cover the

perl Makefile.PL case.

What does

perl argv.pl

print on freebsd ?

linux 2.2 gives me

nick@​liam [test]$ ./argv.pl perl ./argv.pl

linux 2.4 gives me

nick@​fruitbat [8692-src]$ /mnt/liam/nick/test/argv.pl /usr/bin/perl /mnt/liam/nick/test/argv.pl n b> [Should be same perl binary and same /bin/sh from Debain]

Hmm. FreeBSD 4 is "better" than Linux 2.2 here

Nicholas Clark

p5pRT commented 23 years ago

From @nwc10

On Wed\, Feb 07\, 2001 at 10​:07​:11PM +0000\, nick@​ing-simmons.net wrote​:

Which while useful to know\, does not cover the

perl Makefile.PL case.

What does

perl argv.pl

print on freebsd ?

perl argv.pl

D'oh for me not thinking of testing that one. (just like 2.4.0 linux for "perl argv.pl")

Nicholas Clark

p5pRT commented 23 years ago

From [Unknown Contact. See original ticket]

On Wed\, 7 Feb 2001\, Nick Ing-Simmons wrote​:

Looking for perl 5 by these names​: perl5.6.0 miniperl perl perl5 perl5.6.0 in these dirs​:

This would all be a lot simpler of $^X was (reliably) a full path. (Which is not to say that we cannot do better without.)

Linux could get that right with readlink("/proc/$$/exe")

Solaris could get something-that-worked with /proc/$$/object/a.out

Do freebsd and other systems have anything similar?

/proc/$$/file acts like a hard link\, but given that the original 'perlXXX Makefile.PL' will have terminated\, /proc/$$ will be gone when you come to the make. You can get the inode number with `ls -i /proc/$$/file`\, but I'm not sure how you'd get to the original file name with that. IT provides verification that you've got it right I suppose.

lsof can be used to find the path name\, but it's not a given that it's installed. It's code would however be a source of techniques that could be applied on any given platform.

Andrew

-- Andrew McNaughton Te Kete Ipurangi​: The Online Learning Centre andrew@​tki.org.nz Ph​: 64 4 382 6500 Fax​: 64 4 382 6509 Mobile​: 021 323 076

PO Box 19-098 Wellington\, NZ http​://www.tki.org.nz/