use ExtUtils::MakeMaker; require ExtUtils::Install; BEGIN { eval { require FindBin; chdir $FindBin::RealBin; }; } use Config; use File::Copy; use File::Path; use File::Basename; use Cwd; require 5.004; use strict; use vars (qw($VERSION $DOWARN)); my $TermRead; my $Prompt_sub; my @mods_to_get; my $Lock_troubles; my $Windows; $VERSION = '3.15'; # See if we have the CPAN module my $Cpan = 0; my $CpanInit; eval { die if $ =~ /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; } my (@extra_lib_dirs); my (@extra_lib_files); # Now we can use the libraries use lib './lib'; my $origdir = fastcwd(); # See if we have Term::ReadLine::Perl eval { require Term::ReadLine; require Term::ReadLine::Perl; require Term::ReadKey; $TermRead = 1; }; unless($@) { $ENV{PERL_RL} = 'Perl'; } elsif ($Cpan) { push @mods_to_get, 'Term::ReadKey', 'Term::ReadLine::Perl'; } my $term; if($TermRead) { $term = new Term::ReadLine 'MakeFile'; $Prompt_sub = sub { my($prompt, $default) = @_; $prompt .= "[$default] " if defined $default && !$ENV{PERL_RL}; return $term->readline($prompt, $default); }; } my $ActiveState; if($Config{osname} eq 'solaris') { eval { require 5.004 or require File::Lock }; if($@) { push @mods_to_get, "File::Lock"; $Lock_troubles = 1; } } elsif($Config{osname} =~ /win32/i) { $Windows = 1; eval { require 5.004; }; if($@) { print < dist/.linux.badposix"; print <) { /VERSION\s+=.*?\s+([\d.]+)/ or next; $extra = $1; $extra =~ tr/0-9//cd; last; } $extra = 'old' unless $extra; while (-f "$targfile.$extra") { $extra .= '~'; } rename $targfile, "$targfile.$extra" or die "Couldn't rename $targfile to $targfile.$extra: $!\n"; } File::Copy::copy($srcfile, $targfile) or die "Copy of $srcfile to $targfile failed: $!\n"; chmod $perms, $targfile; } sub copyright_prompt { print < MiniVend is free under the terms of the GNU General Public License. EOF } sub my_prompt { return &$Prompt_sub(@_) if defined $Prompt_sub; my($pr) = shift || '? '; my($def) = shift; my($ans); print $pr; print "[$def] " if $def; chomp($ans = ); $ans ? $ans : $def; } sub active_get { my (@mods) = @_; for(@mods) { system "start ppm.pl install $_"; } } sub cpan_get { my($module, $libdir, $prompt) = @_; return active_get($module) if $ActiveState; print <{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}; return CPAN::install($module); } sub initialize { my %X=(); $X{INSTALLARCHLIB} = "/home/minivend/lib"; $X{INSTALLPRIVLIB} = "/home/minivend/lib"; $X{INSTALLMAN1DIR} = "/home/minivend/doc"; $X{INSTALLMAN3DIR} = "/home/minivend/doc"; $X{INSTALLDIRS} = "perl"; my $install = 0; my $realdir; for(@ARGV) { return \%X if /^nocopy$/; ($install = 1, next) if /^install$/; next unless $install; $realdir = $_; $realdir =~ s:/lib$::; } unless ($install) { #exec("perl install.pl") if $Windows; ©right_prompt(); my @mvdir = ( "$ENV{HOME}/mvend", "/home/minivend", "/usr/local/lib/minivend", "$ENV{HOME}/minivend", ); if(defined $Lock_troubles) { print <_active_tried" and close TMP; active_get(@mods_to_get); } } my $dosdir = $realdir; $dosdir =~ s:/:\\:g; open(WINBAT, ">configure2.bat") or die "create configure2.bat: $!\n"; print WINBAT <$realdir/_db_storable") or die "creat $realdir/_db_storable: $!\n"; print TSTORABLE "REMOVE THIS FILE TO STOP USING Storable\n"; close TSTORABLE; } if ($ask =~ /^\s*(y|s)/i) { open(TSTORABLE, ">$realdir/_session_storable") or die "creat $realdir/_session_storable: $!\n"; print TSTORABLE "REMOVE THIS FILE TO STOP USING Storable\n"; close TSTORABLE; } } MODCHECK: { last MODCHECK unless $Cpan; last MODCHECK if $Windows; eval { require MD5; }; push(@mods_to_get, 'MD5') if $@ and $Cpan; eval { require SQL::Statement; }; push(@mods_to_get, 'SQL::Statement') if $@ and $Cpan; eval { require MIME::Base64; }; push(@mods_to_get, 'MIME::Base64') if $@ and $Cpan; eval { require URI::URL; }; push(@mods_to_get, 'URI::URL') if $@ and $Cpan; } my $Upgrade; UPGRADE: { if( -f "$realdir/minivend.cfg" and (-f "$realdir/minivend.pl" or -f "$realdir/bin/minivend")) { my $msg; print <; close MANIFILE; chomp(@files); for(@extra_lib_files) { push @files, "lib/$_"; } for(@extra_doc_files) { push @files, $_; } $ = 0; if($Windows) { my $dll_source = "win/cygwin.dll"; my $dll_dir; for( $ENV{SYSTEMROOT}, qw! c:/windows d:/windows e:/windows f:/windows !) { -d $_ and $dll_dir = $_; } $dll_dir .= '/system'; $dll_dir =~ s:\\:/:g; my $dll_location = $dll_dir . "/cygwin.dll"; DLL: { unless(-f $dll_location) { if (-f $dll_source and -d $dll_dir) { File::Copy::copy( $dll_source, $dll_location); } elsif (-f $dll_source) { print <Load("win/minivend.pif"); open(WINBAT, ">minivend.bat") or die "create minivend.bat: $!\n"; print WINBAT "set PGPPATH=$ENV{PGPPATH}\n" if $ENV{PGPPATH}; print WINBAT <{Path} = "$realdir/minivend.bat"; $short->{WorkingDirectory} = "$realdir"; $short->{Path} =~ s:/:\\:g; $short->{WorkingDirectory} =~ s:/:\\:g; $short->{File} = "Start MiniVend Server"; $short->Save(); undef $short; open(WINBAT, ">makecat.bat") or die "create makecat.bat: $!\n"; print WINBAT <Load("win/minivend.pif"); $short->{Path} = "$realdir/makecat.bat"; $short->{WorkingDirectory} = "$realdir"; $short->{Path} =~ s:/:\\:g; $short->{WorkingDirectory} =~ s:/:\\:g; $short->{File} = "Make MiniVend Catalog"; $short->Save(); File::Copy::copy('win/POSIX.pm', 'lib/POSIX.pm') or die "File::Copy::copy error 'win/POSIX.pm': $!\n"; @winfiles = grep m:^lib/:, @files; eval { File::Copy::copy('Start MiniVend Server.pif', 'dist') or die "File::Copy::copy error 'Start MiniVend Server.pif': $!\n"; File::Copy::copy('Make MiniVend Catalog.pif', 'dist') or die "File::Copy::copy error 'Make MiniVend Catalog.pif': $!\n"; push @winfiles, 'Start MiniVend Server.pif'; push @winfiles, 'Make MiniVend Catalog.pif'; }; if ($@) { my $windir = $realdir; $windir =~ s:/:\\:g; print <MM::install; s/\ninstall :.*/$new/; $_; } WriteMakefile( NAME => "MiniVend", "DISTNAME" => "minivend", "MAN1PODS" => {}, "dist" => { CI => "ci -l -t-Initial", SUFFIX => ".gz", DIST_DEFAULT => 'all tardist', COMPRESS => "gzip -9f", ZIP_FLAGS => '-pr9', }, VERSION_FROM => "dist/bin/minivend", EXE_FILES => [], CONFIGURE => \&initialize, );