2000-05-08 18:59:45 -05:00
|
|
|
#!@-PERL-@ -w
|
2000-12-19 01:59:44 -06:00
|
|
|
# -*- perl -*-
|
2000-01-09 21:33:23 -06:00
|
|
|
#
|
|
|
|
# This perl script is used to make a patch for your GnuCash
|
|
|
|
# development work. All patches should be submitted to the
|
2005-12-27 13:14:07 -06:00
|
|
|
# mailing list gnucash-devel@gnucash.org. For more info
|
|
|
|
# consult README.patches
|
2000-01-09 21:33:23 -06:00
|
|
|
#
|
2004-06-24 17:11:26 -05:00
|
|
|
# WARNING: By default, this script will checkout an entire
|
|
|
|
# up to date copy of the source tree in ../tmp/gnucash/.
|
|
|
|
#
|
|
|
|
# In order to prevent patches which reverse recent changes
|
|
|
|
# made in CVS, make sure to "cvs update" in both
|
|
|
|
# directories before running make-gnucash-patch.
|
|
|
|
#
|
2000-01-09 21:33:23 -06:00
|
|
|
# This script requires the programs 'makepatch', 'gzip',
|
2004-01-02 20:58:33 -06:00
|
|
|
# a 'diff' work-a-like, and 'uuencode'.
|
2000-01-09 21:33:23 -06:00
|
|
|
#
|
2000-08-31 02:16:55 -05:00
|
|
|
# Author: Dave Peticolas <dave@krondo.com>
|
2000-01-09 21:33:23 -06:00
|
|
|
|
2000-05-08 18:59:45 -05:00
|
|
|
use strict;
|
2000-01-09 21:33:23 -06:00
|
|
|
|
2000-12-19 01:59:44 -06:00
|
|
|
use File::Basename;
|
2001-01-16 03:14:55 -06:00
|
|
|
use Getopt::Long;
|
2000-12-19 01:59:44 -06:00
|
|
|
|
2000-12-27 17:37:52 -06:00
|
|
|
$::ask_description = 1;
|
|
|
|
$::should_uuencode = 1;
|
2004-01-02 20:58:33 -06:00
|
|
|
$::diffcmd = "diff -up";
|
2000-12-27 17:37:52 -06:00
|
|
|
|
2005-12-27 13:14:07 -06:00
|
|
|
die "This utility has not been updated to use SVN. Sorry, just use diff(1).";
|
|
|
|
|
2000-12-27 17:37:52 -06:00
|
|
|
my $rcfile = $ENV{"HOME"} . "/.gnucash-patch.rc";
|
|
|
|
|
|
|
|
if (-f $rcfile) {
|
|
|
|
require $rcfile;
|
|
|
|
}
|
|
|
|
|
2000-01-09 21:33:23 -06:00
|
|
|
###########################################################
|
|
|
|
# This section must be configured for your own setup. #
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# The directory with the original gnucash sources
|
2000-12-19 01:59:44 -06:00
|
|
|
my $old = undef;
|
2000-01-09 21:33:23 -06:00
|
|
|
|
2000-12-19 01:59:44 -06:00
|
|
|
chomp(my $cwd = `pwd`);
|
2000-01-09 21:33:23 -06:00
|
|
|
|
2000-12-19 01:59:44 -06:00
|
|
|
my ($new, $gnc_home) = fileparse($cwd);
|
2000-01-09 21:33:23 -06:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# This section should not need to be modified. #
|
|
|
|
###########################################################
|
|
|
|
|
2000-03-05 18:17:25 -06:00
|
|
|
# Allow the user to override the defaults with evnt vars.
|
|
|
|
|
|
|
|
if($ENV{'GNC_MAKEPATCH_OLD_DIR'}) {
|
|
|
|
$old = $ENV{'GNC_MAKEPATCH_OLD_DIR'};
|
|
|
|
}
|
|
|
|
|
|
|
|
if($ENV{'GNC_MAKEPATCH_NEW_DIR'}) {
|
|
|
|
$new = $ENV{'GNC_MAKEPATCH_NEW_DIR'};
|
|
|
|
}
|
|
|
|
|
|
|
|
if($ENV{'GNC_MAKEPATCH_HOME_DIR'}) {
|
|
|
|
$gnc_home = $ENV{'GNC_MAKEPATCH_HOME_DIR'};
|
|
|
|
}
|
|
|
|
|
2001-02-28 02:06:50 -06:00
|
|
|
###########################################################
|
|
|
|
# Make sure makepatch exists before going on #
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
open(OLDOUT, ">&STDOUT");
|
|
|
|
open(OLDERR, ">&STDERR");
|
|
|
|
open(STDOUT, "> /dev/null") || die "Can't redirect stdout";
|
|
|
|
open(STDERR, "> /dev/null") || die "Can't redirect stderr";
|
|
|
|
my $test = system('makepatch', "-help");
|
|
|
|
close(STDOUT);
|
|
|
|
close(STDERR);
|
|
|
|
open(STDOUT, ">&OLDOUT");
|
|
|
|
open(STDERR, ">&OLDERR");
|
|
|
|
close(OLDOUT);
|
|
|
|
close(OLDERR);
|
|
|
|
|
|
|
|
if($test == -1) {
|
|
|
|
print "No makepatch installed. Exiting\n";
|
|
|
|
exit(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-16 03:14:55 -06:00
|
|
|
###########################################################
|
|
|
|
# Now, check if anything specified on command line #
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
my $result;
|
|
|
|
my $help;
|
|
|
|
my $zip = 1; # defaults to on
|
|
|
|
my $diffname = undef;
|
|
|
|
my $ignorename = undef;
|
2001-05-03 18:50:42 -05:00
|
|
|
my @filename = ();
|
|
|
|
my $manifest = undef;
|
2001-01-16 03:14:55 -06:00
|
|
|
|
|
|
|
$result = GetOptions("old=s" => \$old, "new=s" => \$new,
|
|
|
|
"prefix=s" => \$gnc_home, "help" => \$help,
|
2001-05-03 18:50:42 -05:00
|
|
|
"file=s" => \@filename, "ask!" => \$::ask_description,
|
2001-01-16 03:14:55 -06:00
|
|
|
"diff=s" => \$diffname, "uuencode!" => \$::should_uuencode,
|
2004-01-02 20:58:33 -06:00
|
|
|
"diffcmd!" => \$::diffcmd, "zip!" => \$zip,
|
|
|
|
"ignore=s" => \$ignorename, "manifest=s" => \$manifest);
|
2001-01-16 03:14:55 -06:00
|
|
|
|
|
|
|
if ($help or $result == 0) {
|
|
|
|
printf "Help information\n\n";
|
|
|
|
printf "make-gnucash-patch accepts the following arguments:\n";
|
|
|
|
printf "--old \"olddir\" Directory of \"pristine\" copy\n";
|
|
|
|
printf "--new \"newdir\" Directory with modified copy\n";
|
|
|
|
printf "--prefex \"homedir\" Full path of parent directory\n";
|
|
|
|
printf "--diff \"diffname\" Output name for diff file\n";
|
2004-01-02 20:58:33 -06:00
|
|
|
printf "--diffcmd \"cmd\" Command to compare two files\n";
|
2001-05-01 15:58:00 -05:00
|
|
|
printf "--file \"filename\" Make patch for filename ONLY\n";
|
2001-05-03 18:50:42 -05:00
|
|
|
printf "--manifest \"file\" Use file as a manifest file\n";
|
2001-01-16 03:14:55 -06:00
|
|
|
printf "--ignore \"igname\" File containing file matches to ignore\n";
|
|
|
|
printf "--(no)uuencode Enable or disable uuencoded output\n";
|
|
|
|
printf " (Defaults to enabled)\n";
|
|
|
|
printf "--(no)zip Enable or disable gzipped output\n";
|
|
|
|
printf " (Defaults to enabled)\n";
|
2001-05-01 15:58:00 -05:00
|
|
|
printf "--(no)ask Enable or disable prompting for description\n";
|
|
|
|
printf " (Defaults to enabled)\n";
|
2001-01-16 03:14:55 -06:00
|
|
|
printf "and of course:\n";
|
|
|
|
printf "--help Displays this text\n";
|
|
|
|
printf "\nAll options can be abbreviated to their shortest unique\n";
|
2004-01-02 20:58:33 -06:00
|
|
|
printf " form: --o, --ne, --p, --d, --diffc, --f, --m, --i,\n";
|
|
|
|
printf " --u/--nou, --z/--noz, --a/--noa, and --h\n";
|
2001-01-16 03:14:55 -06:00
|
|
|
printf "\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
2000-12-19 01:59:44 -06:00
|
|
|
|
2001-05-01 15:58:00 -05:00
|
|
|
# if explicit filename given, build required MANIFEST file
|
|
|
|
|
2001-05-03 18:50:42 -05:00
|
|
|
@filename = split(/,/,join(',',@filename));
|
|
|
|
|
|
|
|
if (@filename) {
|
2001-05-01 15:58:00 -05:00
|
|
|
open (FN, ">$gnc_home/tmp.MANIFEST") or die "Couldn't create MANIFEST file";
|
|
|
|
printf (FN "# Temporary manifest file for make-gnucash-patch -f option\n");
|
|
|
|
printf (FN "\n");
|
2001-05-03 18:50:42 -05:00
|
|
|
foreach my $part (@filename) {
|
|
|
|
printf (FN "%s\n", $part);
|
|
|
|
}
|
2001-05-01 15:58:00 -05:00
|
|
|
close (FN);
|
|
|
|
}
|
|
|
|
|
2000-01-09 21:33:23 -06:00
|
|
|
# Switch to the home directory
|
2000-12-19 01:59:44 -06:00
|
|
|
print "Changing directory to $gnc_home\n";
|
2000-01-09 21:33:23 -06:00
|
|
|
chdir $gnc_home or die "Can't cd!\n";
|
|
|
|
|
2000-12-19 01:59:44 -06:00
|
|
|
if (not defined($old)) {
|
|
|
|
if (not -f "$new/CVS/Root") {
|
|
|
|
print "Source not checked out of CVS and no \$old set. Quitting...\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (not -d "tmp") {
|
2001-01-11 16:32:22 -06:00
|
|
|
mkdir "tmp", 0755;
|
2000-12-19 01:59:44 -06:00
|
|
|
}
|
|
|
|
chdir "tmp";
|
|
|
|
system("cvs -d `cat ../$new/CVS/Root` co gnucash");
|
|
|
|
chdir "..";
|
|
|
|
$old = "tmp/gnucash";
|
|
|
|
}
|
2000-01-09 21:33:23 -06:00
|
|
|
|
2000-12-19 01:59:44 -06:00
|
|
|
chdir $gnc_home . "/" . $new or die "Can't cd!\n";
|
2000-01-09 21:33:23 -06:00
|
|
|
# Start out with our basic makepatch arguments
|
2004-01-02 20:58:33 -06:00
|
|
|
my @args = ('-verbose', '-exclude-vc');
|
|
|
|
|
|
|
|
# Push the diff command value
|
|
|
|
push(@args, '-diff', "$::diffcmd");
|
2000-01-09 21:33:23 -06:00
|
|
|
|
2000-12-27 17:37:52 -06:00
|
|
|
if (not $::ask_description) {
|
|
|
|
push(@args, '-description', '');
|
|
|
|
}
|
2001-05-01 15:58:00 -05:00
|
|
|
|
|
|
|
# If -f options given, use generated manifest file
|
|
|
|
# otherwise, add exclusions and proceed as normal
|
2001-05-03 18:50:42 -05:00
|
|
|
if (@filename) {
|
2001-05-01 15:58:00 -05:00
|
|
|
push(@args, '-manifest', "$gnc_home/tmp.MANIFEST");
|
|
|
|
}
|
2001-05-03 18:50:42 -05:00
|
|
|
elsif (defined($manifest)) {
|
2002-04-08 02:09:47 -05:00
|
|
|
if (not $manifest =~ m#/#) {
|
|
|
|
$manifest = "$cwd/$manifest";
|
|
|
|
}
|
2001-05-03 18:50:42 -05:00
|
|
|
push(@args, '-manifest', "$manifest");
|
|
|
|
}
|
2001-05-01 15:58:00 -05:00
|
|
|
else {
|
|
|
|
# Add in the exclude patterns from the __DATA__ section
|
|
|
|
push_exclusions(\@args);
|
|
|
|
}
|
2000-12-19 01:59:44 -06:00
|
|
|
|
|
|
|
sub push_exclusions {
|
|
|
|
my $args = shift;
|
|
|
|
foreach my $pat (<DATA>) {
|
|
|
|
chomp($pat);
|
|
|
|
push(@{$args}, '-exclude', $pat) if $pat;
|
|
|
|
}
|
2001-01-16 03:14:55 -06:00
|
|
|
if (defined ($ignorename)) {
|
|
|
|
$ignorename = "../" . $ignorename;
|
|
|
|
if (-e $ignorename) {
|
|
|
|
open (IG, $ignorename) or die "Couldn't open $ignorename";
|
|
|
|
foreach my $igf (<IG>) {
|
|
|
|
chomp ($igf);
|
|
|
|
push(@{$args}, '-exclude', $igf) if $igf;
|
|
|
|
}
|
|
|
|
close (IG);
|
|
|
|
}
|
|
|
|
}
|
2000-12-19 01:59:44 -06:00
|
|
|
my @cvsignores = `find . -name '.cvsignore'`;
|
|
|
|
foreach my $one_ignore (@cvsignores) {
|
|
|
|
my ($name, $path) = fileparse($one_ignore);
|
|
|
|
open (IG, $one_ignore);
|
|
|
|
foreach my $fl (<IG>) {
|
|
|
|
chomp $fl;
|
|
|
|
$path =~ s/^\.\///;
|
|
|
|
push(@{$args}, '-exclude', $path . $fl) if $fl;
|
|
|
|
}
|
|
|
|
close (IG);
|
|
|
|
}
|
2000-01-09 21:33:23 -06:00
|
|
|
}
|
|
|
|
# Add the from and to directories for makepatch
|
|
|
|
push(@args, $old, $new);
|
2000-12-19 01:59:44 -06:00
|
|
|
print "Arguments are: " . join("; ", @args) . "\n";
|
|
|
|
|
|
|
|
chdir $gnc_home or die "Can't cd!\n";
|
|
|
|
|
|
|
|
# Erase the old files
|
|
|
|
#unlink('gnc.diff', 'gnucash.diff.gz', 'gnucash.diff.gz.uue');
|
|
|
|
|
|
|
|
if (not -d "diffs") {
|
2001-01-10 18:10:16 -06:00
|
|
|
mkdir "diffs", 0755;
|
2000-12-19 01:59:44 -06:00
|
|
|
}
|
|
|
|
|
2001-01-16 03:14:55 -06:00
|
|
|
my $outfilename;
|
2000-12-19 01:59:44 -06:00
|
|
|
|
2001-01-16 03:14:55 -06:00
|
|
|
if (not defined($diffname)) {
|
2001-01-17 00:55:43 -06:00
|
|
|
my $date = `date '+%Y%m%d-%H%M%S'`;
|
2001-01-16 03:14:55 -06:00
|
|
|
chomp($date);
|
|
|
|
my $who = `whoami`;
|
|
|
|
chomp($who);
|
|
|
|
|
|
|
|
$outfilename = "gnucash-$date-$who.diff";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$outfilename = $diffname;
|
|
|
|
}
|
2000-01-09 21:33:23 -06:00
|
|
|
|
|
|
|
# Invoke makepatch with standard out redirected to 'gnucash.diff'
|
|
|
|
open(OLDOUT, ">&STDOUT");
|
2000-12-19 01:59:44 -06:00
|
|
|
open(STDOUT, "> diffs/$outfilename") || die "Can't redirect stdout";
|
2000-01-09 21:33:23 -06:00
|
|
|
system('makepatch', @args);
|
|
|
|
close(STDOUT);
|
|
|
|
open(STDOUT, ">&OLDOUT");
|
2001-02-28 02:06:50 -06:00
|
|
|
close(OLDOUT);
|
2000-12-19 01:59:44 -06:00
|
|
|
print "makepatch done\n";
|
2000-01-09 21:33:23 -06:00
|
|
|
|
2001-01-16 03:14:55 -06:00
|
|
|
# Compress the patch if required
|
|
|
|
if ($zip) {
|
|
|
|
if (-f "diffs/$outfilename") {
|
|
|
|
system("gzip", "-9vf", "diffs/$outfilename");
|
|
|
|
}
|
2000-12-19 01:59:44 -06:00
|
|
|
}
|
2000-01-09 21:33:23 -06:00
|
|
|
|
2001-01-16 03:14:55 -06:00
|
|
|
# UU encode the patch if required
|
|
|
|
|
|
|
|
# if $zip is true, then
|
2000-01-09 21:33:23 -06:00
|
|
|
# 'gnucash.diff.gz.uue' is the file you send.
|
2001-01-16 03:14:55 -06:00
|
|
|
if ($zip and -f "diffs/$outfilename.gz" and $::should_uuencode) {
|
2000-12-19 01:59:44 -06:00
|
|
|
system("uuencode diffs/$outfilename.gz $outfilename.gz > diffs/$outfilename.gz.uue");
|
2000-12-27 17:37:52 -06:00
|
|
|
print "diffs/$outfilename.gz.uue\n";
|
|
|
|
}
|
|
|
|
else {
|
2001-01-16 03:14:55 -06:00
|
|
|
if (not $zip and -f "diffs/$outfilename" and $::should_uuencode) {
|
|
|
|
system("uuencode diffs/$outfilename $outfilename > diffs/$outfilename.uue");
|
|
|
|
print "diffs/$outfilename.uue\n";
|
|
|
|
}
|
2000-12-19 01:59:44 -06:00
|
|
|
}
|
|
|
|
|
2000-01-09 21:33:23 -06:00
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
__DATA__
|
|
|
|
|
2000-07-17 16:05:18 -05:00
|
|
|
#*#
|
2001-08-07 18:29:04 -05:00
|
|
|
*.P
|
2001-08-16 19:44:01 -05:00
|
|
|
*.pp
|
2000-08-27 04:02:03 -05:00
|
|
|
*.a
|
2000-07-17 16:05:18 -05:00
|
|
|
*.bak
|
2000-01-09 21:33:23 -06:00
|
|
|
*.bin
|
|
|
|
*.diff
|
|
|
|
*.diffs
|
2000-07-17 16:05:18 -05:00
|
|
|
*.gmo
|
2001-08-07 18:29:04 -05:00
|
|
|
*.la
|
|
|
|
*.lai
|
2000-08-27 04:02:03 -05:00
|
|
|
*.lo
|
2001-08-07 18:29:04 -05:00
|
|
|
*.loT
|
2000-07-17 16:05:18 -05:00
|
|
|
*.log
|
|
|
|
*.mo
|
|
|
|
*.moc
|
2000-08-27 04:02:03 -05:00
|
|
|
*.o
|
2000-07-17 16:05:18 -05:00
|
|
|
*.orig
|
2001-02-07 22:08:50 -06:00
|
|
|
*.ignmgp
|
2000-07-17 16:05:18 -05:00
|
|
|
*.patch
|
|
|
|
*.rej
|
|
|
|
*.tar.gz
|
|
|
|
*.wrap
|
2000-01-09 21:33:23 -06:00
|
|
|
*.xac.*.xac
|
2000-12-19 01:59:44 -06:00
|
|
|
*~
|
2000-01-09 21:33:23 -06:00
|
|
|
.#*
|
2002-10-01 15:48:27 -05:00
|
|
|
doc/gnc-prices.1
|
|
|
|
doc/gnucash.1
|