gnucash/make-gnucash-patch.in

156 lines
3.4 KiB
Plaintext
Raw Normal View History

#!@-PERL-@ -w
2000-12-19 01:59:44 -06:00
# -*- perl -*-
#
# This perl script is used to make a patch for your GnuCash
# development work. All patches should be submitted to the
# mailing list gnucash-patches@gnucash.org. For more info
# consult the README.
#
# This script requires the programs 'makepatch', 'gzip',
# 'diff', and 'uuencode'.
#
# Author: Dave Peticolas <dave@krondo.com>
use strict;
2000-12-19 01:59:44 -06:00
use File::Basename;
###########################################################
# 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-12-19 01:59:44 -06:00
chomp(my $cwd = `pwd`);
2000-12-19 01:59:44 -06:00
my ($new, $gnc_home) = fileparse($cwd);
###########################################################
# This section should not need to be modified. #
###########################################################
# 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'};
}
2000-12-19 01:59:44 -06:00
# Switch to the home directory
2000-12-19 01:59:44 -06:00
print "Changing directory to $gnc_home\n";
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") {
mkdir "tmp";
}
chdir "tmp";
system("cvs -d `cat ../$new/CVS/Root` co gnucash");
chdir "..";
$old = "tmp/gnucash";
}
2000-12-19 01:59:44 -06:00
chdir $gnc_home . "/" . $new or die "Can't cd!\n";
# Start out with our basic makepatch arguments
2000-12-19 01:59:44 -06:00
my @args = ('-verbose', '-diff', 'diff -u', '-exclude-vc');
# Add in the exclude patterns from the __DATA__ section
2000-12-19 01:59:44 -06:00
push_exclusions(\@args);
sub push_exclusions {
my $args = shift;
foreach my $pat (<DATA>) {
chomp($pat);
push(@{$args}, '-exclude', $pat) if $pat;
}
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);
}
}
# 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") {
mkdir "diffs";
}
my $date = `date '+%s'`;
chomp($date);
my $who = `whoami`;
chomp($who);
my $outfilename = "gnucash-$date-$who.diff";
# 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";
system('makepatch', @args);
close(STDOUT);
open(STDOUT, ">&OLDOUT");
2000-12-19 01:59:44 -06:00
print "makepatch done\n";
# Compress the patch
2000-12-19 01:59:44 -06:00
if (-f "diffs/$outfilename") {
system("gzip", "-9vf", "diffs/$outfilename");
}
# UU encode the compressed patch
# 'gnucash.diff.gz.uue' is the file you send.
2000-12-19 01:59:44 -06:00
if (-f "diffs/$outfilename.gz") {
system("uuencode diffs/$outfilename.gz $outfilename.gz > diffs/$outfilename.gz.uue");
}
print "diffs/$outfilename.gz.uue\n";
exit(0);
__DATA__
#*#
*.a
*.bak
*.bin
*.diff
*.diffs
*.gmo
*.lo
*.log
*.mo
*.moc
*.o
*.orig
*.patch
*.rej
*.tar.gz
*.wrap
*.xac.*.xac
2000-12-19 01:59:44 -06:00
*~
.#*