~siretart/gnucash/ubuntu-fullsource

« back to all changes in this revision

Viewing changes to make-gnucash-patch.in

  • Committer: Reinhard Tartler
  • Date: 2008-08-03 07:25:46 UTC
  • Revision ID: siretart@tauware.de-20080803072546-y6p8xda8zpfi62ys
import gnucash_2.2.4.orig.tar.gz

The original tarball had the md5sum: 27e660297dc5b8ce574515779d05a5a5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!@-PERL-@ -w
 
2
# -*- perl -*-
 
3
#
 
4
# This perl script is used to make a patch for your GnuCash
 
5
# development work. All patches should be submitted to the
 
6
# mailing list gnucash-devel@gnucash.org. For more info
 
7
# consult README.patches
 
8
#
 
9
# WARNING: By default, this script will checkout an entire
 
10
# up to date copy of the source tree in ../tmp/gnucash/.
 
11
#
 
12
# In order to prevent patches which reverse recent changes
 
13
# made in CVS, make sure to "cvs update" in both
 
14
# directories before running make-gnucash-patch.
 
15
#
 
16
# This script requires the programs 'makepatch', 'gzip',
 
17
# a 'diff' work-a-like, and 'uuencode'.
 
18
#
 
19
# Author: Dave Peticolas <dave@krondo.com>
 
20
 
 
21
use strict;
 
22
 
 
23
use File::Basename;
 
24
use Getopt::Long;
 
25
 
 
26
$::ask_description = 1;
 
27
$::should_uuencode = 1;
 
28
$::diffcmd = "diff -up";
 
29
 
 
30
die "This utility has not been updated to use SVN.  Sorry, just use diff(1).";
 
31
 
 
32
my $rcfile = $ENV{"HOME"} . "/.gnucash-patch.rc";
 
33
 
 
34
if (-f $rcfile) {
 
35
  require $rcfile;
 
36
}
 
37
 
 
38
###########################################################
 
39
# This section must be configured for your own setup.     #
 
40
###########################################################
 
41
 
 
42
# The directory with the original gnucash sources
 
43
my $old = undef;
 
44
 
 
45
chomp(my $cwd = `pwd`);
 
46
 
 
47
my ($new, $gnc_home) = fileparse($cwd);
 
48
 
 
49
###########################################################
 
50
# This section should not need to be modified.            #
 
51
###########################################################
 
52
 
 
53
# Allow the user to override the defaults with evnt vars.
 
54
 
 
55
if($ENV{'GNC_MAKEPATCH_OLD_DIR'}) {
 
56
  $old = $ENV{'GNC_MAKEPATCH_OLD_DIR'};
 
57
}
 
58
 
 
59
if($ENV{'GNC_MAKEPATCH_NEW_DIR'}) {
 
60
  $new = $ENV{'GNC_MAKEPATCH_NEW_DIR'};
 
61
}
 
62
 
 
63
if($ENV{'GNC_MAKEPATCH_HOME_DIR'}) {
 
64
  $gnc_home = $ENV{'GNC_MAKEPATCH_HOME_DIR'};
 
65
}
 
66
 
 
67
###########################################################
 
68
# Make sure makepatch exists before going on              #
 
69
###########################################################
 
70
 
 
71
open(OLDOUT, ">&STDOUT");
 
72
open(OLDERR, ">&STDERR");
 
73
open(STDOUT, "> /dev/null") || die "Can't redirect stdout";
 
74
open(STDERR, "> /dev/null") || die "Can't redirect stderr";
 
75
my $test = system('makepatch', "-help");
 
76
close(STDOUT);
 
77
close(STDERR);
 
78
open(STDOUT, ">&OLDOUT");
 
79
open(STDERR, ">&OLDERR");
 
80
close(OLDOUT);
 
81
close(OLDERR);
 
82
 
 
83
if($test == -1) {
 
84
  print "No makepatch installed.  Exiting\n";
 
85
  exit(10);
 
86
}
 
87
 
 
88
 
 
89
###########################################################
 
90
# Now, check if anything specified on command line        #
 
91
###########################################################
 
92
 
 
93
my $result;
 
94
my $help;
 
95
my $zip = 1;     # defaults to on
 
96
my $diffname = undef;
 
97
my $ignorename = undef;
 
98
my @filename = ();
 
99
my $manifest = undef;
 
