This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Populate metaconfig branch.
[metaconfig.git] / dist-3.0at70 / pat / patpost.SH
1 case $CONFIG in
2 '')
3         if test -f config.sh; then TOP=.;
4         elif test -f ../config.sh; then TOP=..;
5         elif test -f ../../config.sh; then TOP=../..;
6         elif test -f ../../../config.sh; then TOP=../../..;
7         elif test -f ../../../../config.sh; then TOP=../../../..;
8         else
9                 echo "Can't find config.sh."; exit 1
10         fi
11         . $TOP/config.sh
12         ;;
13 esac
14 case "$0" in
15 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
16 esac
17 echo "Extracting pat/patpost (with variable substitutions)"
18 cat >patpost <<!GROK!THIS!
19 $startperl
20         eval "exec perl -S \$0 \$*"
21                 if \$running_under_some_shell;
22
23 # $Id: patpost.SH,v 3.0.1.4 1995/05/12 12:25:58 ram Exp $
24 #
25 #  Copyright (c) 1991-1993, Raphael Manfredi
26 #  
27 #  You may redistribute only under the terms of the Artistic Licence,
28 #  as specified in the README file that comes with the distribution.
29 #  You may reuse parts of this distribution only within the terms of
30 #  that same Artistic Licence; a copy of which may be found at the root
31 #  of the source tree for dist 3.0.
32 #
33 # Original Author: Larry Wall <lwall@netlabs.com>
34 #
35 # $Log: patpost.SH,v $
36 # Revision 3.0.1.4  1995/05/12  12:25:58  ram
37 # patch54: added explicit From: header line pointing to the maintainer
38 #
39 # Revision 3.0.1.3  1994/01/24  14:32:09  ram
40 # patch16: now prefix error messages with program's name
41 # patch16: added ~/.dist_profile awareness
42 #
43 # Revision 3.0.1.2  1993/08/24  12:19:48  ram
44 # patch3: added ~name expansion for orgname
45 # patch3: random cleanup
46 #
47 # Revision 3.0.1.1  1993/08/19  06:42:41  ram
48 # patch1: leading config.sh searching was not aborting properly
49 #
50 # Revision 3.0  1993/08/18  12:10:47  ram
51 # Baseline for dist 3.0 netwide release.
52 #
53
54 \$inews='${inews-/usr/lib/news/inews}';
55 \$orgname='$orgname';
56 \$version = '$VERSION';
57 \$patchlevel = '$PATCHLEVEL';
58 !GROK!THIS!
59
60 cat >>patpost <<'!NO!SUBS!'
61
62 $progname = &profile;   # Read ~/.dist_profile
63 require 'getopts.pl';
64 &usage unless $#ARGV >= 0;
65 &usage unless &Getopts("hrV");
66
67 if ($opt_V) {
68         print STDERR "$progname $version PL$patchlevel\n";
69         exit 0;
70 } elsif ($opt_h) {
71         &usage;
72 }
73
74 $RCSEXT = ',v' unless $RCSEXT;
75 if ($inews eq 'inews') {
76         $inews = '/usr/lib/news/inews' if -f '/usr/lib/news/inews';
77 }
78
79 chdir '..' if -d '../bugs';
80
81 &readpackage;
82
83 $orgname = &tilda_expand($orgname);
84 chop($orgname = `cat $orgname`) if $orgname =~ m|^/|;
85
86 if ($opt_r) {
87         $repost = ' (REPOST)';
88 }
89
90 while ($_ = shift) {
91         if (/^(patch)?[1-9][\d\-]*$/) {
92                 s/^patch//;
93                 push(@argv,$_);
94         } else {
95                 push(@newsgroups,$_);
96         }
97 }
98 $newsgroups = join(',',@newsgroups) unless $#newsgroups < 0;
99 &usage unless $newsgroups;
100
101 @ARGV = @argv;
102 open(PL,"patchlevel.h") || die "$progname: can't open patchlevel.h: $!\n";
103 while (<PL>) {
104         $maxnum = $1 if /^#define\s+PATCHLEVEL\s+(\d+)/;
105 }
106 close PL;
107 die "$progname: malformed patchlevel.h file.\n" if $maxnum eq '';
108
109 if ($#ARGV < 0) {
110         @patseq = &patseq($maxnum);
111         $lastpat = pop(@patseq);
112         $argv = &rangeargs("$lastpat-$maxnum");
113 }
114 else {
115         $argv = &rangeargs(@ARGV);
116 }
117
118 @ARGV = split(' ',$argv);
119 $argv =~ s/ $//;
120
121 if ($#ARGV < 0) {
122         print STDERR "$progname: no patches specified.\n";
123         &usage;
124 } elsif ($#ARGV) {
125         print
126         "$progname: posting $package $baserev patches $argv to $newsgroups...\n";
127 } else {
128         print
129         "$progname: posting $package $baserev patch $argv to $newsgroups...\n";
130 }
131
132 chdir 'bugs' || die "$progname: can't cd to bugs: $!\n";
133
134 fork && exit;
135
136 until ($#ARGV < 0) {
137         $patnum = shift;
138         open(PATCH,"patch$patnum") ||
139                 die "$progname: can't open patch$patnum: $!\n";
140         open(XHEAD,"|$inews -h") || die "$progname: can't fork $inews: $!\n";
141         print XHEAD
142 "From: $maintloc ($maintname)
143 Newsgroups: $newsgroups
144 Subject: $package $baserev patch #$patnum$repost
145 Summary: This is an official patch for $package $baserev.  Please apply it.
146 Expires: 
147 References: 
148 Sender: 
149 Distribution: 
150 Organization: $orgname
151 Keywords: 
152
153 ";
154         while (<PATCH>) {
155                 print XHEAD;
156         }
157         close PATCH;
158         close XHEAD;
159         die "$progname: could not post patch$patnum.\n" if $?;
160 }
161
162 sub usage {
163         print STDERR <<EOM;
164 Usage: $progname [-hrV] patchlist newsgroups
165   -h : print this message and exit
166   -r : signals a repost
167   -V : print version number and exit
168 EOM
169         exit 1;
170 }
171
172 !NO!SUBS!
173 $grep -v '^;#' ../pl/package.pl >>patpost
174 $grep -v '^;#' ../pl/rangeargs.pl >>patpost
175 $grep -v '^;#' ../pl/patseq.pl >>patpost
176 $grep -v '^;#' ../pl/tilde.pl >>patpost
177 $grep -v '^;#' ../pl/profile.pl >>patpost
178 chmod +x patpost
179 $eunicefix patpost