#!/bin/sh ############################################################ # go-perl -- Install perl and important modules # Mike Schilli, 2002. ############################################################ COMMENT=< asks you a couple of questions (like where you want to install perl) and then grabs the latest tarball from www.perl.com, unpacks it, configures it, makes it, tests it, installs it, then downloads and installs CPANPLUS, and lets you configure it. Then, it will install a slew of modules automatically. If you're on a machine somewhere else and don't have access to C, don't despair: It's always available on perlmeister.com, just do wget http://perlmeister.com/go-perl cx go-perl go-perl and the fun begins. The defaults are currently set to the current user's home directory, assuming you want to use C for local perl installations. =head1 EXAMPLES $ go-perl =head1 LEGALESE Copyright 2002 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2002, Mike Schilli =cut EOT TYPE=SHELL_SCRIPT VER=<" read in if [ "$in" = "" ] then ANSWER=$default else ANSWER=$in fi } ############################################################ mkdir_if_needed () { ############################################################ dir=$1 if [ ! -d $dir ] then echo "mkdir $dir" mkdir -p $dir || exit 1 else echo "Directory $dir already exists" fi } ############################################################ get_distribution () { # Fetch a tarball from the web, extract the distribution ############################################################ url=$1 instdir=$2 tmpdir=$3 tarball=`basename $url` olddir=`pwd` mkdir_if_needed $instdir mkdir_if_needed $tmpdir cd $tmpdir || exit 1 if [ -f $tarball ] then echo "Tarball $tarball already exists" ask "Overwrite" n downloadit=$ANSWER if [ "$ANSWER" = y ] then echo "Deleting $tarball in `pwd`" $RM $tarball || exit 1 fi else echo "Tarball $tarball doesn't exist" downloadit=y fi if [ "$downloadit" = y ] then echo "Fetching $url into `pwd` ..." wget $url || exit 1 fi # Unpack it to determine dir tardir=`$GZIP -dc $tarball | $TAR tfv - |\ $HEAD -1 | sed 's/.* //' | sed 's#/.*##'` tardir=$tmpdir/$tardir echo "tardir is '$tardir'" if [ -d $tardir ] then echo "$tardir already exists" ask "Overwrite" n unpackit=$ANSWER if [ "$ANSWER" = y ] then echo "Deleting $tardir" $RM -rf $tardir || exit 1 fi else echo "$tardir doesn't exist" unpackit=y fi if [ $unpackit = "y" ] then echo "Unpacking $tarball ..." $GZIP -dc $tarball | $TAR xf - || exit 1 fi if [ $unpackit != "y" ] then ask "Build/Install it" n buildit=$ANSWER else buildit=y fi cd $olddir } ############################################################ install_core_perl () { ############################################################ get_distribution $PERL_SRC_URL $PERL_INSTALL_PREFIX $TMP_BUILD_DIR if [ "$buildit" = "y" ] then echo "Building $tardir" olddir=`pwd` cd $tardir || exit 1 echo "./Configure -D prefix=$PERL_INSTALL_PREFIX -d -e" ./Configure -D prefix=$PERL_INSTALL_PREFIX -d -e $MAKE || exit 1 $MAKE install || exit 1 cd $olddir else echo "Not building $tardir" fi } ############################################################ install_cpanplus () { ############################################################ mkdir_if_needed $CPANPLUS_DIR get_distribution $CPANPLUS_URL / $TMP_BUILD_DIR if [ "$buildit" = "y" ] then echo "Building $tardir" olddir=`pwd` cd $tardir || exit 1 $PERL_INSTALL_PREFIX/bin/perl Makefile.PL make || exit 1 make test || exit 1 make install || exit 1 cd $olddir else echo "Not building $tardir" fi } ############################################################ install_module_manually () { ############################################################ url=$1 param=$2 echo "[$url $param]" get_distribution $url / $TMP_BUILD_DIR if [ "$buildit" = "y" ] then echo "Building $tardir" olddir=`pwd` cd $tardir || exit 1 echo "[$PERL_INSTALL_PREFIX/bin/perl Makefile.PL $param]" $PERL_INSTALL_PREFIX/bin/perl Makefile.PL $param make || exit 1 make test || exit 1 make install || exit 1 cd $olddir else echo "Not building $tardir" fi } ############################################################ install_openssl () { ############################################################ url=$OPENSSL_DOWNLOAD_PAGE/$OPENSSL_TARBALL get_distribution $url $PERL_INSTALL_EXTLIB_DIR $TMP_BUILD_DIR if [ "$buildit" = "y" ] then echo "Building $tardir" cd $tardir || exit 1 ./config --prefix=$PERL_INSTALL_EXTLIB_DIR make || exit 1 make install || exit 1 else echo "Not building $tardir" fi } ############################################################ install_pari () { ############################################################ url=$PARI_DOWNLOAD_PAGE/$PARI_TARBALL get_distribution $url $PERL_INSTALL_EXTLIB_DIR $TMP_BUILD_DIR if [ "$buildit" = "y" ] then echo "Building $tardir" cd $tardir || exit 1 ./Configure --prefix=$PERL_INSTALL_EXTLIB_DIR make gp || exit 1 make install-bin || exit 1 else echo "Not building $tardir" fi } ############################################################ install_modules () { ############################################################ $PERL_INSTALL_PREFIX/bin/perl -MCPANPLUS::Backend -e"\ my \$cp = CPANPLUS::Backend->new(); \$cp->install(modules => [qw($MODULES)]); " } ############################################################ install_single_module () { ############################################################ $PERL_INSTALL_PREFIX/bin/perl -MCPANPLUS::Backend -e"\ my \$cp = CPANPLUS::Backend->new(); \$cp->install(modules => [qw($1)]); " } ############################################################ install_net_ssleay () { ############################################################ $PERL_INSTALL_PREFIX/bin/perl -MCPANPLUS::Backend -e"\ my \$cp = CPANPLUS::Backend->new(); \$cp->install(modules => [qw(Crypt::SSLeay)], makemakerflags => '$PERL_INSTALL_EXTLIB_DIR'); " } ############################################################ install_math_pari () { ############################################################ PARI_DIR=`echo $PARI_TARBALL | sed 's/.tgz//' ` $PERL_INSTALL_PREFIX/bin/perl -MCPANPLUS::Backend -e"\ my \$cp = CPANPLUS::Backend->new(); \$cp->install(modules => [qw(Math::Pari)], makemakerflags => 'paridir=$TMP_BUILD_DIR/$PARI_DIR'); " } ask "PERL_INSTALL_PREFIX" $PERL_INSTALL_PREFIX ask "TMP_BUILD_DIR" $TMP_BUILD_DIR ask "PERL_TARBALL" $PERL_TARBALL PERL_INSTALL_EXTLIB_DIR=$PERL_INSTALL_PREFIX/extlib/`uname` mkdir_if_needed $PERL_INSTALL_EXTLIB_DIR PARI_DIR=`echo $PARI_TARBALL | sed 's/.tgz//' ` install_core_perl install_cpanplus install_modules install_openssl install_net_ssleay #install_pari #install_module_manually $MATH_PARI_URL "paridir=$TMP_BUILD_DIR/$PARI_DIR" # install_gd