100
 
 
101
$result = GetOptions("old=s" => \$old, "new=s" => \$new, 
 
102
            "prefix=s" => \$gnc_home, "help" => \$help,
 
103
            "file=s" => \@filename, "ask!" => \$::ask_description,
 
104
            "diff=s" => \$diffname, "uuencode!" => \$::should_uuencode,
 
105
            "diffcmd!" => \$::diffcmd, "zip!" => \$zip, 
 
106
            "ignore=s" => \$ignorename, "manifest=s" => \$manifest);
 
107
 
 
108
if ($help or $result == 0) {
 
109
  printf "Help information\n\n";
 
110
  printf "make-gnucash-patch accepts the following arguments:\n";
 
111
  printf "--old \"olddir\"     Directory of \"pristine\" copy\n";
 
112
  printf "--new \"newdir\"     Directory with modified copy\n";
 
113
  printf "--prefex \"homedir\" Full path of parent directory\n";
 
114
  printf "--diff \"diffname\"  Output name for diff file\n";
 
115
  printf "--diffcmd \"cmd\"    Command to compare two files\n";
 
116
  printf "--file \"filename\"  Make patch for filename ONLY\n";
 
117
  printf "--manifest \"file\"  Use file as a manifest file\n";
 
118
  printf "--ignore \"igname\"  File containing file matches to ignore\n";
 
119
  printf "--(no)uuencode     Enable or disable uuencoded output\n";
 
120
  printf "                   (Defaults to enabled)\n";
 
121
  printf "--(no)zip          Enable or disable gzipped output\n";
 
122
  printf "                   (Defaults to enabled)\n";
 
123
  printf "--(no)ask          Enable or disable prompting for description\n";
 
124
  printf "                   (Defaults to enabled)\n";
 
125
  printf "and of course:\n";
 
126
  printf "--help             Displays this text\n";
 
127
  printf "\nAll options can be abbreviated to their shortest unique\n";
 
128
  printf "  form: --o, --ne, --p, --d, --diffc, --f, --m, --i,\n";
 
129
  printf "        --u/--nou, --z/--noz, --a/--noa, and --h\n";
 
130
  printf "\n";
 
131
  exit 1;
 
132
}
 
133
 
 
134
# if explicit filename given, build required MANIFEST file
 
135
 
 
136
@filename = split(/,/,join(',',@filename));
 
137
 
 
138
if (@filename) {
 
139
  open (FN, ">$gnc_home/tmp.MANIFEST") or die "Couldn't create MANIFEST file";
 
140
  printf (FN "# Temporary manifest file for make-gnucash-patch -f option\n");
 
141
  printf (FN "\n");
 
142
  foreach my $part (@filename) {
 
143
    printf (FN "%s\n", $part);
 
144
  }
 
145
  close (FN);
 
146
}
 
147
 
 
148
# Switch to the home directory
 
149
print "Changing directory to $gnc_home\n";
 
150
chdir $gnc_home or die "Can't cd!\n";
 
151
 
 
152
if (not defined($old)) {
 
153
  if (not -f "$new/CVS/Root") {
 
154
    print "Source not checked out of CVS and no \$old set.  Quitting...\n";
 
155
    exit(1);
 
156
  }
 
157
  if (not -d "tmp") {
 
158
    mkdir "tmp", 0755;
 
159
  }
 
160
  chdir "tmp";
 
161
  system("cvs -d `cat ../$new/CVS/Root` co gnucash");
 
162
  chdir "..";
 
163
  $old = "tmp/gnucash";
 
164
}
 
165
 
 
166
chdir $gnc_home . "/" . $new or die "Can't cd!\n";
 
167
# Start out with our basic makepatch arguments
 
168
my @args = ('-verbose', '-exclude-vc');
 
169
 
 
170
# Push the diff command value
 
171
push(@args, '-diff',  "$::diffcmd");
 
172
 
 
173
if (not $::ask_description) {
 
174
  push(@args, '-description', '');
 
175
}
 
176
 
 
177
# If -f options given, use generated manifest file
 
178
# otherwise, add exclusions and proceed as normal
 
179
if (@filename) {
 
180
  push(@args, '-manifest', "$gnc_home/tmp.MANIFEST");
 
181
}
 
182
elsif (defined($manifest)) {
 
183
  if (not $manifest =~ m#/#) {
 
184
    $manifest = "$cwd/$manifest";
 
185
  }
 
186
  push(@args, '-manifest', "$manifest");
 
187
}
 
188
else {
 
189
  # Add in the exclude patterns from the __DATA__ section
 
190
  push_exclusions(\@args);
 
191
}
 
