diff options
Diffstat (limited to 'bin/gen')
-rwxr-xr-x | bin/gen | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/bin/gen b/bin/gen deleted file mode 100755 index 4d3f1555d..000000000 --- a/bin/gen +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env perl - -sub usage() { - print "Usage: gen dest_dir [-r] file1 [file2 ...]\n"; - print "Turn a set of files into a set of patches (diffed against /dev/null).\n"; - print "-r Recurse.\n"; -} - -if ( ! ( $dest = shift @ARGV ) ) { - print STDERR "No destination specified!\n"; - usage(); - exit 1; -} -if ($dest eq '-h' || $dest eq '--help') { - usage(); - exit 0; -} - -sub gen_diff($) -{ - my $patch = lc ($a); - $patch =~ s/\//-/g; - $patch =~ s/\./-/g; - $patch .= '.diff'; - print "regenerate $patch from $a\n"; - - my $ppipe; - my $output; - - local $SIG{PIPE} = sub { die "spooler pipe broke" }; - - open ($ppipe, "diff --new-file -u /dev/null $a |") || die "Can't diff: $!"; - open ($output, ">$dest/$patch") || die "Can't create patch: $!"; - while (<$ppipe>) { - s/^([\-\+]{3}\s+[\S\d_\-\.]+\s+).*/$1/; - print $output $_; - } - close ($output) || die "Can't close diff: $!"; - close ($ppipe); # odd ... || die "Can't close patch pipe: $! $?"; -} - -sub filter_crud($) -{ - my $a = shift; - - $a =~ /~$/ && return; - $a =~ /\#$/ && return; - $a =~ /\.orig$/ && return; - $a =~ /unxlng.*\.pro$/ && return; - $a eq 'CVS' && return; - $a eq '.' && return; - $a eq '..' && return; - - return $a; -} - -sub slurp_dir($); - -sub slurp_dir($) -{ - my $dir = shift; - my ($dirhandle, $fname); - my @files = (); - - opendir ($dirhandle, $dir) || die "Can't open $dir"; - while ($fname = readdir ($dirhandle)) { - $fname = filter_crud($fname); - defined $fname || next; - if (-d "$dir/$fname") { - push @files, slurp_dir("$dir/$fname"); - } else { - push @files, "$dir/$fname"; - } - } - closedir ($dirhandle); - - return @files; -} - -my @files = (); -my $recurse = 0; - -for $a (@ARGV) { - if ($a eq '-h' || $a eq '--help') { - usage(); - exit 0; - - } elsif ($a eq '-R' || $a eq '-r') { - $recurse = 1; - - } else { - $a = filter_crud($a); - defined $a || next; - - if (-d $a) { - if ($recurse) { - push @files, slurp_dir($a); - } else { - print "skipping dir '$a'\n"; - } - } else { - push @files, $a if defined $a; - } - } -} - -for $a (@files) { - print "Diffing '$a'\n"; - gen_diff ($a); -} |