#!/usr/bin/perl # ************************ 80 columns ****************************************** # # -------------------------------------------------------------------- # Pathway Logic Assistant. # Copyright (C) 2006, SRI International. All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -------------------------------------------------------------------- # use warnings; use strict; use Getopt::Long; use Pod::Usage; use File::Path; ##### # parse parameters my %options = (); # store options in this hash # parse options or complain: if (@ARGV > 0) { GetOptions(\%options, 'help') or pod2usage(-exitval => 2, -verbose => 1); } # print help text and exit: pod2usage(-exitval => 1, -verbose => 2) if ($options{help}); # get archive file name pod2usage(-message => "Must supply archive file to be installed.", -verbose => 1) if (@ARGV < 1); my $archive = $ARGV[0]; pod2usage(-message => "Supplied archive file is not readable.", -verbose => 1) unless (-r $archive); # set installation location my $plalib = '~/Maude/Lib/M2.2'; if (@ARGV > 1) { $plalib = $ARGV[1]; } ##### # test dependencies my $MIN_IOP_VERSION = 644; # maude die " *** Error: Environment variable MAUDE_LIB not defined." if (!defined($ENV{MAUDE_LIB})); # dot print "\nTrying to resolve location of \"dot\"...\n"; die " *** Error: Cannot determine if dot is installed -- \"which dot\" failed." if system("which","dot"); # lola print "\nTrying to resolve location of \"lola\"...\n"; die " *** Error: Cannot determine if lola is installed -- \"which lola\" failed." if system("which","lola"); # iop & version print "\nTrying to resolve location of \"iop\"...\n"; die " *** Error: Cannot determine if iop is installed -- \"which iop\" failed." if system("which","iop"); die " *** Error: Environment variable IOPBINDIR not defined." if (!defined($ENV{IOPBINDIR})); my $iop_version = `iop -v`; $iop_version = join(" ", split " ", $iop_version); # collapse white space and trim $iop_version =~ s/IOP version: //; die " *** Error: Need at least IOP version $MIN_IOP_VERSION but found only version $iop_version installed." if ($MIN_IOP_VERSION > $iop_version); ##### # put files into installation location # convert ~ into home dir $plalib =~ s{^~/}{$ENV{HOME}/}; # delete & make dir rmtree("${plalib}/PLA"); eval { mkpath($plalib) }; die " *** Error: Couldn't create $plalib: $@" if ($@); # extract files in $plalib/PLA my @args = ("tar", "-xzf", $archive, "-C", $plalib); system(@args) == 0 or die " *** Error: system @args failed: $?"; #### # good-bye... my $ciao = qq[ Installation of PLA successful! To run "pla" launch script from anywhere, add ${plalib}/PLA to your PATH environment variable. Enjoy! ]; print $ciao; __END__ =head1 NAME install - Installing the Pathway Logic Assitant from command line =head1 SYNOPSIS install [options] PLA-v.tgz [] =head1 OPTIONS =over 8 =item --help | -h Print man page and exit. =back =head1 DESCRIPTION B installs PLA from the command line. You must supply the compressed archive of PLA-v.tgz that is available from http://pl.csl.sri.com. Optionally, you can specify the directory where to install PLA. If omitted, will use the default location of ~/Maude/Lib/M2.2/ and create directories on-the-fly as needed. =cut