Import from cpanspec project
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Module::Build;
|
||||
|
||||
my $builder = Module::Build->new(
|
||||
dist_name => 'cpanspec',
|
||||
license => 'perl',
|
||||
dist_author => 'Steven Pritchard <steve@cpan.org>',
|
||||
dist_version_from => 'cpanspec',
|
||||
requires => {
|
||||
'Archive::Tar' => 0,
|
||||
'Archive::Zip' => 0,
|
||||
'IO::Uncompress::Bunzip2' => 0,
|
||||
'File::Basename' => 0,
|
||||
'FileHandle' => 0,
|
||||
'Getopt::Long' => 0,
|
||||
'locale' => 0,
|
||||
'LWP::UserAgent' => 0,
|
||||
'POSIX' => 0,
|
||||
'Parse::CPAN::Packages' => 0,
|
||||
'Pod::Simple::TextContent' => 0,
|
||||
'Pod::Usage' => 0,
|
||||
'Text::Autoformat' => 0,
|
||||
'YAML' => 0,
|
||||
},
|
||||
script_files => [
|
||||
'cpanspec',
|
||||
'cpanget',
|
||||
],
|
||||
);
|
||||
|
||||
$builder->create_build_script();
|
||||
|
||||
# vi: set ai et:
|
||||
@@ -0,0 +1,75 @@
|
||||
#!/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:
|
||||
Reference in New Issue
Block a user