diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-10-27 22:15:15 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-10-27 22:15:15 +0000 |
commit | 74cfb115ac810480c0000dc742b20383c1578bac (patch) | |
tree | 316d96e5123617976f1637b143570c309a662045 /gnu/usr.bin/perl/utils | |
parent | 453ade492b8e06c619009d6cd52a85cb04e8cf17 (diff) |
stock perl 5.8.0 from CPAN
Diffstat (limited to 'gnu/usr.bin/perl/utils')
-rw-r--r-- | gnu/usr.bin/perl/utils/enc2xs.PL | 48 | ||||
-rw-r--r-- | gnu/usr.bin/perl/utils/libnetcfg.PL | 760 | ||||
-rw-r--r-- | gnu/usr.bin/perl/utils/perlivp.PL | 485 | ||||
-rw-r--r-- | gnu/usr.bin/perl/utils/piconv.PL | 48 |
4 files changed, 1341 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/utils/enc2xs.PL b/gnu/usr.bin/perl/utils/enc2xs.PL new file mode 100644 index 00000000000..ed55e4ece79 --- /dev/null +++ b/gnu/usr.bin/perl/utils/enc2xs.PL @@ -0,0 +1,48 @@ +#!/usr/local/bin/perl + +use Config; +use File::Basename qw(&basename &dirname); +use Cwd; + +# List explicitly here the variables you want Configure to +# generate. Metaconfig only looks for shell variables, so you +# have to mention them as if they were shell variables, not +# %Config entries. Thus you write +# $startperl +# to ensure Configure will look for $Config{startperl}. + +# This forces PL files to create target in same directory as PL file. +# This is so that make depend always knows where to find PL derivatives. +my $origdir = cwd; +chdir dirname($0); +my $file = basename($0, '.PL'); +$file .= '.com' if $^O eq 'VMS'; + +open OUT,">$file" or die "Can't create $file: $!"; + +print "Extracting $file (with variable substitutions)\n"; + +# In this section, perl variables will be expanded during extraction. +# You can use $Config{...} to use Configure variables. + +print OUT <<"!GROK!THIS!"; +$Config{startperl} + eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; +!GROK!THIS! + +use File::Spec; + +my $enc2xs = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "ext", "Encode", "bin"), "enc2xs"); + +if (open(ENC2XS, $enc2xs)) { + print OUT <ENC2XS>; + close ENC2XS; +} else { + die "$0: cannot find '$enc2xs'\n"; +} + +close OUT or die "Can't close $file: $!"; +chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; +exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; +chdir $origdir; diff --git a/gnu/usr.bin/perl/utils/libnetcfg.PL b/gnu/usr.bin/perl/utils/libnetcfg.PL new file mode 100644 index 00000000000..6f2d65f40bb --- /dev/null +++ b/gnu/usr.bin/perl/utils/libnetcfg.PL @@ -0,0 +1,760 @@ +#!/usr/local/bin/perl + +use Config; +use File::Basename qw(&basename &dirname); +use Cwd; + +# List explicitly here the variables you want Configure to +# generate. Metaconfig only looks for shell variables, so you +# have to mention them as if they were shell variables, not +# %Config entries. Thus you write +# $startperl +# to ensure Configure will look for $Config{startperl}. + +# This forces PL files to create target in same directory as PL file. +# This is so that make depend always knows where to find PL derivatives. +my $origdir = cwd; +chdir dirname($0); +my $file = basename($0, '.PL'); +$file .= '.com' if $^O eq 'VMS'; + +open OUT,">$file" or die "Can't create $file: $!"; + +print "Extracting $file (with variable substitutions)\n"; + +# In this section, perl variables will be expanded during extraction. +# You can use $Config{...} to use Configure variables. + +print OUT <<"!GROK!THIS!"; +$Config{startperl} + eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; +!GROK!THIS! + +# In the following, perl variables are not expanded during extraction. + +print OUT <<'!NO!SUBS!'; + +=head1 NAME + +libnetcfg - configure libnet + +=head1 DESCRIPTION + +The libnetcfg utility can be used to configure the libnet. +Starting from perl 5.8 libnet is part of the standard Perl +distribution, but the libnetcfg can be used for any libnet +installation. + +=head1 USAGE + +Without arguments libnetcfg displays the current configuration. + + $ libnetcfg + # old config ./libnet.cfg + daytime_hosts ntp1.none.such + ftp_int_passive 0 + ftp_testhost ftp.funet.fi + inet_domain none.such + nntp_hosts nntp.none.such + ph_hosts + pop3_hosts pop.none.such + smtp_hosts smtp.none.such + snpp_hosts + test_exist 1 + test_hosts 1 + time_hosts ntp.none.such + # libnetcfg -h for help + $ + +It tells where the old configuration file was found (if found). + +The C<-h> option will show a usage message. + +To change the configuration you will need to use either the C<-c> or +the C<-d> options. + +The default name of the old configuration file is by default +"libnet.cfg", unless otherwise specified using the -i option, +C<-i oldfile>, and it is searched first from the current directory, +and the from your module path. + +The default name of new configuration file is "libnet.cfg", and by +default it is written to the current directory, unless otherwise +specified using the -o option, C<-o newfile>. + +=head1 SEE ALSO + +L<Net::Config>, L<Net::libnetFAQ> + +=head1 AUTHORS + +Graham Barr, the original Configure script of libnet. + +Jarkko Hietaniemi, conversion into libnet cfg for inclusion into Perl 5.8. + +=cut + +# $Id: Configure,v 1.8 1997/03/04 09:22:32 gbarr Exp $ + +use strict; +use IO::File; +use Getopt::Std; +use ExtUtils::MakeMaker qw(prompt); +use File::Spec; + +use vars qw($opt_d $opt_c $opt_h $opt_o $opt_i); + +## +## +## + +my %cfg = (); +my @cfg = (); + +my($libnet_cfg_in,$libnet_cfg_out,$msg,$ans,$def,$have_old); + +## +## +## + +sub valid_host +{ + my $h = shift; + + defined($h) && (($cfg{'test_exist'} == 0) || gethostbyname($h)); +} + +## +## +## + +sub test_hostnames (\@) +{ + my $hlist = shift; + my @h = (); + my $host; + my $err = 0; + + foreach $host (@$hlist) + { + if(valid_host($host)) + { + push(@h, $host); + next; + } + warn "Bad hostname: '$host'\n"; + $err++; + } + @$hlist = @h; + $err ? join(" ",@h) : undef; +} + +## +## +## + +sub Prompt +{ + my($prompt,$def) = @_; + + $def = "" unless defined $def; + + chomp($prompt); + + if($opt_d) + { + print $prompt,," [",$def,"]\n"; + return $def; + } + prompt($prompt,$def); +} + +## +## +## + +sub get_host_list +{ + my($prompt,$def) = @_; + + $def = join(" ",@$def) if ref($def); + + my @hosts; + + do + { + my $ans = Prompt($prompt,$def); + + $ans =~ s/(\A\s+|\s+\Z)//g; + + @hosts = split(/\s+/, $ans); + } + while(@hosts && defined($def = test_hostnames(@hosts))); + + \@hosts; +} + +## +## +## + +sub get_hostname +{ + my($prompt,$def) = @_; + + my $host; + + while(1) + { + my $ans = Prompt($prompt,$def); + $host = ($ans =~ /(\S*)/)[0]; + last + if(!length($host) || valid_host($host)); + + $def ="" + if $def eq $host; + + print <<"EDQ"; + +*** ERROR: + Hostname `$host' does not seem to exist, please enter again + or a single space to clear any default + +EDQ + } + + length $host + ? $host + : undef; +} + +## +## +## + +sub get_bool ($$) +{ + my($prompt,$def) = @_; + + chomp($prompt); + + my $val = Prompt($prompt,$def ? "yes" : "no"); + + $val =~ /^y/i ? 1 : 0; +} + +## +## +## + +sub get_netmask ($$) +{ + my($prompt,$def) = @_; + + chomp($prompt); + + my %list; + @list{@$def} = (); + +MASK: + while(1) { + my $bad = 0; + my $ans = Prompt($prompt) or last; + + if($ans eq '*') { + %list = (); + next; + } + + if($ans eq '=') { + print "\n",( %list ? join("\n", sort keys %list) : 'none'),"\n\n"; + next; + } + + unless ($ans =~ m{^\s*(?:(-?\s*)(\d+(?:\.\d+){0,3})/(\d+))}) { + warn "Bad netmask '$ans'\n"; + next; + } + + my($remove,$bits,@ip) = ($1,$3,split(/\./, $2),0,0,0); + if ( $ip[0] < 1 || $bits < 1 || $bits > 32) { + warn "Bad netmask '$ans'\n"; + next MASK; + } + foreach my $byte (@ip) { + if ( $byte > 255 ) { + warn "Bad netmask '$ans'\n"; + next MASK; + } + } + + my $mask = sprintf("%d.%d.%d.%d/%d",@ip[0..3],$bits); + + if ($remove) { + delete $list{$mask}; + } + else { + $list{$mask} = 1; + } + + } + + [ keys %list ]; +} + +## +## +## + +sub default_hostname +{ + my $host; + my @host; + + foreach $host (@_) + { + if(defined($host) && valid_host($host)) + { + return $host + unless wantarray; + push(@host,$host); + } + } + + return wantarray ? @host : undef; +} + +## +## +## + +getopts('dcho:i:'); + +$libnet_cfg_in = "libnet.cfg" + unless(defined($libnet_cfg_in = $opt_i)); + +$libnet_cfg_out = "libnet.cfg" + unless(defined($libnet_cfg_out = $opt_o)); + +my %oldcfg = (); + +$Net::Config::CONFIGURE = 1; # Suppress load of user overrides +if( -f $libnet_cfg_in ) + { + %oldcfg = ( %{ do $libnet_cfg_in } ); + } +elsif (eval { require Net::Config }) + { + $have_old = 1; + %oldcfg = %Net::Config::NetConfig; + } + +map { $cfg{lc $_} = $cfg{$_}; delete $cfg{$_} if /[A-Z]/ } keys %cfg; + +#--------------------------------------------------------------------------- + +if ($opt_h) { + print <<EOU; +$0: Usage: $0 [-c] [-d] [-i oldconfigile] [-o newconfigfile] [-h] +Without options, the old configuration is shown. + + -c change the configuration + -d use defaults from the old config (implies -c, non-interactive) + -i use a specific file as the old config file + -o use a specific file as the new config file + -h show this help + +The default name of the old configuration file is by default +"libnet.cfg", unless otherwise specified using the -i option, +C<-i oldfile>, and it is searched first from the current directory, +and the from your module path. + +The default name of new configuration file is "libnet.cfg", and by +default it is written to the current directory, unless otherwise +specified using the -o option. + +EOU + exit(0); +} + +#--------------------------------------------------------------------------- + +{ + my $oldcfgfile; + my @inc; + push @inc, $ENV{PERL5LIB} if exists $ENV{PERL5LIB}; + push @inc, $ENV{PERLLIB} if exists $ENV{PERLLIB}; + push @inc, @INC; + for (@inc) { + my $trycfgfile = File::Spec->catfile($_, $libnet_cfg_in); + if (-f $trycfgfile && -r $trycfgfile) { + $oldcfgfile = $trycfgfile; + last; + } + } + print "# old config $oldcfgfile\n" if defined $oldcfgfile; + for (sort keys %oldcfg) { + printf "%-20s %s\n", $_, + ref $oldcfg{$_} ? @{$oldcfg{$_}} : $oldcfg{$_}; + } + unless ($opt_c || $opt_d) { + print "# $0 -h for help\n"; + exit(0); + } +} + +#--------------------------------------------------------------------------- + +$oldcfg{'test_exist'} = 1 unless exists $oldcfg{'test_exist'}; +$oldcfg{'test_hosts'} = 1 unless exists $oldcfg{'test_hosts'}; + +#--------------------------------------------------------------------------- + +if($have_old && !$opt_d) + { + $msg = <<EDQ; + +Ah, I see you already have installed libnet before. + +Do you want to modify/update your configuration (y|n) ? +EDQ + + $opt_d = 1 + unless get_bool($msg,0); + } + +#--------------------------------------------------------------------------- + +$msg = <<EDQ; + +This script will prompt you to enter hostnames that can be used as +defaults for some of the modules in the libnet distribution. + +To ensure that you do not enter an invalid hostname, I can perform a +lookup on each hostname you enter. If your internet connection is via +a dialup line then you may not want me to perform these lookups, as +it will require you to be on-line. + +Do you want me to perform hostname lookups (y|n) ? +EDQ + +$cfg{'test_exist'} = get_bool($msg, $oldcfg{'test_exist'}); + +print <<EDQ unless $cfg{'test_exist'}; + +*** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** + +OK I will not check if the hostnames you give are valid +so be very cafeful + +*** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** +EDQ + + +#--------------------------------------------------------------------------- + +print <<EDQ; + +The following questions all require a list of host names, separated +with spaces. If you do not have a host available for any of the +services, then enter a single space, followed by <CR>. To accept the +default, hit <CR> + +EDQ + +$msg = 'Enter a list of available NNTP hosts :'; + +$def = $oldcfg{'nntp_hosts'} || + [ default_hostname($ENV{NNTPSERVER},$ENV{NEWSHOST},'news') ]; + +$cfg{'nntp_hosts'} = get_host_list($msg,$def); + +#--------------------------------------------------------------------------- + +$msg = 'Enter a list of available SMTP hosts :'; + +$def = $oldcfg{'smtp_hosts'} || + [ default_hostname(split(/:/,$ENV{SMTPHOSTS} || ""), 'mailhost') ]; + +$cfg{'smtp_hosts'} = get_host_list($msg,$def); + +#--------------------------------------------------------------------------- + +$msg = 'Enter a list of available POP3 hosts :'; + +$def = $oldcfg{'pop3_hosts'} || []; + +$cfg{'pop3_hosts'} = get_host_list($msg,$def); + +#--------------------------------------------------------------------------- + +$msg = 'Enter a list of available SNPP hosts :'; + +$def = $oldcfg{'snpp_hosts'} || []; + +$cfg{'snpp_hosts'} = get_host_list($msg,$def); + +#--------------------------------------------------------------------------- + +$msg = 'Enter a list of available PH Hosts :' ; + +$def = $oldcfg{'ph_hosts'} || + [ default_hostname('dirserv') ]; + +$cfg{'ph_hosts'} = get_host_list($msg,$def); + +#--------------------------------------------------------------------------- + +$msg = 'Enter a list of available TIME Hosts :' ; + +$def = $oldcfg{'time_hosts'} || []; + +$cfg{'time_hosts'} = get_host_list($msg,$def); + +#--------------------------------------------------------------------------- + +$msg = 'Enter a list of available DAYTIME Hosts :' ; + +$def = $oldcfg{'daytime_hosts'} || $oldcfg{'time_hosts'}; + +$cfg{'daytime_hosts'} = get_host_list($msg,$def); + +#--------------------------------------------------------------------------- + +$msg = <<EDQ; + +Do you have a firewall/ftp proxy between your machine and the internet + +If you use a SOCKS firewall answer no + +(y|n) ? +EDQ + +if(get_bool($msg,0)) { + + $msg = <<'EDQ'; +What series of FTP commands do you need to send to your +firewall to connect to an external host. + +user/pass => external user & password +fwuser/fwpass => firewall user & password + +0) None +1) ----------------------- + USER user@remote.host + PASS pass +2) ----------------------- + USER fwuser + PASS fwpass + USER user@remote.host + PASS pass +3) ----------------------- + USER fwuser + PASS fwpass + SITE remote.site + USER user + PASS pass +4) ----------------------- + USER fwuser + PASS fwpass + OPEN remote.site + USER user + PASS pass +5) ----------------------- + USER user@fwuser@remote.site + PASS pass@fwpass +6) ----------------------- + USER fwuser@remote.site + PASS fwpass + USER user + PASS pass +7) ----------------------- + USER user@remote.host + PASS pass + AUTH fwuser + RESP fwpass + +Choice: +EDQ + $def = exists $oldcfg{'ftp_firewall_type'} ? $oldcfg{'ftp_firewall_type'} : 1; + $ans = Prompt($msg,$def); + $cfg{'ftp_firewall_type'} = 0+$ans; + $def = $oldcfg{'ftp_firewall'} || $ENV{FTP_FIREWALL}; + + $cfg{'ftp_firewall'} = get_hostname("FTP proxy hostname :", $def); +} +else { + delete $cfg{'ftp_firewall'}; +} + + +#--------------------------------------------------------------------------- + +if (defined $cfg{'ftp_firewall'}) + { + print <<EDQ; + +By default Net::FTP assumes that it only needs to use a firewall if it +cannot resolve the name of the host given. This only works if your DNS +system is setup to only resolve internal hostnames. If this is not the +case and your DNS will resolve external hostnames, then another method +is needed. Net::Config can do this if you provide the netmasks that +describe your internal network. Each netmask should be entered in the +form x.x.x.x/y, for example 127.0.0.0/8 or 214.8.16.32/24 + +EDQ +$def = []; +if(ref($oldcfg{'local_netmask'})) + { + $def = $oldcfg{'local_netmask'}; + print "Your current netmasks are :\n\n\t", + join("\n\t",@{$def}),"\n\n"; + } + +print " +Enter one netmask at each prompt, prefix with a - to remove a netmask +from the list, enter a '*' to clear the whole list, an '=' to show the +current list and an empty line to continue with Configure. + +"; + + my $mask = get_netmask("netmask :",$def); + $cfg{'local_netmask'} = $mask if ref($mask) && @$mask; + } + +#--------------------------------------------------------------------------- + +###$msg =<<EDQ; +### +###SOCKS is a commonly used firewall protocol. If you use SOCKS firewalls +###then enter a list of hostames +### +###Enter a list of available SOCKS hosts : +###EDQ +### +###$def = $cfg{'socks_hosts'} || +### [ default_hostname($ENV{SOCKS5_SERVER}, +### $ENV{SOCKS_SERVER}, +### $ENV{SOCKS4_SERVER}) ]; +### +###$cfg{'socks_hosts'} = get_host_list($msg,$def); + +#--------------------------------------------------------------------------- + +print <<EDQ; + +Normally when FTP needs a data connection the client tells the server +a port to connect to, and the server initiates a connection to the client. + +Some setups, in particular firewall setups, can/do not work using this +protocol. In these situations the client must make the connection to the +server, this is called a passive transfer. +EDQ + +if (defined $cfg{'ftp_firewall'}) { + $msg = "\nShould all FTP connections via a firewall/proxy be passive (y|n) ?"; + + $def = $oldcfg{'ftp_ext_passive'} || 0; + + $cfg{'ftp_ext_passive'} = get_bool($msg,$def); + + $msg = "\nShould all other FTP connections be passive (y|n) ?"; + +} +else { + $msg = "\nShould all FTP connections be passive (y|n) ?"; +} + +$def = $oldcfg{'ftp_int_passive'} || 0; + +$cfg{'ftp_int_passive'} = get_bool($msg,$def); + + +#--------------------------------------------------------------------------- + +$def = $oldcfg{'inet_domain'} || $ENV{LOCALDOMAIN}; + +$ans = Prompt("\nWhat is your local internet domain name :",$def); + +$cfg{'inet_domain'} = ($ans =~ /(\S+)/)[0]; + +#--------------------------------------------------------------------------- + +$msg = <<EDQ; + +If you specified some default hosts above, it is possible for me to +do some basic tests when you run `make test' + +This will cause `make test' to be quite a bit slower and, if your +internet connection is via dialup, will require you to be on-line +unless the hosts are local. + +Do you want me to run these tests (y|n) ? +EDQ + +$cfg{'test_hosts'} = get_bool($msg,$oldcfg{'test_hosts'}); + +#--------------------------------------------------------------------------- + +$msg = <<EDQ; + +To allow Net::FTP to be tested I will need a hostname. This host +should allow anonymous access and have a /pub directory + +What host can I use : +EDQ + +$cfg{'ftp_testhost'} = get_hostname($msg,$oldcfg{'ftp_testhost'}) + if $cfg{'test_hosts'}; + + +print "\n"; + +#--------------------------------------------------------------------------- + +my $fh = IO::File->new($libnet_cfg_out, "w") or + die "Cannot create `$libnet_cfg_out': $!"; + +print "Writing $libnet_cfg_out\n"; + +print $fh "{\n"; + +my $key; +foreach $key (keys %cfg) { + my $val = $cfg{$key}; + if(!defined($val)) { + $val = "undef"; + } + elsif(ref($val)) { + $val = '[' . join(",", + map { + my $v = "undef"; + if(defined $_) { + ($v = $_) =~ s/'/\'/sog; + $v = "'" . $v . "'"; + } + $v; + } @$val ) . ']'; + } + else { + $val =~ s/'/\'/sog; + $val = "'" . $val . "'" if $val =~ /\D/; + } + print $fh "\t'",$key,"' => ",$val,",\n"; +} + +print $fh "}\n"; + +$fh->close; + +############################################################################ +############################################################################ + +exit 0; +!NO!SUBS! + +close OUT or die "Can't close $file: $!"; +chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; +exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; +chdir $origdir; diff --git a/gnu/usr.bin/perl/utils/perlivp.PL b/gnu/usr.bin/perl/utils/perlivp.PL new file mode 100644 index 00000000000..fd58e878248 --- /dev/null +++ b/gnu/usr.bin/perl/utils/perlivp.PL @@ -0,0 +1,485 @@ +#!/usr/local/bin/perl + +use Config; +use File::Basename; +use Cwd; + +# List explicitly here the variables you want Configure to +# generate. Metaconfig only looks for shell variables, so you +# have to mention them as if they were shell variables, not +# %Config entries: +# $startperl +# $perlpath +# $eunicefix + +# This forces PL files to create target in same directory as PL file. +# This is so that make depend always knows where to find PL derivatives. +my $origdir = cwd; +chdir dirname($0); +my $file = basename($0, '.PL'); +$file .= '.com' if $^O eq 'VMS'; + +# Create output file. +open OUT,">$file" or die "Can't create $file: $!"; + +print "Extracting $file (with variable substitutions)\n"; + +# In this section, perl variables will be expanded during extraction. +# You can use $Config{...} to use Configure variables. + +print OUT <<"!GROK!THIS!"; +$Config{'startperl'} + eval 'exec $Config{'perlpath'} -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; +!GROK!THIS! + +# In the following, perl variables are not expanded during extraction. + +print OUT <<'!NO!SUBS!'; + +# perlivp V 0.02 + + +sub usage { + warn "@_\n" if @_; + print << " EOUSAGE"; +Usage: + + $0 [-p] [-v] | [-h] + + -p Print a preface before each test telling what it will test. + -v Verbose mode in which extra information about test results + is printed. Test failures always print out some extra information + regardless of whether or not this switch is set. + -h Prints this help message. + EOUSAGE + exit; +} + +use vars qw(%opt); # allow testing with older versions (do not use our) + +@opt{ qw/? H h P p V v/ } = qw(0 0 0 0 0 0 0); + +while ($ARGV[0] =~ /^-/) { + $ARGV[0] =~ s/^-//; + for my $flag (split(//,$ARGV[0])) { + usage() if '?' =~ /\Q$flag/; + usage() if 'h' =~ /\Q$flag/; + usage() if 'H' =~ /\Q$flag/; + usage("unknown flag: `$flag'") unless 'HhPpVv' =~ /\Q$flag/; + warn "$0: `$flag' flag already set\n" if $opt{$flag}++; + } + shift; +} + +$opt{p}++ if $opt{P}; +$opt{v}++ if $opt{V}; + +my $pass__total = 0; +my $error_total = 0; +my $tests_total = 0; + +!NO!SUBS! + +# We cannot merely check the variable `$^X' in general since on many +# Unixes it is the basename rather than the full path to the perl binary. +my $perlpath = ''; +if (defined($Config{'perlpath'})) { $perlpath = $Config{'perlpath'}; } +# Of course some platforms are distinct... +if ($^O eq 'VMS') { $perlpath = $^X; } + +# The useithreads Config variable plays a role in whether or not +# threads and threads/shared work when C<use>d. They apparently always +# get installed on systems that can run Configure. +my $useithreads = ''; +if (defined($Config{'useithreads'})) { $useithreads = $Config{'useithreads'}; } + +print OUT <<"!GROK!THIS!"; +my \$perlpath = '$perlpath'; +my \$useithreads = '$useithreads'; +!GROK!THIS! + +print OUT <<'!NO!SUBS!'; + +print "## Checking Perl binary via variable `\$perlpath' = $perlpath.\n" if $opt{'p'}; + +if (-x $perlpath) { + print "## Perl binary `$perlpath' appears executable.\n" if $opt{'v'}; + print "ok 1\n"; + $pass__total++; +} +else { + print "# Perl binary `$perlpath' does not appear executable.\n"; + print "not ok 1\n"; + $error_total++; +} +$tests_total++; + + +print "## Checking Perl version via variable `\$]'.\n" if $opt{'p'}; + +!NO!SUBS! + +print OUT <<"!GROK!THIS!"; +my \$ivp_VERSION = $]; + +!GROK!THIS! +print OUT <<'!NO!SUBS!'; +if ($ivp_VERSION == $]) { + print "## Perl version `$]' appears installed as expected.\n" if $opt{'v'}; + print "ok 2\n"; + $pass__total++; +} +else { + print "# Perl version `$]' installed, expected $ivp_VERSION.\n"; + print "not ok 2\n"; + $error_total++; +} +$tests_total++; + + +print "## Checking roots of the Perl library directory tree via variable `\@INC'.\n" if $opt{'p'}; + +my $INC_total = 0; +my $INC_there = 0; +foreach (@INC) { + next if $_ eq '.'; # skip -d test here + if ($^O eq 'MacOS') { + next if $_ eq ':'; # skip -d test here + next if $_ eq 'Dev:Pseudo:'; # why is this in @INC? + } + if (-d $_) { + print "## Perl \@INC directory `$_' exists.\n" if $opt{'v'}; + $INC_there++; + } + else { + print "# Perl \@INC directory `$_' does not appear to exist.\n"; + } + $INC_total++; +} +if ($INC_total == $INC_there) { + print "ok 3\n"; + $pass__total++; +} +else { + print "not ok 3\n"; + $error_total++; +} +$tests_total++; + + +print "## Checking installations of modules necessary for ivp.\n" if $opt{'p'}; + +my $needed_total = 0; +my $needed_there = 0; +foreach (qw(Config.pm ExtUtils/Installed.pm)) { + $@ = undef; + $needed_total++; + eval "require \"$_\";"; + if (!$@) { + print "## Module `$_' appears to be installed.\n" if $opt{'v'}; + $needed_there++; + } + else { + print "# Needed module `$_' does not appear to be properly installed.\n"; + } + $@ = undef; +} +if ($needed_total == $needed_there) { + print "ok 4\n"; + $pass__total++; +} +else { + print "not ok 4\n"; + $error_total++; +} +$tests_total++; + + +print "## Checking installations of extensions built with perl.\n" if $opt{'p'}; + +use Config; + +my $extensions_total = 0; +my $extensions_there = 0; +if (defined($Config{'extensions'})) { + my @extensions = split(/\s+/,$Config{'extensions'}); + foreach (@extensions) { + next if ($_ eq ''); + if ( $useithreads !~ /define/i ) { + next if ($_ eq 'threads'); + next if ($_ eq 'threads/shared'); + } + next if ($_ eq 'Devel/DProf'); + # VMS$ perl -e "eval ""require \""Devel/DProf.pm\"";"" print $@" + # \NT> perl -e "eval \"require 'Devel/DProf.pm'\"; print $@" + # DProf: run perl with -d to use DProf. + # Compilation failed in require at (eval 1) line 1. + eval " require \"$_.pm\"; "; + if (!$@) { + print "## Module `$_' appears to be installed.\n" if $opt{'v'}; + $extensions_there++; + } + else { + print "# Required module `$_' does not appear to be properly installed.\n"; + $@ = undef; + } + $extensions_total++; + } + + # A silly name for a module (that hopefully won't ever exist). + # Note that this test serves more as a check of the validity of the + # actuall required module tests above. + my $unnecessary = 'bLuRfle'; + + if (!grep(/$unnecessary/, @extensions)) { + $@ = undef; + eval " require \"$unnecessary.pm\"; "; + if ($@) { + print "## Unnecessary module `$unnecessary' does not appear to be installed.\n" if $opt{'v'}; + } + else { + print "# Unnecessary module `$unnecessary' appears to be installed.\n"; + $extensions_there++; + } + } + $@ = undef; +} +if ($extensions_total == $extensions_there) { + print "ok 5\n"; + $pass__total++; +} +else { + print "not ok 5\n"; + $error_total++; +} +$tests_total++; + + +print "## Checking installations of later additional extensions.\n" if $opt{'p'}; + +use ExtUtils::Installed; + +my $installed_total = 0; +my $installed_there = 0; +my $version_check = 0; +my $installed = ExtUtils::Installed -> new(); +my @modules = $installed -> modules(); +my @missing = (); +my $version = undef; +for (@modules) { + $installed_total++; + # Consider it there if it contains one or more files, + # and has zero missing files, + # and has a defined version + $version = undef; + $version = $installed -> version($_); + if ($version) { + print "## $_; $version\n" if $opt{'v'}; + $version_check++; + } + else { + print "# $_; NO VERSION\n" if $opt{'v'}; + } + $version = undef; + @missing = (); + @missing = $installed -> validate($_); + if ($#missing >= 0) { + print "# file",+($#missing == 0) ? '' : 's'," missing from installation:\n"; + print '# ',join(' ',@missing),"\n"; + } + elsif ($#missing == -1) { + $installed_there++; + } + @missing = (); +} +if (($installed_total == $installed_there) && + ($installed_total == $version_check)) { + print "ok 6\n"; + $pass__total++; +} +else { + print "not ok 6\n"; + $error_total++; +} +$tests_total++; + + +print "## Checking installations of *.h -> *.ph header files.\n" if $opt{'p'}; +my $ph_there = 0; +my $var = undef; +my $val = undef; +my $h_file = undef; +# Just about "any" C implementation ought to have a stdio.h (even if +# Config.pm may not list a i_stdio var). +my @ph_files = qw(stdio.ph); +# Add the ones that we know that perl thinks are there: +while (($var, $val) = each %Config) { + if ($var =~ m/i_(.+)/ && $val eq 'define') { + $h_file = $1; + # Some header and symbol names don't match for hysterical raisins. + $h_file = 'arpa/inet' if $h_file eq 'arpainet'; + $h_file = 'netinet/in' if $h_file eq 'niin'; + $h_file = 'netinet/tcp' if $h_file eq 'netinettcp'; + $h_file = 'sys/resource' if $h_file eq 'sysresrc'; + $h_file = 'sys/select' if $h_file eq 'sysselct'; + $h_file = 'sys/security' if $h_file eq 'syssecrt'; + $h_file = 'rpcsvc/dbm' if $h_file eq 'rpcsvcdbm'; + # This ought to distinguish syslog from sys/syslog. + # (NB syslog.ph is heavily used for the DBI pre-requisites). + $h_file =~ s{^sys(\w.+)}{sys/$1} unless $h_file eq 'syslog'; + push(@ph_files, "$h_file.ph"); + } +} +#foreach (qw(stdio.ph syslog.ph)) { +foreach (@ph_files) { + $@ = undef; + eval "require \"$_\";"; + if (!$@) { + print "## Perl header `$_' appears to be installed.\n" if $opt{'v'}; + $ph_there++; + } + else { + print "# Perl header `$_' does not appear to be properly installed.\n"; + } + $@ = undef; +} + +if (scalar(@ph_files) == $ph_there) { + print "ok 7\n"; + $pass__total++; +} +else { + print "not ok 7\n"; + $error_total++; +} +$tests_total++; + +# Final report (rather than feed ousrselves to Test::Harness::runtests() +# we simply format some output on our own to keep things simple and +# easier to "fix" - at least for now. + +if ($error_total == 0 && $tests_total) { + print "All tests successful.\n"; +} elsif ($tests_total==0){ + die "FAILED--no tests were run for some reason.\n"; +} else { + my $rate = 0.0; + if ($tests_total > 0) { $rate = sprintf "%.2f", 100.0 * ($pass__total / $tests_total); } + printf " %d/%d subtests failed, %.2f%% okay.\n", + $error_total, $tests_total, $rate; +} + +=head1 NAME + +B<perlivp> - Perl Installation Verification Procedure + +=head1 SYNOPSIS + +B<perlivp> [B<-p>] [B<-v>] [B<-h>] + +=head1 DESCRIPTION + +The B<perlivp> program is set up at Perl source code build time to test the +Perl version it was built under. It can be used after running: + + make install + +(or your platform's equivalent procedure) to verify that B<perl> and its +libraries have been installed correctly. A correct installation is verified +by output that looks like: + + ok 1 + ok 2 + +etc. + +=head1 OPTIONS + +=over 5 + +=item B<-h> help + +Prints out a brief help message. + +=item B<-p> print preface + +Gives a description of each test prior to performing it. + +=item B<-v> verbose + +Gives more detailed information about each test, after it has been performed. +Note that any failed tests ought to print out some extra information whether +or not -v is thrown. + +=back + +=head1 DIAGNOSTICS + +=over 4 + +=item * print "# Perl binary `$perlpath' does not appear executable.\n"; + +Likely to occur for a perl binary that was not properly installed. +Correct by conducting a proper installation. + +=item * print "# Perl version `$]' installed, expected $ivp_VERSION.\n"; + +Likely to occur for a perl that was not properly installed. +Correct by conducting a proper installation. + +=item * print "# Perl \@INC directory `$_' does not appear to exist.\n"; + +Likely to occur for a perl library tree that was not properly installed. +Correct by conducting a proper installation. + +=item * print "# Needed module `$_' does not appear to be properly installed.\n"; + +One of the two modules that is used by perlivp was not present in the +installation. This is a serious error since it adversely affects perlivp's +ability to function. You may be able to correct this by performing a +proper perl installation. + +=item * print "# Required module `$_' does not appear to be properly installed.\n"; + +An attempt to C<eval "require $module"> failed, even though the list of +extensions indicated that it should succeed. Correct by conducting a proper +installation. + +=item * print "# Unnecessary module `bLuRfle' appears to be installed.\n"; + +This test not coming out ok could indicate that you have in fact installed +a bLuRfle.pm module or that the C<eval " require \"$module_name.pm\"; "> +test may give misleading results with your installation of perl. If yours +is the latter case then please let the author know. + +=item * print "# file",+($#missing == 0) ? '' : 's'," missing from installation:\n"; + +One or more files turned up missing according to a run of +C<ExtUtils::Installed -E<gt> validate()> over your installation. +Correct by conducting a proper installation. + +=item * print "# Perl header `$_' does not appear to be properly installed.\n"; + +Correct by running B<h2ph> over your system's C header files. If necessary, +edit the resulting *.ph files to eliminate perl syntax errors. + +=back + +For further information on how to conduct a proper installation consult the +INSTALL file that comes with the perl source and the README file for your +platform. + +=head1 AUTHOR + +Peter Prymmer + +=cut + +!NO!SUBS! + +close OUT or die "Can't close $file: $!"; +chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; +exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; +chdir $origdir; + diff --git a/gnu/usr.bin/perl/utils/piconv.PL b/gnu/usr.bin/perl/utils/piconv.PL new file mode 100644 index 00000000000..e7be9849685 --- /dev/null +++ b/gnu/usr.bin/perl/utils/piconv.PL @@ -0,0 +1,48 @@ +#!/usr/local/bin/perl + +use Config; +use File::Basename qw(&basename &dirname); +use Cwd; + +# List explicitly here the variables you want Configure to +# generate. Metaconfig only looks for shell variables, so you +# have to mention them as if they were shell variables, not +# %Config entries. Thus you write +# $startperl +# to ensure Configure will look for $Config{startperl}. + +# This forces PL files to create target in same directory as PL file. +# This is so that make depend always knows where to find PL derivatives. +my $origdir = cwd; +chdir dirname($0); +my $file = basename($0, '.PL'); +$file .= '.com' if $^O eq 'VMS'; + +open OUT,">$file" or die "Can't create $file: $!"; + +print "Extracting $file (with variable substitutions)\n"; + +# In this section, perl variables will be expanded during extraction. +# You can use $Config{...} to use Configure variables. + +print OUT <<"!GROK!THIS!"; +$Config{startperl} + eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; +!GROK!THIS! + +use File::Spec; + +my $piconv = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "ext", "Encode", "bin"), "piconv"); + +if (open(PICONV, $piconv)) { + print OUT <PICONV>; + close PICONV; +} else { + die "$0: cannot find '$piconv'\n"; +} + +close OUT or die "Can't close $file: $!"; +chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; +exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; +chdir $origdir; |