X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=utils%2Fperlbug.PL;h=d9389ce7d14ee6d66e9ddf43ceba65dd86c5943f;hb=aaa68c4a88ea4a62f62819baf4cacc0ca679c5fa;hp=4685e42af2ace300c379807cdcad6c21d9d065a4;hpb=cca87523cf2ee6eb48a8a0b1a57f8bea2c4b1915;p=p5sagit%2Fp5-mst-13.2.git diff --git a/utils/perlbug.PL b/utils/perlbug.PL index 4685e42..d9389ce 100644 --- a/utils/perlbug.PL +++ b/utils/perlbug.PL @@ -2,6 +2,8 @@ use Config; use File::Basename qw(&basename &dirname); +use Cwd; +use File::Spec::Functions; # List explicitly here the variables you want Configure to # generate. Metaconfig only looks for shell variables, so you @@ -13,6 +15,7 @@ use File::Basename qw(&basename &dirname); # 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. +$origdir = cwd; chdir dirname($0); $file = basename($0, '.PL'); $file .= '.com' if $^O eq 'VMS'; @@ -21,7 +24,8 @@ open OUT, ">$file" or die "Can't create $file: $!"; # extract patchlevel.h information -open PATCH_LEVEL, "<../patchlevel.h" or die "Can't open patchlevel.h: $!"; +open PATCH_LEVEL, "<" . catfile(updir, "patchlevel.h") + or die "Can't open patchlevel.h: $!"; my $patchlevel_date = (stat PATCH_LEVEL)[9]; @@ -33,15 +37,15 @@ my @patches; while () { last if /^\s*}/; chomp; - s/^\s+,?"?//; - s/"?,?$//; + s/^\s+,?\s*"?//; + s/"?\s*,?$//; s/(['\\])/\\$1/g; push @patches, $_ unless $_ eq 'NULL'; } my $patch_desc = "'" . join("',\n '", @patches) . "'"; my $patch_tags = join "", map /(\S+)/ ? "+$1 " : (), @patches; -close PATCH_LEVEL; +close(PATCH_LEVEL) or die "Error closing patchlevel.h: $!"; # TO DO (prehaps): store/embed $Config::config_sh into perlbug. When perlbug is # used, compare $Config::config_sh with the stored version. If they differ then @@ -53,12 +57,14 @@ 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. +my $extract_version = sprintf("v%vd", $^V); + print OUT <<"!GROK!THIS!"; $Config{startperl} eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' if \$running_under_some_shell; -my \$config_tag1 = '$] - $Config{cf_time}'; +my \$config_tag1 = '$extract_version - $Config{cf_time}'; my \$patchlevel_date = $patchlevel_date; my \$patch_tags = '$patch_tags'; @@ -72,6 +78,7 @@ my \@patches = ( print OUT <<'!NO!SUBS!'; use Config; +use File::Spec; # keep perlbug Perl 5.005 compatible use Getopt::Std; use strict; @@ -84,7 +91,7 @@ BEGIN { $::HaveUtil = ($@ eq ""); }; -my $Version = "1.23"; +my $Version = "1.31"; # Changed in 1.06 to skip Mail::Send and Mail::Util if not available. # Changed in 1.07 to see more sendmail execs, and added pipe output. @@ -112,6 +119,14 @@ my $Version = "1.23"; # Changed in 1.21 Added '-nok' for reporting build failure DFD 98-05-05 # Changed in 1.22 Heavy reformatting & minor bugfixes HVDS 98-05-10 # Changed in 1.23 Restore -ok(ay): say 'success'; don't prompt +# Changed in 1.24 Added '-F' to save report HVDS 98-07-01 +# Changed in 1.25 Warn on failure to open save file. HVDS 98-07-12 +# Changed in 1.26 Don't require -t STDIN for -ok. HVDS 98-07-15 +# Changed in 1.27 Added Mac OS and File::Spec support CNANDOR 99-07-27 +# Changed in 1.28 Additional questions for Perlbugtron RFOLEY 20.03.2000 +# Changed in 1.29 Perlbug(tron): auto(-ok), short prompts RFOLEY 05-05-2000 +# Changed in 1.30 Added warnings on failure to open files MSTEVENS 13-07-2000 +# Changed in 1.31 Add checks on close().Fix my $var unless. TJENNESS 26-07-2000 # TODO: - Allow the user to re-name the file on mail failure, and # make sure failure (transmission-wise) of Mail::Send is @@ -119,23 +134,25 @@ my $Version = "1.23"; # - Test -b option my( $file, $usefile, $cc, $address, $perlbug, $testaddress, $filename, - $subject, $from, $verbose, $ed, + $subject, $from, $verbose, $ed, $outfile, $Is_MacOS, $category, $severity, $fh, $me, $Is_MSWin32, $Is_VMS, $msg, $body, $andcc, %REP, $ok); -my $config_tag2 = "$] - $Config{cf_time}"; +my $perl_version = $^V ? sprintf("v%vd", $^V) : $]; + +my $config_tag2 = "$perl_version - $Config{cf_time}"; Init(); if ($::opt_h) { Help(); exit; } if ($::opt_d) { Dump(*STDOUT); exit; } -if (!-t STDIN) { +if (!-t STDIN && !($ok and not $::opt_n)) { paraprint < { + 'default' => 'core', + 'ok' => 'install', + 'opts' => [qw(core docs install library utilities)], # patch, notabug + }, + 'severity' => { + 'default' => 'low', + 'ok' => 'none', + 'opts' => [qw(critical high medium low wishlist none)], # zero + }, + ); + die "Invalid alternative($name) requested\n" unless grep(/^$name$/, keys %alts); + my $alt = ""; + if ($ok) { + $alt = $alts{$name}{'ok'}; + } else { + my @alts = @{$alts{$name}{'opts'}}; + paraprint < 5) { + die "Invalid $name: aborting.\n"; + } + print "Please enter a \u$name [$alts{$name}{'default'}]: "; + $alt = <>; + chomp $alt; + if ($alt =~ /^\s*$/) { + $alt = $alts{$name}{'default'}; + } + } while !((($alt) = grep(/^$alt/i, @alts))); + } + lc $alt; +} + sub Init { # -------- Setup -------- $Is_MSWin32 = $^O eq 'MSWin32'; $Is_VMS = $^O eq 'VMS'; + $Is_MacOS = $^O eq 'MacOS'; + + @ARGV = split m/\s+/, + MacPerl::Ask('Provide command-line args here (-h for help):') + if $Is_MacOS && $MacPerl::Version =~ /App/; - getopts("dhva:s:b:f:r:e:SCc:to:n:"); + if (!getopts("dhva:s:b:f:F:r:e:SCc:to:n:")) { Help(); exit; }; # This comment is needed to notify metaconfig that we are # using the $perladmin, $cf_by, and $cf_time definitions. @@ -181,6 +245,9 @@ sub Init { # File to send as report $file = $::opt_f || ""; + # File to output to + $outfile = $::opt_F || ""; + # Body of report $body = $::opt_b || ""; @@ -188,6 +255,7 @@ sub Init { $ed = $::opt_e || $ENV{VISUAL} || $ENV{EDITOR} || $ENV{EDIT} || ($Is_VMS && "edit/tpu") || ($Is_MSWin32 && "notepad") + || ($Is_MacOS && '') || "vi"; # Not OK - provide build failure template by finessing OK report @@ -224,7 +292,7 @@ EOF $::opt_C = 1; # don't send a copy to the local admin $::opt_s = 1; # we have a subject line $subject = ($::opt_n ? 'Not ' : '') - . "OK: perl $] ${patch_tags}on" + . "OK: perl $perl_version ${patch_tags}on" ." $::Config{'archname'} $::Config{'osvers'} $subject"; $ok = 1; } else { @@ -247,7 +315,12 @@ EOF # My username $me = $Is_MSWin32 ? $ENV{'USERNAME'} : $^O eq 'os2' ? $ENV{'USER'} || $ENV{'LOGNAME'} + : $Is_MacOS ? $ENV{'USER'} : eval { getpwuid($<) }; # May be missing + + $from = $::Config{'cf_email'} + if !$from && $::Config{'cf_email'} && $::Config{'cf_by'} && $me && + ($me eq $::Config{'cf_by'}); } # sub Init sub Query { @@ -295,6 +368,13 @@ EOF my $guess; $guess = $ENV{'REPLY-TO'} || $ENV{'REPLYTO'} || ''; + if ($Is_MacOS) { + require Mac::InternetConfig; + $guess = $Mac::InternetConfig::InternetConfig{ + Mac::InternetConfig::kICEmail() + }; + } + unless ($guess) { my $domain; if ($::HaveUtil) { @@ -403,6 +483,12 @@ EOF } } + # Prompt for category of bug + $category ||= ask_for_alternatives('category'); + + # Prompt for severity of bug + $severity ||= ask_for_alternatives('severity'); + # Generate scratch file to edit report in $filename = filename(); @@ -435,12 +521,12 @@ EOF } # Generate report - open(REP,">$filename"); + open(REP,">$filename") or die "Unable to create report file `$filename': $!\n"; my $reptype = !$ok ? "bug" : $::opt_n ? "build failure" : "success"; print REP <) { print REP $_ } - close(F); + close(F) or die "Error closing `$file': $!"; } else { print REP <) { s/\s+//g; $REP{$_}++; } - close(REP); + close(REP) or die "Error closing report file `$filename': $!"; } # sub Query sub Dump { local(*OUT) = @_; - print REP "\n---\n"; - print REP "This perlbug was built using Perl $config_tag1\n", + print OUT <; + } if ($sts) { paraprint <; chop $action; @@ -623,23 +728,26 @@ EOF chop $file; $file = "perlbug.rep" if $file eq ""; - open(FILE, ">$file"); - open(REP, "<$filename"); + unless (open(FILE, ">$file")) { + print "\nError opening $file: $!\n\n"; + goto retry; + } + open(REP, "<$filename") or die "Couldn't open file `$filename': $!\n"; print FILE "To: $address\nSubject: $subject\n"; print FILE "Cc: $cc\n" if $cc; print FILE "Reply-To: $from\n" if $from; print FILE "\n"; while () { print FILE } - close(REP); - close(FILE); + close(REP) or die "Error closing report file `$filename': $!"; + close(FILE) or die "Error closing $file: $!"; print "\nMessage saved in `$file'.\n"; exit; } elsif ($action =~ /^(d|l|sh)/i ) { # isplay, ist, ow # Display the message - open(REP, "<$filename"); + open(REP, "<$filename") or die "Couldn't open file `$filename': $!\n"; while () { print $_ } - close(REP); + close(REP) or die "Error closing report file `$filename': $!"; } elsif ($action =~ /^se/i) { # end # Send the message print "Are you certain you want to send this message?\n" @@ -671,15 +779,19 @@ EOF sub Send { # Message has been accepted for transmission -- Send the message + if ($outfile) { + open SENDMAIL, ">$outfile" or die "Couldn't open '$outfile': $!\n"; + goto sendout; + } if ($::HaveSend) { $msg = new Mail::Send Subject => $subject, To => $address; $msg->cc($cc) if $cc; $msg->add("Reply-To",$from) if $from; $fh = $msg->open; - open(REP, "<$filename"); + open(REP, "<$filename") or die "Couldn't open `$filename': $!\n"; while () { print $fh $_ } - close(REP); + close(REP) or die "Error closing $filename: $!"; $fh->close; print "\nMessage sent.\n"; @@ -725,17 +837,18 @@ So you may attempt to find some way of sending your message, it has been left in the file `$filename'. EOF open(SENDMAIL, "|$sendmail -t") || die "'|$sendmail -t' failed: $!"; +sendout: print SENDMAIL "To: $address\n"; print SENDMAIL "Subject: $subject\n"; print SENDMAIL "Cc: $cc\n" if $cc; print SENDMAIL "Reply-To: $from\n" if $from; print SENDMAIL "\n\n"; - open(REP, "<$filename"); + open(REP, "<$filename") or die "Couldn't open `$filename': $!\n"; while () { print SENDMAIL $_ } - close(REP); + close(REP) or die "Error closing $filename: $!"; if (close(SENDMAIL)) { - print "\nMessage sent.\n"; + printf "\nMessage %s.\n", $outfile ? "saved" : "sent"; } else { warn "\nSendmail returned status '", $? >> 8, "'\n"; } @@ -751,7 +864,7 @@ It is designed to be used interactively. Normally no arguments will be needed. Usage: -$0 [-v] [-a address] [-s subject] [-b body | -f file ] +$0 [-v] [-a address] [-s subject] [-b body | -f inpufile ] [ -F outputfile ] [-r returnaddress] [-e editor] [-c adminaddress | -C] [-S] [-t] [-h] $0 [-v] [-r returnaddress] [-ok | -okay | -nok | -nokay] @@ -762,6 +875,7 @@ Options: -v Include Verbose configuration data in the report -f File containing the body of the report. Use this to quickly send a prepared message. + -F File to output the resulting mail message to, instead of mailing. -S Send without asking for confirmation. -a Address to send the report to. Defaults to `$address'. -c Address to send copy of report to. Defaults to `$cc'. @@ -774,7 +888,7 @@ Options: this if you don't give it here. -e Editor to use. -t Test mode. The target address defaults to `$testaddress'. - -d Data mode (the default if you redirect or pipe output.) + -d Data mode (the default if you redirect or pipe output.) This prints out your configuration data, without mailing anything. You can use this with -v to get more complete data. -ok Report successful build on this system to perl porters @@ -793,11 +907,12 @@ EOF sub filename { my $dir = $Is_VMS ? 'sys$scratch:' : ($Is_MSWin32 && $ENV{'TEMP'}) ? $ENV{'TEMP'} - : '/tmp/'; + : $Is_MacOS ? $ENV{'TMPDIR'} + : '/tmp'; $filename = "bugrep0$$"; - $dir .= "\\" if $Is_MSWin32 and $dir !~ m|[\\/]$|; - $filename++ while -e "$dir$filename"; - $filename = "$dir$filename"; +# $dir .= "\\" if $Is_MSWin32 and $dir !~ m|[\\/]$|; + $filename++ while -e File::Spec->catfile($dir, $filename); + $filename = File::Spec->catfile($dir, $filename); } sub paraprint { @@ -824,7 +939,8 @@ perlbug - how to submit bug reports on Perl =head1 SYNOPSIS B S<[ B<-v> ]> S<[ B<-a> I
]> S<[ B<-s> I ]> -S<[ B<-b> I | B<-f> I ]> S<[ B<-r> I ]> +S<[ B<-b> I | B<-f> I ]> S<[ B<-F> I ]> +S<[ B<-r> I ]> S<[ B<-e> I ]> S<[ B<-c> I | B<-C> ]> S<[ B<-S> ]> S<[ B<-t> ]> S<[ B<-d> ]> S<[ B<-h> ]> @@ -855,7 +971,7 @@ this checklist: =over 4 -=item What version of perl you are running? +=item What version of Perl you are running? Type C at the command line to find out. @@ -863,22 +979,29 @@ Type C at the command line to find out. Look at http://www.perl.com/ to find out. If it is not the latest released version, get that one and see whether your bug has been -fixed. Note that bug reports about old versions of perl, especially +fixed. Note that bug reports about old versions of Perl, especially those prior to the 5.0 release, are likely to fall upon deaf ears. You are on your own if you continue to use perl1 .. perl4. =item Are you sure what you have is a bug? A significant number of the bug reports we get turn out to be documented -features in perl. Make sure the behavior you are witnessing doesn't fall +features in Perl. Make sure the behavior you are witnessing doesn't fall under that category, by glancing through the documentation that comes -with perl (we'll admit this is no mean task, given the sheer volume of +with Perl (we'll admit this is no mean task, given the sheer volume of it all, but at least have a look at the sections that I relevant). Be aware of the familiar traps that perl programmers of various hues fall into. See L. -Try to study the problem under the perl debugger, if necessary. +Check in L to see what any Perl error message(s) mean. +If message isn't in perldiag, it probably isn't generated by Perl. +Consult your operating system documentation instead. + +If you are on a non-UNIX platform check also L, as some +features may be unimplemented or work differently. + +Try to study the problem under the Perl debugger, if necessary. See L. =item Do you have a proper test case? @@ -893,12 +1016,23 @@ A good test case is almost always a good candidate to be on the perl test suite. If you have the time, consider making your test case so that it will readily fit into the standard test suite. +Remember also to include the B error messages, if any. +"Perl complained something" is not an exact error message. + +If you get a core dump (or equivalent), you may use a debugger +(B, B, etc) to produce a stack trace to include in the bug +report. NOTE: unless your Perl has been compiled with debug info +(often B<-g>), the stack trace is likely to be somewhat hard to use +because it will most probably contain only the function names and not +their arguments. If possible, recompile your Perl with debug info and +reproduce the dump and the stack trace. + =item Can you describe the bug in plain English? The easier it is to understand a reproducible bug, the more likely it will be fixed. Anything you can provide by way of insight into the -problem helps a great deal. In other words, try to analyse the -problem to the extent you feel qualified and report your discoveries. +problem helps a great deal. In other words, try to analyze the +problem (to the extent you can) and report your discoveries. =item Can you fix the bug yourself? @@ -931,10 +1065,15 @@ it to B. If, for some reason, you cannot run C at all on your system, be sure to include the entire output produced by running C (note the uppercase V). +Whether you use C or send the email manually, please make +your Subject line informative. "a bug" not informative. Neither is +"perl crashes" nor "HELP!!!". These don't help. +A compact description of what's wrong is fine. + =back Having done your bit, please be prepared to wait, to be told the bug -is in your code, or even to get no reply at all. The perl maintainers +is in your code, or even to get no reply at all. The Perl maintainers are busy folks, so if your problem is a small one or if it is difficult to understand or already known, they may not respond with a personal reply. If it is important to you that your bug be fixed, do monitor the @@ -980,6 +1119,12 @@ Editor to use. File containing the body of the report. Use this to quickly send a prepared message. +=item B<-F> + +File to output the results to instead of sending as an email. Useful +particularly when running perlbug on a machine with no direct internet +connection. + =item B<-h> Prints a brief summary of the options. @@ -1039,15 +1184,19 @@ Include verbose configuration data in the report. =head1 AUTHORS Kenneth Albanowski (Ekjahds@kjahds.comE), subsequently Itored -by Gurusamy Sarathy (Egsar@umich.eduE), Tom Christiansen +by Gurusamy Sarathy (Egsar@activestate.comE), Tom Christiansen (Etchrist@perl.comE), Nathan Torkington (Egnat@frii.comE), Charles F. Randall (Ecfr@pobox.comE), Mike Guy -(Emjtg@cam.a.ukE), Dominic Dunlop (Edomo@computer.orgE) -and Hugo van der Sanden (Ehv@crypt0.demon.co.ukE). +(Emjtg@cam.a.ukE), Dominic Dunlop (Edomo@computer.orgE), +Hugo van der Sanden (Ehv@crypt0.demon.co.ukE), +Jarkko Hietaniemi (Ejhi@iki.fiE), Chris Nandor +(Epudge@pobox.comE), Jon Orwant (Eorwant@media.mit.eduE, +and Richard Foley (Erichard@rfi.netE). =head1 SEE ALSO -perl(1), perldebug(1), perltrap(1), diff(1), patch(1) +perl(1), perldebug(1), perldiag(1), perlport(1), perltrap(1), +diff(1), patch(1), dbx(1), gdb(1) =head1 BUGS @@ -1060,4 +1209,4 @@ None known (guess what must have been used to report them?) 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;