mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Conrad Canterford's make-gnucash-patch patch adding command line args.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3481 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
424a9ed9fd
commit
fc33a481bb
@ -14,6 +14,7 @@
|
||||
use strict;
|
||||
|
||||
use File::Basename;
|
||||
use Getopt::Long;
|
||||
|
||||
$::ask_description = 1;
|
||||
$::should_uuencode = 1;
|
||||
@ -53,6 +54,40 @@ if($ENV{'GNC_MAKEPATCH_HOME_DIR'}) {
|
||||
$gnc_home = $ENV{'GNC_MAKEPATCH_HOME_DIR'};
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Now, check if anything specified on command line #
|
||||
###########################################################
|
||||
|
||||
my $result;
|
||||
my $help;
|
||||
my $zip = 1; # defaults to on
|
||||
my $diffname = undef;
|
||||
my $ignorename = undef;
|
||||
|
||||
$result = GetOptions("old=s" => \$old, "new=s" => \$new,
|
||||
"prefix=s" => \$gnc_home, "help" => \$help,
|
||||
"diff=s" => \$diffname, "uuencode!" => \$::should_uuencode,
|
||||
"zip!" => \$zip, "ignore=s" => \$ignorename);
|
||||
|
||||
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";
|
||||
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";
|
||||
printf "and of course:\n";
|
||||
printf "--help Displays this text\n";
|
||||
printf "\nAll options can be abbreviated to their shortest unique\n";
|
||||
printf " form: --o, --ne, --p, --d, --i, --u/--nou, --z/--noz, and --h\n";
|
||||
printf "\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Switch to the home directory
|
||||
print "Changing directory to $gnc_home\n";
|
||||
@ -88,6 +123,17 @@ sub push_exclusions {
|
||||
chomp($pat);
|
||||
push(@{$args}, '-exclude', $pat) if $pat;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
my @cvsignores = `find . -name '.cvsignore'`;
|
||||
foreach my $one_ignore (@cvsignores) {
|
||||
my ($name, $path) = fileparse($one_ignore);
|
||||
@ -113,12 +159,19 @@ if (not -d "diffs") {
|
||||
mkdir "diffs", 0755;
|
||||
}
|
||||
|
||||
my $date = `date '+%s'`;
|
||||
chomp($date);
|
||||
my $who = `whoami`;
|
||||
chomp($who);
|
||||
my $outfilename;
|
||||
|
||||
my $outfilename = "gnucash-$date-$who.diff";
|
||||
if (not defined($diffname)) {
|
||||
my $date = `date '+%s'`;
|
||||
chomp($date);
|
||||
my $who = `whoami`;
|
||||
chomp($who);
|
||||
|
||||
$outfilename = "gnucash-$date-$who.diff";
|
||||
}
|
||||
else {
|
||||
$outfilename = $diffname;
|
||||
}
|
||||
|
||||
# Invoke makepatch with standard out redirected to 'gnucash.diff'
|
||||
open(OLDOUT, ">&STDOUT");
|
||||
@ -128,19 +181,26 @@ close(STDOUT);
|
||||
open(STDOUT, ">&OLDOUT");
|
||||
print "makepatch done\n";
|
||||
|
||||
# Compress the patch
|
||||
if (-f "diffs/$outfilename") {
|
||||
system("gzip", "-9vf", "diffs/$outfilename");
|
||||
# Compress the patch if required
|
||||
if ($zip) {
|
||||
if (-f "diffs/$outfilename") {
|
||||
system("gzip", "-9vf", "diffs/$outfilename");
|
||||
}
|
||||
}
|
||||
|
||||
# UU encode the compressed patch
|
||||
# UU encode the patch if required
|
||||
|
||||
# if $zip is true, then
|
||||
# 'gnucash.diff.gz.uue' is the file you send.
|
||||
if (-f "diffs/$outfilename.gz" and $::should_uuencode) {
|
||||
if ($zip and -f "diffs/$outfilename.gz" and $::should_uuencode) {
|
||||
system("uuencode diffs/$outfilename.gz $outfilename.gz > diffs/$outfilename.gz.uue");
|
||||
print "diffs/$outfilename.gz.uue\n";
|
||||
}
|
||||
else {
|
||||
print "diffs/$outfilename.gz\n";
|
||||
if (not $zip and -f "diffs/$outfilename" and $::should_uuencode) {
|
||||
system("uuencode diffs/$outfilename $outfilename > diffs/$outfilename.uue");
|
||||
print "diffs/$outfilename.uue\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user