CPAN-Search-Lite
view release on metacpan or search on metacpan
build/gen_conf.pl view on Meta::CPAN
my $home = $ENV{HOME} || $cwd;
my $config = catfile $home, 'csl', 'cpan.conf';
$config = prompt('Location of configuration file?', $config);
unless (check_dir(dirname($config))) {
die "Need a valid location to save the configuration file";
}
if (-f $config) {
if (prompt_y("'$config' exists. Overwrite it?")) {
unlink $config or die "Cannot unlink $config: $!";
}
else {
die "Please specify a different configuration file name";
}
}
$cfg->SetFileName($config);
my $html_root;
if (prompt_y('Are you running a local CPAN mirror?')) {
my $CPAN = prompt('Path to top-level CPAN directory?',
'/var/ftp/pub/CPAN');
die qq{$CPAN does not exist} unless (-d $CPAN);
$cfg->newval('CPAN', 'CPAN', $CPAN);
my $pod_root = prompt('Path to store pod sources?',
catdir($httpd, 'POD'));
if ($pod_root = check_dir($pod_root)) {
$cfg->newval('CPAN', 'pod_root', $pod_root);
}
else {
warn "Will not insert configuration for pod sources\n";
}
$html_root = prompt('Path to store html files?',
catdir($httpd, 'htdocs', 'CPAN'));
if ($html_root = check_dir($html_root)) {
$cfg->newval('CPAN', 'html_root', $html_root);
}
else {
warn "Will not insert configuration for html files\n";
}
}
else {
$cfg->newval('CPAN', 'no_mirror', 1);
my $CPAN = prompt('Location to store CPAN index files?',
catdir($home, '.cpan', 'build'));
if ($CPAN = check_dir($CPAN)) {
$cfg->newval('CPAN', 'CPAN', $CPAN);
}
else {
die "Must have a valid location to store index files";
}
my $remote_mirror = prompt('CPAN mirror to fetch index files?',
'http://www.cpan.org');
$cfg->newval('CPAN', 'remote_mirror', $remote_mirror);
}
unless (prompt_y('Gather Win32 ppm package information?')) {
$cfg->newval('CPAN', 'no_ppm', 1);
}
if (prompt_y('Guess unassigned module categories?')) {
my $cat_threshold = prompt('Threshold value for guesses?', 0.998);
$cfg->newval('CPAN', 'cat_threshold', $cat_threshold);
}
else {
$cfg->newval('CPAN', 'no_cat', 1);
}
$cfg->newval('CPAN', 'DEBUG', 1);
my $multiplex;
if (prompt_y('Use a multiplexer for mirror redirects?')) {
$multiplex = prompt('Address of multiplexer',
'http://www.perl.com/CPAN');
$cfg->newval('CPAN', 'multiplex', $multiplex);
}
print <<'END';
For the database, as well as needing the name, we will
also require the user and password who has permission to
create/query/alter/drop tables. It is assumed the database
has already been created, and that this user has already
been set up with the proper privileges.
END
my $db = prompt('Name of database?', 'pause');
$cfg->newval('DB', 'db', $db);
my $user = WIN32 ? $ENV{USERNAME} : getpwuid($>);
$user = prompt('User to create/query/alter/drop tables?', $user);
$cfg->newval('DB', 'user', $user);
my $passwd = prompt("Password for '$user'?", 'q1w2e3r4');
$cfg->newval('DB', 'passwd', $passwd);
my $host = hostname;
my %config;
my ($tt2, $static);
my $web = prompt_y('Set up configuration for a web server?');
if ($web) {
print <<'END';
We now gather some information for configuring the
web server.
END
$config{db_sub} = $cfg->val('DB', 'db');
$config{nobody_sub} = prompt('User to query tables?', 'nobody');
$config{no_pass_sub} = prompt("Password for '$config{nobody_sub}'?",
'p0o9i8u7');
$tt2 = prompt('Location of installed tt2 templates?',
catdir($httpd, 'tt2'));
if ($tt2 = check_dir($tt2)) {
$cfg->newval('WWW', 'tt2', $tt2);
$config{tt2_sub} = $tt2;
}
else {
die "Need a valid directory for tt2 pages\n";
}
my $geoip = prompt('Location of list of CPAN mirrors?',
catfile($tt2, 'cpan.txt'));
if ($geoip = check_dir(dirname($geoip))) {
( run in 1.038 second using v1.01-cache-2.11-cpan-c221a9de4ec )