[ic] Interchange installation on Virtual Server Help required

Mike Heins mikeh@minivend.com
Fri, 13 Oct 2000 16:32:38 -0400


--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii

Quoting Hansraj Pankhania (itnc@themutual.net):
> I have obtain a copy of Interchange 4.5.7. , and due to access right problems i'm having problems trying to install interchange and cannot get the additional CPAN modules installed or as a matter of fact interchange installed at all.
> 
> I've email Jon and he advised either :-
> 
> a) run perl -MCPAN -e 'install Bundle::Interchange'
> 
> or
> 
> b) Speak to the administrators of my ISP and get them to  install the modules.
> 

or c) use the cpan_local_install script, which I just wrote.

I should have done this a long time ago; it is attached.

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

Unix version of an Outlook-style virus:
It works on the honor system. Please forward this message to everyone
you know, and delete a bunch of your files at random.

--bp/iNruPH9dso1Pn
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 if $^O =~ /win32/i;
		unless( -f ".cpan.tried") {
			open TMP, ">.cpan.tried" and close TMP;
			require CPAN::Config;
			require CPAN;
			import CPAN;
		}
		unlink ".cpan.tried";
};
unless($@) {
	$Cpan = 1;
}

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);
	return undef if $ask =~ /^\s*n/i;
	
	return undef unless defined $CPAN::Config;
	$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);
}

--bp/iNruPH9dso1Pn--