#!perl -wln -S # SplitPatch - Split patch file to multiple files # Splits at Index: lines # Splits at diff lines # Output files named patchedfile.patch # Dies if patch file exists - may want to support sequence numbering # -l chomp/add line endings # -n loop on args # -p print $_ # -s process switch args does not work here - use perl -s # -S search PATH must be last here # -w strict warnings # Copyright (c) 2014 Steven Levine and Associates, Inc. # All rights reserved. # 2014-02-08 SHL Baseline # 2014-10-06 SHL Support split at diff commands use strict; use warnings; # use Package::Subpackage Options; our $g_curarg; our $g_outfile; BEGIN { return if $^C; warn "$0 will process " . @ARGV . " args\n"; $g_curarg = ''; } END { return if $^C; close OUTFILE if defined $g_outfile; # warn "\nBye\n"; } if ($ARGV ne $g_curarg) { $g_curarg = $ARGV; warn "$0 processing $g_curarg\n"; close OUTFILE if defined $g_outfile; undef $g_outfile; } # 2014-12-22 SHL Added to support diff next if /^Only in .*: .*$/; # Index: bld/sdk/rc/rc/regress/os2/rcdata.rc # diff -ur stunnel-5.04-o/src/client.c stunnel-5.04/src/client.c if (/^Index:.*\/([^\/]*)$/ || /^diff .*\/([^\/]*)$/ ) { my $name = $1; # filename without path close OUTFILE if defined $g_outfile; $g_outfile = "$name.patch"; die "$g_outfile exists" if -f $g_outfile; warn "Writing $g_outfile\n"; open OUTFILE, ">$g_outfile" or die "open $g_outfile $!"; } # ignore noise at start of file next if !defined $g_outfile; print OUTFILE $_; # print $_; # The end