Alt-App-makepatch
view release on metacpan or search on metacpan
script/makepatch view on Meta::CPAN
}
message (" $excluded file",
$excluded == 1 ? " was" : "s were", " excluded.\n") if $excluded;
}
sub filelist ($) {
my ($man) = @_;
my @new = make_filelist_from_manifest ($man);
foreach ( @new ) {
print STDOUT ($opt_prefix, $_, "\n");
}
}
sub app_options () {
my $opt_manifest;
my $opt_help = 0;
my $opt_ident = 0;
my $opt_rcfile;
my @o = (
"automanifest=s" => \$opt_automanifest,
"debug!" => \$opt_debug,
"description=s@" => \@opt_descr,
"diff=s" => \$opt_diff,
"exclude-regex=s@" => \@opt_exclude_regex,
"exclude-standard!" => \$opt_exclude_standard,
"exclude-rcs!" => \$opt_exclude_rcs,
"exclude-sccs!" => \$opt_exclude_sccs,
"exclude-cvs!" => \$opt_exclude_cvs,
"exclude-vc!" => sub { $opt_exclude_rcs =
$opt_exclude_cvs =
$opt_exclude_sccs = $_[1] },
"exclude=s@" => \@opt_exclude,
"extract=s%" => \%opt_extract,
"filelist|list!" => \$opt_filelist,
"follow!" => \$opt_follow,
"help" => \$opt_help,
"ident!" => \$opt_ident,
"ignore-cvs-keywords|ignore-rcs-keywords!"
=> \$opt_ignore_rcs_keywords,
"infocmd=s" => \$opt_infocmd,
"manifest=s" => \$opt_manifest,
"newmanifest=s" => \$opt_newmanifest,
"nomanifest!" => \$opt_nomanifest,
"oldmanifest=s" => \$opt_oldmanifest,
"patchlevel=s" => \$opt_patchlevel,
"prefix=s" => \$opt_prefix,
"quiet!" => \$opt_quiet,
"sort!" => \$opt_sort,
"recurse!" => \$opt_recurse,
"test" => \$opt_test,
"trace!" => \$opt_trace,
"verbose!" => \$opt_verbose,
);
my $init;
# Process ENV options.
if ( defined ($init = $ENV{MAKEPATCHINIT}) ) {
require Text::ParseWords;
local (@ARGV) = Text::ParseWords::shellwords ($init);
unless ( GetOptions (@o, "rcfile=s" => \$opt_rcfile) &&
@ARGV == 0 ) {
warn ("Error in MAKEPATCHINIT\n");
app_usage (1);
}
else {
trace ("+ INIT: $init\n");
}
}
unless ( $opt_test ) {
# Process ini file options.
# First, try system wide file. Unix specific.
app_parse_rc ("/etc/makepatchrc", 1, \@o);
my $rcname = ".".$my_name."rc";
# Then, try HOME .rc.
app_parse_rc (catfile ($HOME, $rcname), 1, \@o);
# Then try --rcfile, defaulting to .rc in current dir.
if ( defined $opt_rcfile ) {
app_parse_rc ($opt_rcfile, 0, \@o);
}
else {
app_parse_rc (catfile ($dot, $rcname), 1, \@o);
}
}
# Process command line options
if ( !GetOptions (@o) || $opt_help ) {
app_usage (1);
}
# Argument check.
if ( $opt_filelist ) {
if ( defined $opt_manifest ) {
app_usage (1) if @ARGV;
@ARGV = ( $opt_manifest );
}
else {
app_usage (1) unless @ARGV == 1;
}
}
else {
app_usage (1) unless @ARGV == 2;
}
$opt_trace = 1 if $opt_debug;
print STDERR ("This is $my_name version $my_version\n")
if $opt_verbose || $opt_ident;
if ( $opt_prefix ne '' ) {
die ("$0: option \"-prefix\" requires \"-filelist\"\n")
unless $opt_filelist;
}
if ( defined $opt_sort ) {
die ("$0: option \"-[no]sort\" requires \"-filelist\"\n")
unless $opt_filelist;
}
else {
$opt_sort = 1;
}
if ( $opt_filelist ) {
die ("$0: option \"-filelist\" only uses \"-manifest\"\n")
if defined $opt_oldmanifest || defined $opt_newmanifest;
}
if ( defined $opt_manifest ) {
die ("$0: do not use \"-manifest\" with \"-oldmanifest\"".
" or \"-newmanifest\"\n")
if defined $opt_newmanifest || defined $opt_oldmanifest;
$opt_newmanifest = $opt_oldmanifest = $opt_manifest;
}
if ( defined $opt_infocmd ) {
die ("$0: \"-infocmd\" can not be used with \"-filelist\"\n")
if $opt_filelist;
# Protect %% sequences.
$opt_infocmd =~ s/\%\%/\001/g;
# Encode %o and %n sequences.
$opt_infocmd =~ s/\%o([P])/\002$1/g;
$opt_infocmd =~ s/\%n([P])/\003$1/g;
# Restore %% sequences.
$opt_infocmd =~ s/\001/%%/g;
while ( $opt_infocmd =~ /(\%[on]\S)/g ) {
warn ("Warning: $1 in info command may become ",
"special in the future\n");
}
}
$opt_verbose = 0 if $opt_quiet;
$opt_trace ||= $opt_debug;
$opt_verbose ||= $opt_trace;
}
sub app_parse_rc ($$$) {
my ($file, $opt, $optref) = @_;
my $rcfile = new IO::File;
unless ( $rcfile->open($file) ) {
die ("$file: $!\n") unless $opt;
return;
}
require Text::ParseWords;
local (@ARGV);
my $ok = 1;
# Intercept Getopt::Long warning messages.
my $warn;
$SIG{__WARN__} = sub { $warn = "@_"; };
# Process the file.
while ( <$rcfile> ) {
# Skip blank and comment lines.
next if /^\s*[;#]/;
next unless /\S/;
# Split.
my @a = Text::ParseWords::shellwords ($_);
$warn = '';
trace ("+ RC: @a\n");
# Handle.
@ARGV = @a;
unless ( GetOptions (@$optref) ) {
chomp ($warn);
print STDERR ("$warn -- at line $. in $file\n");
$ok = 0;
}
if ( @ARGV > 0 ) {
print STDERR ("Garbage \"@ARGV\"",
" -- at line $. in $file\n");
$ok = 0;
}
}
$rcfile->close;
$SIG{__WARN__} = 'DEFAULT';
unless ( $ok ) {
app_usage (1);
}
$ok;
}
sub app_usage ($) {
my ($exit) = @_;
print STDERR <<EoU;
This is $my_name version $my_version
Usage: $0 [options] old-src new-src
Makepatch options:
-description XXX descriptive message about this patch
-diff cmd diff command to use, default \"$opt_diff\"
-patchlevel file file to use as patchlevel.h
-man[ifest] file list of files for old and new dir, defaults to $opt_automanifest
-nomanifest suppress use of MANIFEST files
-automan[ifest] XXX assumend name for MANIFEST files
-newman[ifest] file list of files for new dir
-oldman[ifest] file list of files for old dir
-follow follow symbolic links
-infocmd cmd add output of cmd to each patch chunk
-exclude pat exclude files according to wildcard pattern
-exclude-regex pat exclude files and dirs matching regex pattern
-exclude-vc exclude version control files (RCS, CVS, SCCS)
-exclude-rcs exclude version control files for RCS
-exclude-cvs exclude version control files for CVS
( run in 2.233 seconds using v1.01-cache-2.11-cpan-d8267643d1d )