home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: jv@mh.nl (Johan Vromans)
- Subject: v35i074: makepatch - Generate patch kits, version 1.6, Part01/01
- Message-ID: <1993Feb22.033831.14390@sparky.imd.sterling.com>
- X-Md4-Signature: 992e1ccc2d6fdaac6a38e7bc7c4aa9c9
- Date: Mon, 22 Feb 1993 03:38:31 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: jv@mh.nl (Johan Vromans)
- Posting-number: Volume 35, Issue 74
- Archive-name: makepatch/part01
- Environment: Perl
-
- This is makepatch, a program to generate a patch file from two files
- or directories.
-
- It resembles "diff -c -r -N", but:
-
- - it is always recursive;
- - it handles 'patchlevel.h' first;
- - it supplies 'Index:' and 'Prereq:' lines;
- - it can use 'manifest' files;
- - it generates shell commands to remove files;
- - it can manipulate manifest files.
-
- As distributed, it assumes that perl resides in /usr/local/bin. You
- have to change the first line of makepatch.pl if your perl is in a
- different location.
-
- To install: edit the Makefile (if needed) and type 'make install'.
-
- Johan Vromans jv@mh.nl via internet backbones
- Multihouse Automatisering bv uucp:..!{uunet,sun4nl}!mh.nl!jv
- Doesburgweg 7, 2803 PL Gouda, The Netherlands phone/fax: +31 1820 62911/62500
- ------------------------ "Arms are made for hugging" -------------------------
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: README MANIFEST Makefile makepatch.man makepatch.pl
- # Wrapped by kent@sparky on Sat Feb 20 23:29:49 1993
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 1 (of 1)."'
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(861 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XThis is makepatch, a program to generate a patch file from two files
- Xor directories.
- X
- XIt resembles "diff -c -r -N", but:
- X
- X - it is always recursive;
- X - it handles 'patchlevel.h' first;
- X - it supplies 'Index:' and 'Prereq:' lines;
- X - it can use 'manifest' files;
- X - it generates shell commands to remove files;
- X - it can manipulate manifest files.
- X
- XAs distributed, it assumes that perl resides in /usr/local/bin. You
- Xhave to change the first line of makepatch.pl if your perl is in a
- Xdifferent location.
- X
- XTo install: edit the Makefile (if needed) and type 'make install'.
- X
- XJohan Vromans jv@mh.nl via internet backbones
- XMultihouse Automatisering bv uucp:..!{uunet,sun4nl}!mh.nl!jv
- XDoesburgweg 7, 2803 PL Gouda, The Netherlands phone/fax: +31 1820 62911/62500
- X------------------------ "Arms are made for hugging" -------------------------
- END_OF_FILE
- if test 861 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'MANIFEST' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MANIFEST'\"
- else
- echo shar: Extracting \"'MANIFEST'\" \(171 characters\)
- sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
- XMANIFEST for makepatch 1.6
- X
- XREADME Short description
- XMANIFEST List of files
- XMakefile Simple Makefile to install it
- Xmakepatch.pl The program
- Xmakepatch.man The manual page
- END_OF_FILE
- if test 171 -ne `wc -c <'MANIFEST'`; then
- echo shar: \"'MANIFEST'\" unpacked with wrong size!
- fi
- # end of 'MANIFEST'
- fi
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(649 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- XVERSION = 1.6
- XBINDIR = /usr/local/bin
- XMANEXT = 1
- XMANDIR = /usr/local/man/man$(MANEXT)
- X
- XINSTALL_PROGRAM = install -c -m 0555
- XINSTALL_DATA = install -c -m 0444
- X
- Xall:
- X @echo "Edit the Makefile and issue"
- X @echo "'make install' to install makepatch"
- X
- Xinstall:
- X $(INSTALL_PROGRAM) makepatch.pl $(BINDIR)/makepatch
- X $(INSTALL_DATA) makepatch.man $(MANDIR)/makepatch.$(MANEXT)
- X
- Xdist:
- X ln -s . makepatch-$(VERSION)
- X makepatch -quiet -filelist -prefix makepatch-$(VERSION)/ MANIFEST |\
- X gtar -zcvf makepatch-$(VERSION).tar.Z -T -
- X rm -f makepatch-$(VERSION)
- X
- Xshar:
- X makepatch -quiet -filelist -nosort MANIFEST |\
- X shar -f -F -S > makepatch-$(VERSION).shar
- END_OF_FILE
- if test 649 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'makepatch.man' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makepatch.man'\"
- else
- echo shar: Extracting \"'makepatch.man'\" \(5543 characters\)
- sed "s/^X//" >'makepatch.man' <<'END_OF_FILE'
- X.TH MAKEPATCH 1 "93/02/13" "Version 1.6"
- X.SH NAME
- Xmakepatch \- create patch diffs between two versions of source
- X.SH SYNOPSIS
- X.B makepatch
- X.RI [ options ]
- X.I old new
- X.PP
- X.B makepatch
- X\-filelist
- X.RI [ options ]
- X.I manifest
- X.SH DESCRIPTION
- X.I Makepatch
- Xgenerates a set of differences between two files or two sets of files
- Xmaintained in two different directories and prints the results to
- X\fIstdout\fP.
- XThis resulting output is suitable for use by the
- X.IR patch (1)
- Xprogram to update copies of the target file(s) from the \fIold\fP
- Xto the \fInew\fP version.
- X.LP
- XFeatures of this utility include:
- X.in +2n
- X.na
- X.ti -2n
- X\- Recursive descend through sub-directories.
- X.ti -2n
- X\- Generation of commands to remove obsolete files.
- X.ti -2n
- X\- Automatic handling of the \fIpatchlevel.h\fP file first.
- X.ti -2n
- X\- Automatic inclusion of \fIIndex:\fP and \fIPrereq:\fP lines.
- X.ti -2n
- X\- Ability to utilize specified \fImanifest\fP file(s).
- X.ad
- X.in -2n
- X.SH ARGUMENTS
- X.TP 6
- X.I old
- XThis is the name of either a single file or else a directory which
- Xcontains copies of the older version of the target file(s); in
- Xother words, copies of the file(s) \fIprior\fP to any modifications.
- X.TP
- X.I new
- XThis is the name of either a single file or else a directory which
- Xcontains copies of the newer version of the target file(s); in
- Xother words, copies of the file(s) \fIafter\fP the modifications have
- Xbeen made.
- XA
- X.IR rm (1)
- Xcommand will automatically be generated for every
- X\fIold\fP file that no longer has a corresponding \fInew\fP version.
- X.SH "MAKEPATCH OPTIONS"
- X.TP 6
- X\fB\-diff\fP \fIcmd\fP
- XIf specified, \fIcmd\fP is the command to be used to generate the
- Xdifferences between the two versions of the files.
- XIf not specified, this command defaults to "\fBdiff \-c\fP".
- X.TP 6
- X\fB\-patchlevel\fP \fIpfile\fP
- XIf specified, \fIpfile\fP indicates an alternate file that is to be
- Xused in lieu of "\fBpatchlevel.h\fP".
- X.TP 6
- X\fB\-man\fP[\fBifest\fP] \fImfile\fP
- XIf specified, \fImfile\fP indicates the name of the manifest file
- Xwhich consists of a list of the files contained in both the \fIold\fP
- Xand the \fInew\fP directories.
- X.TP 6
- X\fB\-oldman\fP[\fBifest\fP] \fIomfile\fP
- XIf specified, \fIomfile\fP indicates the name of the manifest file
- Xwhich consists of a list of the files contained in the \fIold\fP
- Xdirectory.
- XThis option is designed to be used in conjunction with the
- X\%\fB-newmanifest\fP option.
- XNote that the \fIold\fP and \fInew\fP directories must still be
- Xindicated.
- X.TP 6
- X\fB\-newman\fP[\fBifest\fP] \fInmfile\fP
- XIf specified, \fInmfile\fP indicates the name of the manifest file
- Xwhich consists of a list of the files contained in the \fInew\fP
- Xdirectory.
- XThis option is designed to be used in conjunction with the
- X\%\fB-oldmanifest\fP option.
- XNote that the \fIold\fP and \fInew\fP directories must still be
- Xindicated.
- X.SH "FILELIST OPTIONS"
- X.TP 6
- X.BR \-file [ list ]
- XThis option instructs
- X.I makepatch
- Xto read a manifest file, and output the list of files included in
- Xthis manifest. This option is useful to turn the contents of a
- Xmanifest file into a list of files suitable for other programs.
- X.TP 6
- X\fB\-man\fP[\fBifest\fP] \fImfile\fP
- XIf specified, \fImfile\fP indicates the name of the manifest file to
- Xbe used. Alternatively, the name of the manifest file may follow the
- Xcommand line options.
- X.TP 6
- X.B \-prefix
- X.I string
- XEvery entry in the manifest file is prefixed with
- X.I string
- Xbefore it is written to
- X.IR stdout .
- X.TP 6
- X.B \-nosort
- XRetain the order of filenames from the manifest file.
- X.SH "GENERAL OPTIONS"
- X.TP 6
- X.B \-verbose
- XThis is the default mode which displays information
- Xconcerning \fBmakepatch\fP's activity to \fIstderr\fP.
- X.TP 6
- X.B \-quiet
- XThe opposite of \fB-verbose\fP.
- XThis instructs \fImakepatch\fP to suppress the display of
- Xactivity information.
- X.TP 6
- X.B \-help
- XThis causes a short help message to be displayed, after which the
- Xprogram immediately exits.
- X.SH "MANIFEST FILES"
- XAlthough there is no formal standard for manifest files, the following
- Xrules apply:
- X.TP 2n
- X\-
- XIf the second line from the manifest file looks like a separator
- Xline (e.g. it is empty, or contains only dashes), it is discarded and
- Xso is the first line.
- X.TP 2n
- X\-
- XEmpty lines and lines that start with a
- X.B #
- Xare ignored.
- X.TP 2n
- X\-
- XIf there are multiple space-separated ``words'' on a line, the
- Xfirst word is considered to be the filename.
- X.SH EXAMPLES
- XSuppose you have a directory tree
- X.B emacs\-18.58
- Xcontaining the sources for GNU Emacs 18.58, and a directory tree
- X.B emacs\-18.59
- Xcontaining the sources for GNU Emacs 18.59. The following command will
- Xgenerate the patch file needed to transform the 18.58 sources into
- X18.59:
- X
- X.in +6n
- X.na
- Xmakepatch emacs-18.58 emacs-18.59 > emacs-18.58-18.59.diff
- X.in
- X.ad
- X
- XThis is one way to generate and use manifest files:
- X
- X.in +6n
- X.na
- X(cd emacs-18.58; find . -type f -print > MANIFEST)
- X.br
- X(cd emacs-18.59; find . -type f -print > MANIFEST)
- X.br
- Xmakepatch \e
- X.in +4n
- X-oldmanifest emacs-18.58/MANIFEST \e
- X.br
- X-newmanifest emacs-18.59/MANIFEST \e
- X.br
- Xemacs-18.58 emacs-18.59 > emacs-18.58-18.59.diff
- X.in -10n
- X.ad
- X
- XThe following example transforms the manifest file into a list of
- Xfiles suitable for GNU tar. Note the trailing
- X.B /
- Xin the prefix string:
- X
- X.na
- X.in +6n
- Xmakepatch -filelist -prefix emacs-18.59/ emacs-18.59/MANIFEST |
- X.in +4n
- Xgtar -zcvf emacs-18.59.tar.Z -T -
- X.in -10n
- X.ad
- X
- X.SH "SEE ALSO"
- X.IR diff (1),
- X.IR patch (1),
- X.IR perl (1),
- X.IR rm (1).
- X.SH AUTHORS
- XJohan Vromans (jv@mh.nl).
- X.br
- XJeffery Small (jeff@cjsa.uucp) donated the base version of this manual
- Xpage that inspired me to complete it.
- END_OF_FILE
- if test 5543 -ne `wc -c <'makepatch.man'`; then
- echo shar: \"'makepatch.man'\" unpacked with wrong size!
- fi
- # end of 'makepatch.man'
- fi
- if test -f 'makepatch.pl' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makepatch.pl'\"
- else
- echo shar: Extracting \"'makepatch.pl'\" \(11375 characters\)
- sed "s/^X//" >'makepatch.pl' <<'END_OF_FILE'
- X#!/usr/local/bin/perl
- X# makepatch.pl -- generate batch of patches.
- X# SCCS Status : @(#)@ makepatch.pl 1.6
- X# Author : Johan Vromans
- X# Created On : Tue Jul 7 20:39:39 1992
- X# Last Modified By: Johan Vromans
- X# Last Modified On: Sat Feb 13 17:23:06 1993
- X# Update Count : 125
- X# Status : Released to USEnet.
- X#
- X# Generate a patch from two files or directories.
- X#
- X# Resembles "diff -c -r -N", but:
- X#
- X# - always recursive
- X# - handles 'patchlevel.h' first
- X# - supplies 'Index:' and 'Prereq:' lines
- X# - can use manifest file
- X# - generates shell commands to remove files
- X# - manipulates manifest files
- X#
- X################################################################
- X#
- X# Usage:
- X#
- X# makepatch <old-dir> <new-dir
- X#
- X# This will compare all files in <new-dir> against the files in
- X# <old-dir>, and generate a bunch of patches to transform every
- X# file in <old-dir> into the corresponding one in <new-dir>.
- X# Files that appear in <new-dir> but not in <old-dir> are created.
- X# For files that appear in <old-dir> but not in <new-dir>
- X# 'rm'-commands are generated at the beginning of the patch.
- X#
- X# Using MANIFEST files:
- X#
- X# makepatch -oldmanifest <oldmanifest> -newmanifest <newmanifest> \
- X# <new-dir> <old-dir>
- X#
- X# <oldmanifest> and <newmanifest> list the files in <old-dir>
- X# and <new-dir> that are to be examined.
- X# Only the files that are named will be examined.
- X# <oldmanifest> should contain the names of the files relative to
- X# <old-dir> and <newmanifest> should contain the names of the files
- X# relative to <new-dir>.
- X#
- X# makepatch -manifest <manifest> <new-dir> <old-dir>
- X#
- X# This is a simplified form of the above example.
- X# <manifest> applies to both <old-dir> and <new-dir>.
- X#
- X# makepatch -filelist [ -prefix xxx ] manifest
- X#
- X# The filenames are extracted from the manifest file,
- X# optionally prefixed, sorted and written to standard output.
- X#
- X# Examples:
- X#
- X# % makepatch -verbose emacs-18.58 emacs-18.59 > emacs-18.58-18.59.diff
- X#
- X# % (cd emacs-18.58; find . -type f -print > MANIFEST)
- X# % (cd emacs-18.59; find . -type f -print > MANIFEST)
- X# % makepatch -verbose \
- X# -oldmanifest emacs-18.58/MANIFEST \
- X# -newmanifest emacs-18.59/MANIFEST \
- X# emacs-18.58 emacs-18.59 > emacs-18.58-18.59.diff
- X#
- X# % makepatch -filelist -prefix emacs-18.59/ emacs-18.59/MANIFEST |
- X# gtar -zcvf emacs-18.59.tar.Z -T -
- X#
- X################################################################
- X
- X&stdio;
- X&options;
- X($old, $new) = @ARGV;
- X
- Xprint STDERR ("This is makepatch.pl version 1.6\n") if $opt_verbose;
- X
- Xif ( defined $opt_filelist ) {
- X @new = &domanifest (shift (@ARGV));
- X foreach ( @new ) {
- X print STDOUT ($opt_prefix, $_, "\n");
- X }
- X exit (0);
- X}
- X
- X$tmpfile = $ENV{"TMPDIR"} || "/usr/tmp";
- X$thepatch = "$tmpfile/mp$$.p";
- X$tmpfile .= "/mp$$.t";
- Xopen (PATCH, ">$thepatch") || die ("$thepatch: $!\n");
- X$patched = $created = 0;
- X&doit ($old, $new);
- X&wrapup;
- Xexit (0);
- X
- X################ Subroutines ################
- X
- Xsub doit {
- X local ($old, $new) = @_;
- X
- X if ( -f $old && -f $new ) {
- X # Two files.
- X if ( $opt_verbose ) {
- X print STDERR ("Old file = $old.\n",
- X "New file = $new.\n");
- X }
- X &dodiff ("", $old, "", $new);
- X }
- X elsif ( -f $old && -d $new ) {
- X # File and dir -> File and dir/File.
- X $new = ( $new =~ m|^\./?$| ) ? "" : "$new/";
- X if ( $opt_verbose ) {
- X print STDERR ("Old file = $old.\n",
- X "New file = $new$old.\n");
- X }
- X &dodiff ("", $old, $new, $old);
- X }
- X elsif ( -f $new && -d $old ) {
- X $old = ( $old =~ m|^\./?$| ) ? "" : "$old/";
- X if ( $opt_verbose ) {
- X print STDERR ("Old file = $old$new.\n",
- X "New file = $new.\n");
- X }
- X &dodiff ($old, $new, "", $new);
- X }
- X else {
- X # Should be two directories.
- X local (@old, @new);
- X if ( defined $opt_oldmanifest ) {
- X @old = &domanifest ($opt_oldmanifest);
- X }
- X else {
- X @old = &make_filelist ($old);
- X }
- X if ( defined $opt_newmanifest ) {
- X @new = &domanifest ($opt_newmanifest);
- X }
- X else {
- X @new = &make_filelist ($new);
- X }
- X
- X $new = ( $new =~ m|^\./?$| ) ? "" : "$new/";
- X $old = ( $old =~ m|^\./?$| ) ? "" : "$old/";
- X
- X if ( $opt_verbose ) {
- X local ($old) = $old; chop ($old);
- X local ($new) = $new; chop ($new);
- X print STDERR ("Old dir = $old, file list = ",
- X defined $opt_oldmanifest ? $opt_oldmanifest : "<*>",
- X ", ", 0+@old, " files.\n");
- X print STDERR ("New dir = $new, file list = ",
- X defined $opt_newmanifest ? $opt_newmanifest : "<*>",
- X ", ", 0+@new, " files.\n");
- X }
- X if ( $opt_debug ) {
- X print STDERR ("Old: @old\nNew: @new\n");
- X }
- X
- X # Handle patchlevel file first.
- X $opt_patchlevel = (grep (/patchlevel\.h/, @new))[0]
- X unless defined $opt_patchlevel;
- X
- X if ( defined $opt_patchlevel && $opt_patchlevel ne "" ) {
- X if ( ! -f "$new$opt_patchlevel" ) {
- X die ("$new$opt_patchlevel: $!\n");
- X }
- X if ( -f "$old$opt_patchlevel" ) {
- X &dodiff ($old, $opt_patchlevel, $new, $opt_patchlevel);
- X }
- X else {
- X $created++;
- X &dodiff ("", "/dev/null", $new, $opt_patchlevel);
- X }
- X }
- X else {
- X undef $opt_patchlevel;
- X }
- X
- X # Process the filelists.
- X while ( @old + @new ) {
- X
- X $o = shift (@old) unless defined $o;
- X $n = shift (@new) unless defined $n;
- X
- X if ( !defined $o || $o gt $n ) {
- X # New file.
- X if ( defined $opt_patchlevel && $n eq $opt_patchlevel ) {
- X undef $opt_patchlevel;
- X }
- X else {
- X $created++;
- X &dodiff ("", "/dev/null", $new, $n);
- X }
- X undef $n;
- X }
- X elsif ( !defined $n || $o lt $n ) {
- X # Obsolete (removed) file.
- X push (@goners, $o);
- X undef $o;
- X }
- X elsif ( $o eq $n ) {
- X # Same file.
- X if ( defined $opt_patchlevel && $n eq $opt_patchlevel ) {
- X undef $opt_patchlevel;
- X }
- X else {
- X &dodiff ($old, $o, $new, $n);
- X }
- X undef $n;
- X undef $o;
- X }
- X }
- X }
- X}
- X
- Xsub make_filelist {
- X local ($dir, $disp) = @_;
- X
- X # Return a list of files, sorted, for this directory.
- X # Recurses.
- X
- X local (@ret);
- X local (*DIR);
- X local (@tmp);
- X local ($fname);
- X
- X $disp = "" unless defined $disp;
- X
- X print STDERR ("+ recurse $dir\n") if $opt_trace;
- X opendir (DIR, $dir) || die ("$dir: $!\n");
- X @tmp = sort (readdir (DIR));
- X closedir (DIR);
- X print STDERR ("Dir $dir: ", 0+@tmp, " entries\n") if $opt_debug;
- X
- X @ret = ();
- X foreach $file ( @tmp ) {
- X
- X # Skip unwanted files.
- X next if $file =~ /^\.\.?$/; # dot and dotdot
- X next if $file =~ /~$/; # editor backup files
- X
- X # Push on the list.
- X $fname = "$dir/$file";
- X if ( -d $fname ) {
- X # Recurse.
- X push (@ret, &make_filelist ($fname, "$disp$file/"));
- X }
- X elsif ( -f _ ) {
- X push (@ret, $disp . $file);
- X }
- X else {
- X print STDERR ("Ignored $fname: not a file\n");
- X }
- X }
- X @ret;
- X}
- X
- Xsub domanifest {
- X local ($man) = @_;
- X local (*MAN);
- X local (@ret) = ();
- X
- X open (MAN, $man) || die ("$man: $!\n");
- X while ( <MAN> ) {
- X if ( $. == 2 && /^[-=_\s]*$/ ) {
- X @ret = ();
- X next;
- X }
- X next if /^#/;
- X next unless /\S/;
- X $_ = $` if /\s/;
- X push (@ret, $_);
- X }
- X close (MAN);
- X @ret = sort @ret unless defined $opt_nosort;
- X @ret;
- X}
- X
- Xsub dodiff {
- X local ($olddir, $old, $newdir, $new) = @_;
- X
- X # Produce a patch hunk.
- X
- X local ($cmd) = "$opt_diff '$olddir$old' '$newdir$new'";
- X print STDERR ("+ ", $cmd, "\n") if $opt_trace;
- X $result = system ("$cmd > $tmpfile");
- X printf STDERR ("+> result = 0x%x\n", $result)
- X if $result && $opt_debug;
- X
- X return unless $result == 0x100; # no diffs
- X $patched++;
- X
- X # print PATCH ($cmd, "\n");
- X print PATCH ("Index: ", $new, "\n");
- X
- X # Try to find a prereq.
- X open (OLD, $olddir . $old);
- X while ( <OLD> ) {
- X next unless /\@\(\#\)/; # SCCS header
- X next unless $' =~ /\b\d+(\.\d+)*\b/; # e.g. 5.4
- X print PATCH ("Prereq: $&\n");
- X last;
- X }
- X close (OLD);
- X
- X # Copy patch.
- X open (TMP, $tmpfile);
- X print PATCH <TMP>;
- X close (TMP);
- X}
- X
- Xsub wrapup {
- X if ( $opt_verbose ) {
- X local ($goners) = scalar (@goners);
- X print STDERR ("Collecting: $patched patch",
- X $patched == 1 ? "" : "es");
- X print STDERR (" ($created new file",
- X $created == 1 ? "" : "s", ")") if $created;
- X print STDERR (", $goners goner",
- X $goners == 1 ? "" : "s") if $goners;
- X print STDERR (".\n");
- X }
- X if ( @goners ) {
- X print STDOUT
- X ("# Please remove the following file",
- X @goners == 1 ? "" : "s", " before applying this patch.\n",
- X "# (You can feed this patch to 'sh' to do so.)\n",
- X "\n");
- X foreach ( @goners ) {
- X print STDOUT ("rm -f ", $_, "\n");
- X }
- X print STDOUT ("exit\n\n");
- X }
- X
- X # Copy patch.
- X open (PATCH, $thepatch);
- X print while <PATCH>;
- X close (PATCH);
- X
- X # Cleanup.
- X unlink ($tmpfile, $thepatch);
- X}
- X
- Xsub stdio {
- X # Since output to STDERR seems to be character based (and slow),
- X # we connect STDERR to STDOUT if they both point to the terminal.
- X if ( -t STDOUT && -t STDERR ) {
- X close (STDERR);
- X open (STDERR, '>&STDOUT');
- X select (STDERR); $| = 1;
- X select (STDOUT);
- X }
- X}
- X
- Xsub options {
- X local ($opt_manifest);
- X local ($opt_quiet);
- X
- X # Defaults...
- X $opt_diff = "diff -c";
- X $opt_verbose = 1;
- X
- X # Process options, if any...
- X if ( $ARGV[0] =~ /^-/ ) {
- X require "newgetopt.pl";
- X
- X # Aliases.
- X *opt_man = *opt_manifest;
- X *opt_oldman = *opt_oldmanifest;
- X *opt_newman = *opt_newmanifest;
- X *opt_v = *opt_verbose;
- X *opt_list = *opt_filelist;
- X
- X if ( ! &NGetOpt ("patchlevel=s", "diff=s",
- X "manifest=s", "newmanifest=s", "oldmanifest=s",
- X "man=s", "newman=s", "oldman=s",
- X "list", "filelist", "prefix=s", "nosort",
- X "quiet", "verbose", "v", "help", "debug", "trace")
- X || defined $opt_help ) {
- X &usage;
- X }
- X $opt_trace = 1 if defined $opt_debug;
- X $opt_verbose = 0 if defined $opt_quiet;
- X if ( defined $opt_prefix ) {
- X die ("$0: option \"-prefix\" requires \"-filelist\"\n")
- X unless defined $opt_filelist;
- X }
- X if ( defined $opt_nosort ) {
- X die ("$0: option \"-nosort\" requires \"-filelist\"\n")
- X unless defined $opt_filelist;
- X }
- X if ( defined $opt_filelist ) {
- X die ("$0: option \"-filelist\" only uses \"-manifest\"\n")
- X if defined $opt_oldmanifest || defined $opt_newmanifest;
- X }
- X if ( defined $opt_manifest ) {
- X die ("$0: do not use \"-manifest\" with \"-oldmanifest\"".
- X " or \"-newmanifest\"\n")
- X if defined $opt_newmanifest || defined $opt_oldmanifest;
- X $opt_newmanifest = $opt_oldmanifest = $opt_manifest;
- X }
- X }
- X
- X # Argument check.
- X if ( defined $opt_filelist ) {
- X if ( defined $opt_manifest ) {
- X &usage if @ARGV;
- X @ARGV = ( $opt_manifest );
- X }
- X else {
- X &usage unless @ARGV == 1;
- X }
- X }
- X else {
- X &usage unless @ARGV == 2;
- X }
- X}
- X
- Xsub usage {
- X print STDERR <<EoU;
- XThis is makepatch.pl version 1.6
- X
- XUsage: $0 [options] old new
- XUsage: $0 -filelist [ -prefix XXX ] [ -nosort ] [ -manifest ] file
- X
- XMakepatch options:
- X -diff cmd diff command to use, default \"$opt_diff\"
- X -patchlevel file file to use as patchlevel.h
- X -man[ifest] file list of files for old and new dir
- X -newman[ifest] file list of files for new dir
- X -oldman[ifest] file list of files for old dir
- XFilelist options:
- X -[file]list extract filenames from manifest file
- X -prefix XXX add a prefix to these filenames
- X -nosort do not sort manifest entries
- XGeneral options:
- X -verbose verbose output (default)
- X -quiet no verbose output
- X -help this message
- XEoU
- X exit (1);
- X}
- END_OF_FILE
- if test 11375 -ne `wc -c <'makepatch.pl'`; then
- echo shar: \"'makepatch.pl'\" unpacked with wrong size!
- fi
- # end of 'makepatch.pl'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-