#!@PREFIX@/bin/perl # # $NetBSD: mkpatches.pl,v 1.7 2002/07/21 16:34:10 wiz Exp $ # # mkpatches: creates a set of patches patch-aa, patch-ab, ... # in work/.newpatches by looking for *.orig files in and below # WRKDIR and comparing them to the corresponding changed file. All # files are then referrenced relative to WRKSRC. # # It should be called from the packages directory, # e.g. /usr/pkgsrc/example/test # # Copyright (c) 2000 by Thomas Klausner # All Rights Reserved. Absolutely no warranty. # use Getopt::Std; use Cwd; use File::Spec; my $patchdir; my $wrkdir; my $l=0; # create patchdir, or empty it if already existing sub create_patchdir { if ( -d $patchdir ) { unlink "$patchdir/*"; } else { mkdir($patchdir, 0755); } } # read command line arguments getopts('d:hv'); if ($opt_h) { ($prog) = ($0 =~ /([^\/]+)$/); print STDERR <) { my $path, $complete; my $new, $old; chomp(); $path = $_; $complete = $path; $complete =~ s/.orig$//; $new = File::Spec->abs2rel( $complete, $wrksrc ); $old = File::Spec->abs2rel( $path, $wrksrc ); if ( -f $complete ) { $patchfile = ("aa".."zz")[$l]; $patchfile =~ s/^/patch-/; if ($opt_v) { print "$patchfile -> $complete\n"; } $diff=`pkgdiff $old $new`; if ( $? ) { print "$old\n$diff\n"; exit 1; } if ( "$diff" eq "" ) { print ("$new and $old don't differ\n"); } else { system("pkgdiff $old $new > $patchdir/$patchfile"); } } else { print ("$new doesn't exist, though $old does\n"); } $l++; }