in reply to Re^3: Specifying .pm files
in thread Specifying .pm files

Installing to a consistent local folder is doable but requires a bit of research, mostly because of differences between Module::Build and ExtUtils::MakeMaker.

At work I need to install a large number of modules locally as a non-root user and I quickly got tired of the manual build process. Behind the 'readmore' tags is the current version of a bash script I wrote to automate this process. After I clean it up and check for existing implementations I'll post it if people find it useful.

#!/bin/bash # usage: pminstall [-f] <tarball|directory> # Example: pminstall foo.tgz # Author: Christopher Clark <perlmonkey@gmail.com> # The actual installation is handled in do_install, the rest of this s +cript is devoted to # determining where to run the install commands. # function usage { echo "Usage: $0 <tarball|directory> <installation path>" echo "Examples:" echo " $0 Foo-1.1.tgz Bar-* ~/local" echo " $0 Foo-1.1/ ~/local" } if [ "$#" -lt "2" ]; then usage exit 1 fi function real_install { base=$1 echo if [ "$PMINSTALL_NODELAY" = "" ]; then echo -n Installing to $base/ in 3 sleep 1 && echo -ne "\b2" sleep 1 && echo -ne "\b1" echo -e "\b\b\b\b " else echo Installing to $base/ fi perl Makefile.PL PREFIX=$base LIB=$base/lib && make && make test && +make pure_install } function do_install { force=$1 file=$2 base=$3 # Exit if the specified file is neither a file nor a directory if [ ! -d "$file" -a ! -f "$file" ]; then echo "Invalid file '$file'" exit fi if [ "$base" = "" ]; then usage exit 1 fi # If the specified file is a directory we can simply change to that di +rectory and run real_install if [ -d "$file" ]; then cd $file real_install $base return fi # If the specified module is a file, then it must be unzipped if [ -f "$file" ]; then # The install should be done in a sandbox directory, in case the tar +ball doesn't have a subdirectory [ -d sandbox ] || mkdir sandbox cd sandbox # Identify the top level directory in the tarball.. this isn't a ter +ribly robust method # But it shouldn't really need to be top_dir=`tar -tzf ../$file | awk '/\// {print}' | sed 's/\/.*$//' | +sort -u` #echo "top level dir = $top_dir" # if the top level directory is empty we'll stay in the sandbox if [ "$top_dir" = "" ]; then tar -xzf ../$file # Otherwise we'll change to that directory else tar -xzf ../$file cd $top_dir fi real_install $base return; fi } ############## Actual start of the script #Find the last argument - this is our destination folder for file in $*; do dest=$file; done; if [[ ! "$dest" =~ '^/' ]]; then dest="$PWD/$dest" fi idx=1 stop=$(($# -1)) force=0 start_dir=`pwd` for file in $*; do if [ "$idx" -gt "$stop" ]; then break; fi if [ "$file" = "-f" ]; then force=1 idx=$(($idx + 1)) continue fi cd $start_dir echo -e "\n----- Installing $file to $dest/" do_install $force $file $dest idx=$(($idx + 1)) done
Update - After having my first coffee of the day I re-read the OP and noticed the 'C:\'. Bash scripts typically aren't useful on windows, so ignore this post.

Replies are listed 'Best First'.
Re^5: Specifying .pm files -- Re: Update
by rodion (Chaplain) on Aug 17, 2006 at 20:45 UTC
    But the rest of us can still use it. Thanks.