Add --download-only to replace cpanget

This commit is contained in:
Dennis Kaarsemaker
2011-08-31 20:42:46 +02:00
parent 73d854d3b3
commit f3017f18fc
3 changed files with 7 additions and 84 deletions
-4
View File
@@ -1,9 +1,5 @@
* Planned features (as of 2005-09-19):
- Download from CPAN automatically when executed as "cpanspec Foo::Bar".
+ DONE!
+ Add --download-only or something similar to replace cpanget.
* Add options to filter out Provides/Requires.
- Done, but the documentation needs work.
-80
View File
@@ -1,80 +0,0 @@
#!/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 )
[ -z "$quiet" ] && echo "Fetching $( basename $packages )..." >&2
curl $quiet -R -z $packages -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
[ -z "$quiet" ] && echo "Fetching $tar..." >&2
curl $quiet -R \
-z "$( basename $tar )" \
-o "$( basename $tar )" \
$CPAN/authors/id/$tar
else
echo "$module: $CPAN/authors/id/$tar"
fi
done
# vi: set ai et:
+7
View File
@@ -133,6 +133,10 @@ Disttag (a string to append to the release number), used to
differentiate builds for various releases. Defaults to the
semi-standard (for Fedora) string C<%{?dist}>.
=item B<-D>, B<--download-only>
Only download the upstream tarball, do not generate a specfile
=item B<-s>, B<--srpm>
Build a source rpm from the generated spec file.
@@ -231,6 +235,7 @@ our $packager;
our $release=1;
our $epoch;
our $disttag='%{?dist}';
our $download_only=0;
our $buildsrpm=0;
our $buildrpm=0;
our $verbose=0;
@@ -549,6 +554,7 @@ GetOptions(
'release|r=i' => \$release,
'epoch|e=i' => \$epoch,
'disttag|d=s' => \$disttag,
'download-only|D' => \$download_only,
'srpm|s' => \$buildsrpm,
'build|b' => \$buildrpm,
'cpan|c=s' => \$cpan,
@@ -640,6 +646,7 @@ for my $file (@args) {
$source=$cpan . "/authors/id/" . $d->prefix();
$file=basename($d->filename());
fetch($source, $file);
next if $download_only;
$name=$d->dist();
$version=$d->version();
$version=~s/^v\.?//;