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.0at70b / pat / patsnap.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/patsnap (with variable substitutions)"
18 cat >patsnap <<!GROK!THIS!
19 $startperl
20         eval "exec perl -S \$0 \$*"
21                 if \$running_under_some_shell;
22
23 # $Id: patsnap.SH,v 3.0.1.2 1994/01/24 14:33:08 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 # $Log: patsnap.SH,v $
34 # Revision 3.0.1.2  1994/01/24  14:33:08  ram
35 # patch16: now prefix error messages with program's name
36 # patch16: added ~/.dist_profile awareness
37 #
38 # Revision 3.0.1.1  1993/08/24  12:22:08  ram
39 # patch3: created
40 #
41
42 \$version = '$VERSION';
43 \$patchlevel = '$PATCHLEVEL';
44 !GROK!THIS!
45 cat >>patsnap <<'!NO!SUBS!'
46
47 $progname = &profile;           # Read ~/.dist_profile
48 require 'getopts.pl';
49 &usage unless $#ARGV >= 0;
50 &usage unless &Getopts("aho:V");
51
52 $SNAPSHOT = 'SNAPSHOT';         # Default snapshot file name
53
54 if ($opt_V) {
55         print STDERR "$progname $version PL$patchlevel\n";
56         exit 0;
57 } elsif ($opt_h) {
58         &usage;
59 }
60
61 &readpackage;
62
63 $RCSEXT = ',v' unless $RCSEXT;
64 $TOPDIR = '';                   # We are at the top-level directory
65 $SNAPSHOT = $opt_o if $opt_o;
66
67 if ($opt_a) {
68         open(MANI,"MANIFEST.new") || die "$progname: can't read MANIFEST.new: $!\n";
69         @ARGV = ();
70         while (<MANI>) {
71                 chop;
72                 s|^\./||;
73                 next if m|^patchlevel.h|;               # Special file
74                 ($_) = split(' ');
75                 next if -d;
76                 push(@ARGV,$_);
77         }
78         close MANI;
79 }
80
81 open(SNAPSHOT, ">$SNAPSHOT") || die "$progname: can't create $SNAPSHOT: $!\n";
82
83 foreach $file (@ARGV) {
84         $files = &rcsargs($file);
85         @files = split(' ',$files);
86         $revs=0;
87         $rlog = `rlog -r$baserev -r$revbranch $files 2>&1`;
88         ($revs) = ($rlog =~ /selected revisions: (\d+)/);
89         if (!$revs) {
90                 print "$progname: $file has never been checked in--skipping\n";
91                 next;
92         }
93         elsif ($revs == 1) {
94                 print "$progname: last revision for $file is $baserev.\n";
95                 print SNAPSHOT "$file\t$baserev\n";
96         }
97         else {
98                 ($lastrev) = ($rlog =~ /revision $revbranch\.(\d+)/);
99                 print "$progname: last revision for $file is $revbranch.$lastrev.\n";
100                 print SNAPSHOT "$file\t$revbranch.$lastrev\n";
101         }
102 }
103
104 close SNAPSHOT;
105
106 sub usage {
107         print STDERR <<EOM;
108 Usage: $progname [-ahV] [-o snapshot] [filelist]
109   -a : all the files in MANIFEST.new
110   -h : print this message and exit
111   -o : specify snapshot file output (default $SNAPSHOT)
112   -V : print version number and exit
113 EOM
114         exit 1;
115 }
116
117 !NO!SUBS!
118 $grep -v '^;#' ../pl/package.pl >>patsnap
119 $grep -v '^;#' ../pl/rcsargs.pl >>patsnap
120 $grep -v '^;#' ../pl/comment.pl >>patsnap
121 $grep -v '^;#' ../pl/tilde.pl >>patsnap
122 $grep -v '^;#' ../pl/profile.pl >>patsnap
123 chmod +x patsnap
124 $eunicefix patsnap