blob: ac5118c2d06bb5002df8e15768d4cfe560e5ea89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#!@PREFIX@/bin/perl
#
# $NetBSD: mkpatches.pl,v 1.1.1.1 2000/06/28 01:42:42 wiz Exp $
#
# mkpatches: creates a set of patches patch-aa, patch-ab, ...
# in work/.newpatches by looking for *.orig files in and below
# WRKSRC and comparing them to the corresponding changed file. It
# should be called from the packages directory,
# e.g. /usr/pkgsrc/example/test
#
# Copyright (c) 2000 by Thomas Klausner <wiz@netbsd.org>
# All Rights Reserved. Absolutely no warranty.
#
use Getopt::Std;
use Cwd;
my $patchdir;
my $wrkdir;
my $l=0;
# change to WRKSRC
sub goto_wrksrcdir {
my $wrksrc;
$wrksrc=`make show-var VARNAME=WRKSRC` or
die ("can't find WRKSRC -- wrong dir?");
chomp($wrksrc);
chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)");
}
# 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:h');
if ($opt_h) {
($prog) = ($0 =~ /([^\/]+)$/);
print STDERR <<EOF;
usage: $prog [-d output-directory]
-d dirname directory to put the resulting patches into;
defaults to \$WRKDIR/.newpatches
EOF
exit 0;
};
# get WRKDIR
$wrkdir=`make show-var VARNAME=WRKDIR` or
die ("can't find WRKDIR -- wrong dir?");
chomp($wrkdir);
if ($opt_d) {
$patchdir = cwd()."/$opt_d";
}
else {
$patchdir="$wrkdir"."/.newpatches";
}
goto_wrksrcdir();
create_patchdir();
# find files
open(handle, "find . -type f -name \\\*.orig |");
# create patches
while(<handle>) {
my $path, $complete;
chomp();
$path = $_;
$path =~ s/^..//;
$complete = $path;
$complete =~ s/.orig$//;
if ( -f $complete ) {
$patchfile = ("aa".."zz")[$l];
$patchfile =~ s/^/patch-/;
system("pkgdiff $path $complete > $patchdir/$patchfile");
} else {
print ("$complete doesn't exist, though $path does");
}
$l++;
}
|