192
 
 
193
sub push_exclusions {
 
194
  my $args = shift;
 
195
  foreach my $pat (<DATA>) {
 
196
    chomp($pat);
 
197
    push(@{$args}, '-exclude', $pat) if $pat;
 
198
  }
 
199
  if (defined ($ignorename)) {
 
200
    $ignorename = "../" . $ignorename;
 
201
    if (-e $ignorename) {
 
202
      open (IG, $ignorename) or die "Couldn't open $ignorename";
 
203
      foreach my $igf (<IG>) {
 
204
        chomp ($igf);
 
205
        push(@{$args}, '-exclude', $igf) if $igf;
 
206
      }
 
207
      close (IG);
 
208
    }
 
209
  }
 
210
  my @cvsignores = `find . -name '.cvsignore'`;
 
211
  foreach my $one_ignore (@cvsignores) {
 
212
    my ($name, $path) = fileparse($one_ignore);
 
213
    open (IG, $one_ignore);
 
214
    foreach my $fl (<IG>) {
 
215
      chomp $fl;
 
216
      $path =~ s/^\.\///;
 
217
      push(@{$args}, '-exclude', $path . $fl) if $fl;
 
218
    }
 
219
    close (IG);
 
220
  }
 
221
}
 
222
# Add the from and to directories for makepatch
 
223
push(@args, $old, $new);
 
224
print "Arguments are: " . join("; ", @args) . "\n";
 
225
 
 
226
chdir $gnc_home or die "Can't cd!\n";
 
227
 
 
228
# Erase the old files
 
229
#unlink('gnc.diff', 'gnucash.diff.gz', 'gnucash.diff.gz.uue');
 
230
 
 
231
if (not -d "diffs") {
 
232
  mkdir "diffs", 0755;
 
233
}
 
234
 
 
235
my $outfilename;
 
236
 
 
237
if (not defined($diffname)) {
 
238
  my $date = `date '+%Y%m%d-%H%M%S'`;
 
239
  chomp($date);
 
240
  my $who = `whoami`;
 
241
  chomp($who);
 
242
 
 
243
  $outfilename = "gnucash-$date-$who.diff";
 
244
}
 
245
else {
 
246
  $outfilename = $diffname;
 
247
}
 
248
 
 
249
# Invoke makepatch with standard out redirected to 'gnucash.diff'
 
250
open(OLDOUT, ">&STDOUT");
 
251
open(STDOUT, "> diffs/$outfilename") || die "Can't redirect stdout";
 
252
system('makepatch', @args);
 
253
close(STDOUT);
 
254
open(STDOUT, ">&OLDOUT");
 
255
close(OLDOUT);
 
256
print "makepatch done\n";
 
257
 
 
258
# Compress the patch if required
 
259
if ($zip) {
 
260
  if (-f "diffs/$outfilename") {
 
261
    system("gzip", "-9vf", "diffs/$outfilename");
 
262
  }
 
263
}
 
264
 
 
265
# UU encode the patch if required
 
266
 
 
267
# if $zip is true, then
 
268
# 'gnucash.diff.gz.uue' is the file you send.
 
269
if ($zip and -f "diffs/$outfilename.gz" and $::should_uuencode) {
 
270
  system("uuencode diffs/$outfilename.gz $outfilename.gz > diffs/$outfilename.gz.uue");
 
271
  print "diffs/$outfilename.gz.uue\n";
 
272
}
 
273
else {
 
274
  if (not $zip and -f "diffs/$outfilename" and $::should_uuencode) {
 
275
    system("uuencode diffs/$outfilename $outfilename > diffs/$outfilename.uue");
 
276
    print "diffs/$outfilename.uue\n";
 
277
  }
 
278
}
 
279
 
 
280
 
 
281
exit(0);
 
282
 
 
283
__DATA__
 
284
 
 
285
#*#
 
286
*.P
 
287
*.pp 
 
288
*.a
 
289
*.bak
 
290
*.bin
 
291
*.diff
 
292
*.diffs
 
293
*.gmo
 
294
*.la
 
295
*.lai
 
296
*.lo
 
297
*.loT
 
298
*.log
 
299
*.mo
 
300
*.moc
 
301
*.o
 
302
*.orig
 
303
*.ignmgp
 
304
*.patch
 
305
*.rej
 
306
*.tar.gz
 
307
*.wrap
 
308
*.xac.*.xac
 
309
*~
 
310
.#*
 
311
doc/gnc-prices.1
 
312
doc/gnucash.1