diff --git a/Build.PL b/Build.PL index 0866b9b..a13258e 100644 --- a/Build.PL +++ b/Build.PL @@ -16,6 +16,7 @@ my $builder = Module::Build->new( 'Getopt::Long' => 0, 'locale' => 0, 'LWP::UserAgent' => 0, + 'Module::CoreList' => 0, 'Module::ExtractUse' => 0, 'POSIX' => 0, 'Parse::CPAN::Packages' => 0, @@ -26,7 +27,6 @@ my $builder = Module::Build->new( }, script_files => [ 'cpanspec', - 'cpanget', ], ); diff --git a/MANIFEST b/MANIFEST index 5bf91fa..7025e97 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,5 +1,4 @@ Build.PL -cpanget cpanspec MANIFEST This list of files META.yml diff --git a/TODO b/TODO index 56b783e..2d6600b 100644 --- a/TODO +++ b/TODO @@ -1,19 +1,8 @@ * 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. - -* It would be useful to be able to write the spec to stdout. - * Add options to filter out Provides/Requires. - Done, but the documentation needs work. -* Do a better job of detecting scripts in the package. - -* Check the search path for rpm, rpmbuild, etc. instead of hard-coding - paths. - * Try to get cpan_home from CPAN::MyConfig or CPAN::Config instead of hard-coding $pkgdetails. diff --git a/cpanget b/cpanget deleted file mode 100755 index 90b39f6..0000000 --- a/cpanget +++ /dev/null @@ -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 <&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: diff --git a/cpanspec b/cpanspec index 3e4325e..1dc5e47 100755 --- a/cpanspec +++ b/cpanspec @@ -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; @@ -364,7 +369,7 @@ sub build_rpm($) { my $spec=shift; my $dir=getcwd(); - my $rpmbuild=(-x "/usr/bin/rpmbuild" ? "/usr/bin/rpmbuild" : "/bin/rpm"); + my $rpmbuild=which("rpmbuild","rpm"); verbose("Building " . ($buildrpm ? "rpms" : "source rpm") . " from $spec"); @@ -496,8 +501,7 @@ sub get_description(%) { sub check_rpm($) { my $dep=shift; - my $rpm="/bin/rpm"; - return undef if (!-x $rpm); + my $rpm=which("rpm"); my @out=`$rpm -q --whatprovides "$dep"`; @@ -512,8 +516,7 @@ sub check_rpm($) { sub check_repo($) { my $dep=shift; - my $repoquery="/usr/bin/repoquery"; - return undef if (!-x $repoquery); + my $repoquery=which("repoquery"); verbose("Running $repoquery to check for $dep. This may take a while..."); my @out=`$repoquery --whatprovides "$dep"`; @@ -532,6 +535,15 @@ sub check_dep($) { return (check_rpm("perl($module)") || check_repo("perl($module)")); } +sub which(@) { + for my $bin (@_) { + for my $path (split /:/, $ENV{PATH}) { + return "$path/$bin" if -x "$path/$bin"; + } + } + die("Cannot find " . join(" or ", @_)); +} + # Set locale to en_US.UTF8 so that dates in changelog will be correct # if using another locale. Also ensures writing out UTF8. (Thanks to # Roy-Magne Mo for pointing out the problem and providing a solution.) @@ -549,6 +561,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, @@ -576,7 +589,8 @@ if ($follow and $buildrpm) { my $prefix=$noprefix ? "" : "perl-"; -$packager=$packager || `rpm --eval '\%packager'`; +my $rpm=which("rpm"); +$packager=$packager || `$rpm --eval '\%packager'`; chomp $packager; @@ -640,6 +654,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\.?//; @@ -954,12 +969,12 @@ for my $file (@args) { if(!defined($package)) { # Don't print this for common false positives unless($dep =~ /^(Config|base|5|lib)/) { - print STDERR "Module not on CPAN, not adding dependency: $dep\n"; + verbose("Module not on CPAN, not adding dependency: $dep\n"); } next; } if($package->distribution->dist eq $name) { - print STDERR "Dependency $dep provided by ourselves, not adding dependency\n"; + verbose("Dependency $dep provided by ourselves, not adding dependency\n"); next; } $build_requires{$dep} ||= 0;