From 4863fad5997341b376d1aca993a58d88c6153a3b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Lars=20D=C9=AA=E1=B4=87=E1=B4=84=E1=B4=8B=E1=B4=8F=E1=B4=A1=20=E8=BF=AA=E6=8B=89=E6=96=AF?= <daxim@cpan.org>
Date: Tue, 16 Jun 2009 16:30:54 +0200
Subject: [PATCH] RT #41123, RT# 46369: make configuration non-interactive
fixes for:
RT #41123: one should be able to script the install of this module
RT #46369: Data::UUID Makefile.PL requires interaction. Should have non-interactive abilities for automation.
---
META.yml | 2 +
Makefile.PL | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/META.yml b/META.yml
index 2583c54..3f37afd 100644
--- a/META.yml
+++ b/META.yml
@@ -8,6 +8,8 @@ license: bsd
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
+ Getopt::Long: 2.23
+ Pod::Usage: 1.12
build_requires:
ExtUtils::MakeMaker: 0
requires:
diff --git a/Makefile.PL b/Makefile.PL
index 9021671..af025ef 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,5 +1,7 @@
use ExtUtils::MakeMaker;
use Config;
+use Getopt::Long qw(GetOptions :config pass_through);
+use Pod::Usage qw(pod2usage);
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
@@ -52,17 +54,29 @@ WriteMakefile(
# Un-comment this if you add C files to link with later:
OBJECT => '$(O_FILES)', # link all the C files too
CONFIGURE => sub {
+ my %opt;
+ GetOptions(\%opt, 's|state-storage-directory:s', 'd|default-umask:s',
+ 'help|?', 'man') or pod2usage(2);
+ pod2usage(1) if $opt{help};
+ pod2usage(-verbose => 2) if $opt{man};
+
+ print "Configured options (run perl Makefile.PL --help for how to change this):\n";
+
my $d;
if ($^O eq 'MSWin32' and -d "c:/tmp/") {
$d="c:/tmp";
} else {
$d=eval { require File::Spec; File::Spec->tmpdir; } || '/var/tmp';
}
- $d = prompt("UUID state storage", $d);
+ $d = $opt{s} || $d;
+ print "\tUUID state storage: $d\n";
$d =~ s/\\/\\\\/g if $^O eq 'MSWin32';
my $m = '0007';
- $m = prompt("default umask", $m) unless $^O eq 'MSWin32';
+ unless ($^O eq 'MSWin32') {
+ $m = $opt{d} || $m;
+ print "\tdefault umask: $m\n";
+ }
chmod(0666, sprintf("%s/%s", $d, ".UUID_NODEID"));
chmod(0666, sprintf("%s/%s", $d, ".UUID_STATE"));
@@ -73,3 +87,59 @@ WriteMakefile(
};
}
);
+
+__END__
+
+=head1 NAME
+
+Makefile.PL - configure Makefile for Data::UUID
+
+=head1 SYNOPSIS
+
+perl Makefile.PL [options] [EU::MM options]
+
+perl Makefile.PL -s=/var/local/lib/data-uuid -d=0007
+
+ Options:
+ --state-storage-directory directory for storing library state information
+ --default-umask umask for files in the state storage directory
+ --help brief help message
+ --man full documentation
+
+Options can be abbreviated, see L<Getopt::Long/"Case and abbreviations">.
+
+=head1 OPTIONS
+
+=over
+
+=item --state-storage-directory
+
+Optional. Takes a string that is interpreted as directory for storing library
+state information. Default is c:/tmp/ on Windows if it already exists, or the
+operating system's temporary directory (see tmpdir in L<File::Spec/"METHODS">),
+or /var/tmp as fallback.
+
+=item --default-umask
+
+Optional. Takes a string that is interpreted as umask for the files in the state
+storage directory. Default is 0007. This is ignored on Windows.
+
+=item --help
+
+Print a brief help message and exits.
+
+=item --man
+
+Prints the manual page and exits.
+
+=back
+
+=head1 DESCRIPTION
+
+B<Makefile.PL> writes the Makefile for the Data::UUID library. It is configured
+with the options L</"--state-storage-directory"> and L</"--default-umask">.
+Unless given, default values are used. In any case the values are printed for
+confirmation.
+
+Additionally, the usual EU::MM options are processed, see
+L<ExtUtils::MakeMaker/"Using Attributes and Parameters">.
--
1.6.3