3 # genpatch - A utility that generates patches for submission to
4 # wine-patches@winehq.com
6 # By Steven Elliott <elliotsl@mindspring.com>
8 # This program is subject to the same license as Wine (www.winehq.com).
12 use POSIX qw(strftime);
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
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;
26 unless(getopts("n:c:f:a:", \%options))
28 print STDERR "Usage: $0 [-n patch_name] [-c change_log] [-f patch_file] " .
33 $options{f} = "patches/$options{n}.diff" unless(exists $options{f});
34 $patches_dir = dirname $options{f};
35 @new_files = split ' ', $options{a};
41 print STDERR "$options{f} already exists. Aborting.\n";
47 mkdir $patches_dir, (0777 & ~umask) or
48 die "Unable to mkdir $patches_dir: $!";
51 print "Generating $options{f}.\n";
52 open OPT_F, ">$options{f}" or die "Unable to open $options{f} for write: $!";
55 ChangeLog: $options{c}
60 foreach $new_file (@new_files)
62 print "Adding $new_file as a new file.\n";
63 open DIFF_IN, "diff -u /dev/null $new_file|" or die "Unable to " .
65 print OPT_F <DIFF_IN>;
69 print "Invoking cvs diff.\n";
70 open CVS_IN, "cvs diff -u|" or die "Unable to invoke cvs: $!";