No longer directly accessing debuggee memory.
[wine] / tools / genpatch
1 #!/usr/bin/perl
2
3 # genpatch - A utility that generates patches for submission to
4 # wine-patches@winehq.com
5 #
6 # By Steven Elliott <elliotsl@mindspring.com>
7 #
8 # This program is subject to the same license as Wine (www.winehq.com).
9
10 use Getopt::Std;
11 use File::Basename;
12 use POSIX qw(strftime);
13 use strict;
14
15 my $gen_date;    # date the patch was generated
16 my %options;     # command line options
17 my @new_files;   # new files as an array
18 my $new_file;    # new file being considered
19 my $patches_dir; # location of the patch file
20
21 # Default the patch name to the UTC time.  Use a more descriptive date for the
22 # patch generation date.
23 $options{n} = strftime "%Y%m%d%H%M", gmtime;
24 $gen_date = strftime "%Y/%m/%d %H:%M:%S UTC", gmtime;
25
26 unless(getopts("n:c:f:a:", \%options))
27 {
28     print STDERR "Usage: $0 [-n patch_name] [-c change_log] [-f patch_file] " .
29         "[-a new_files]\n";
30     exit 1;
31 }
32
33 $options{f} = "patches/$options{n}.diff" unless(exists $options{f});
34 $patches_dir = dirname $options{f};
35 @new_files = split ' ', $options{a};
36
37 if(-d $patches_dir)
38 {
39     if(-e $options{f})
40     {
41         print STDERR "$options{f} already exists.  Aborting.\n";
42         exit 1;
43     }
44 }
45 else
46 {
47     mkdir $patches_dir, (0777 & ~umask) or
48         die "Unable to mkdir $patches_dir: $!";
49 }
50
51 print "Generating $options{f}.\n";
52 open OPT_F, ">$options{f}" or die "Unable to open $options{f} for write: $!";
53 print OPT_F <<EOF;
54 Name: $options{n}
55 ChangeLog: $options{c}
56 GenDate: $gen_date
57 NewFiles: $options{a}
58 EOF
59
60 foreach $new_file (@new_files)
61 {
62     print "Adding $new_file as a new file.\n";
63     open DIFF_IN, "diff -u /dev/null $new_file|" or die "Unable to " .
64         "invoke diff: $!";
65     print OPT_F <DIFF_IN>;
66     close DIFF_IN;
67 }
68
69 print "Invoking cvs diff.\n";
70 open CVS_IN, "cvs diff -u|" or die "Unable to invoke cvs: $!";
71 print OPT_F <CVS_IN>;
72 close CVS_IN;