Files
cpanspec/cpanget
stevenpritchard 4825c92807 * Make sure $] is numeric before we use it with Module::CoreList.
* Switch from wget to curl in cpanget since wget is broken in Fedora 9.
2008-04-25 20:18:41 +00:00

76 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
set -e
CPAN=${CPAN:-"http://www.cpan.org"}
packages=$HOME/.cpan/sources/modules/02packages.details.txt.gz
quiet=''
only_url=0
help() {
cat <<END
Usage: $( basename $0 ) [options] [module [module [...]]]
Options:
-h Print this message
-n Don't download, only print URLs
-q Work quietly
END
}
for n in "$@" ; do
if [ "$( echo '' "$n" | sed 's/^ //;s/^\(.\).*$/\1/' )" = "-" ] ; then
shift
for arg in $( echo '' "$n" | sed 's/^ //;s/^-//;s/./ &/g' ) ; do
case $arg in
[h?])
help
exit 0
;;
n)
only_url=1
;;
q)
quiet='-s'
;;
*)
echo "Unknown option '$arg'."
help
exit 1
;;
esac
done
else
break
fi
done
if [ $# -eq 0 ] ; then
help
exit 1
fi
mkdir -p $( dirname $packages )
curl $quiet -R -o $packages $CPAN/modules/$( basename $packages )
for module in "$@" ; do
tar=$( zgrep '^'$module' ' $packages | awk '{print $3}' )
if [ -z "$tar" ] ; then
echo "Can't find $module, skipping..." >&2
continue
fi
if [ $only_url -eq 0 ] ; then
curl $quiet -R -o "$( basename $tar )" $CPAN/authors/id/$tar
else
echo "$module: $CPAN/authors/id/$tar"
fi
done
# vi: set ai et: