[ic] Interchange installation on Virtual Server Help required

Mike Heins mikeh@minivend.com
Fri, 13 Oct 2000 22:11:06 -0400


--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii

Quoting John Walsh (jwalsh@diabetesnet.com):
> Mike,
> 
> Being the perl and IC novice I am, I welcomed your CPAN_local_install 
> script, but when I ran it in my VPS space, I got:
> 
> ##########
> If you have errors during the process, don't worry. Either
> just continue on or stop the program and try again, replying
> No when prompted for CPAN.
> 
> Get Bundle::Interchange module? [yes]
> Can't return outside a subroutine at cpan_local_install line 96, <STDIN> 
> chunk 1
>  .
> #############
> 
> In the script, I believe these are the lines referenced:
> ##############
> for my $module (@mods_to_get) {
>          my $prompt = "Get $module module? [yes]";
>          my $ask = my_prompt($prompt);
>          return undef if $ask =~ /^\s*n/i;
> 
>          return undef unless defined $CPAN::Config;
>          $CPAN::Config->{makepl_arg} = .......
> ##################
> 
> There's a sub above called myprompt, but the return doesn't seem to realize 
> it's there?

Yes, bug moving it from Makefile.PL to that script. (Actually, I managed
to delete the original script when trying out a new feature of my mailer,
so I hurriedly recreated it and made a mistake or two.)

V 0.2 attached, but I am guessing you are failing at the CPAN initialization.
It probably will not work, but this time you will get a more illuminating
error message.

I think you are doomed to installing a complete new version of Perl in your
own directory. Luckily the days of 10MB web server limits are past (or should be).

-- 
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>

Nature, to be commanded, must be obeyed. -- Francis Bacon

--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=cpan_local_install

#!/usr/bin/perl

require 5.6.0;

use Cwd;
use File::Spec;

use strict;

my @mods_to_get;

# See if we have the CPAN module
my $Cpan = 0;
my $CpanInit;
eval { 	
		die "Don't try this at home with Windows.\n" if $^O =~ /win32/i;
		require CPAN::Config;
		require CPAN;
		import CPAN;
};

if($@) {
	die "Can't do cpan_local_install: $@\n";
}

die "CPAN not initialized.\n"
	unless defined $CPAN::Config;

sub my_prompt {
    my($pr) = shift || '? ';
    my($def) = shift;
    my($ans);

    print $pr;
    print "[$def] " if $def;
    chomp($ans = <STDIN>);
    $ans ? $ans : $def;
}

my $libdir = shift;
my @mods_to_get = @ARGV;

if(! @mods_to_get) {
	push @mods_to_get, 'Bundle::Interchange';
}

if(! $libdir) {
	my @possible = grep -f $_, qw/minivend.cfg interchange.cfg interchange.cfg.dist/;
	if(@possible) {
		$libdir = cwd() if -d 'lib';
	}
}

$libdir =~ s:(^|/)lib$::;

if(! File::Spec->file_name_is_absolute($libdir) ) {
	$libdir = File::Spec->catfile(cwd(), $libdir);
}

unshift @INC, $libdir, "$libdir/lib";

print <<EOF;

Since you have the CPAN module installed and initialized,
we can go and get optional modules that help Interchange work a
bit better and faster. At least we can if you are connected
to the Internet and have one of the following on your machine:

		Perl LWP libraries
		Perl Net::FTP library
		ncftp (a nice FTP program)
		lynx  (the text-based web browser)

In case you were wondering, CPAN is a worldwide network of
over 100 FTP sites which maintain the latest Perl software.
If you don't know a URL to use, you can try:

	ftp://ftp.freesoftware.com/pub/perl/CPAN
	ftp://ftp.funet.fi/pub/languages/perl/CPAN

If you have never used CPAN before, you may want to reply NO.
Interchange should work anyway -- it just won't be quite as easy
to build the demo catalogs.

If you have errors during the process, don't worry. Either
just continue on or stop the program and try again, replying
No when prompted for CPAN.

EOF

for my $module (@mods_to_get) {
	my $prompt = "Get $module module? [yes]";
	my $ask = my_prompt($prompt);
	exit 2 if $ask =~ /^\s*n/i;
	
	$CPAN::Config->{makepl_arg} = "INSTALLPRIVLIB=$libdir/lib INSTALLARCHLIB=$libdir/lib INSTALLSITELIB=$libdir/lib INSTALLMAN1DIR=none INSTALLMAN3DIR=none INSTALLSITEARCH=$libdir/lib INSTALLDIRS=perl";
	$CPAN::Config->{keep_source_where} = "$libdir/src"
		unless -w $CPAN::Config->{keep_source_where};
	$CPAN::Config->{cpan_home} = "$libdir/src"
		unless -w $CPAN::Config->{cpan_home};
	$CPAN::Config->{build_dir} = "$libdir/src"
		unless -w $CPAN::Config->{build_dir};
	CPAN::install($module);
}

--mP3DRpeJDSE+ciuQ--