Steffen Schwigon <s...@renormalist.net> wrote:

>nimectos <tt4g-x...@dea.spamcon.org> writes:
>> I want to point CPAN or some tool to the module .tar.gz files I want
>> to add, and get them installed.
>
>If you already have the .tgz files,then you just need to unpack them by
>yourself and then use “cpan .” inside such a subdir:
>
>  cd /tmp/
>  tar xzf Some-Lib.tar.gz          # or -Z/-j for unzip/bunzip2 etc.
>  cd /tmp/Some-Lib
>  cpan .
>
>Kind regards,
>Steffen 

Thank you SO much - that's the solution I needed!  I did see "cpan ." in
the man CPAN page but it immediately talks about downloading dependencies
so I'd skipped it thinking it was little different than regular cpan use.

I came up with this for my current simple needs of a handful of packages,
with no dependencies I don't already have installed, all are .tar.gz, and
I only need installs, not upgrades:

for MOD_ARCHIVE in *.tar.gz
do
    ARCH_CONTENT=`tar -xzvf $MOD_ARCHIVE 2> /dev/null`
    [ $? -ne 0 ] && echo "ERROR: Could not extract $MOD_ARCHIVE,
skipping." && continue
    ARCH_DIR=`echo "$ARCH_CONTENT" | head -1 | sed -r 's_^([^/]+)/.*_\1_'`
    [ $? -ne 0 -o "$ARCH_DIR" == "" ] && echo "ERROR: Could not determine
archive dir for $MOD_ARCHIVE, skipping." && continue
    pushd $ARCH_DIR &> /dev/null
    MOD_NAME=`grep -hP "^[ \t]+'*NAME'*[ \t]*=>" * 2> /dev/null | sed -r
"s/.*NAME.*[^']+'([^']+)'.*/\1/" | sed -r
"s/.*NAME.*.*q\[([^]]+)\].*/\1/"`
    [ $? -ne 0 -o "$MOD_NAME" == "" ] && echo "ERROR: Could not determine
module name for $MOD_ARCHIVE, skipping." && popd &> /dev/null && continue
    CHECK_CMD="use $MOD_NAME; exit 0;"
    perl -e '$CHECK_CMD' &> /dev/null
    if [ $? -eq 0 ]
    then
        echo "Already installed: $MOD_NAME"
    else
        echo "Installing: $MOD_NAME from $MOD_ARCHIVE ..."
        nice cpan . >> ../cpan-stdout.log 2>>../cpan-stderr.log
        [ $? -ne 0 ] && echo "ERROR: 'cpan .' returned error doing
$MOD_NAME, see *.log."
    fi
    popd &> /dev/null
done



Reply via email to