Merge branch 'master' of git://github.com/seveas/cpanspec into seveas-pull-request
This commit is contained in:
2
Build.PL
2
Build.PL
@@ -16,6 +16,7 @@ my $builder = Module::Build->new(
|
|||||||
'Getopt::Long' => 0,
|
'Getopt::Long' => 0,
|
||||||
'locale' => 0,
|
'locale' => 0,
|
||||||
'LWP::UserAgent' => 0,
|
'LWP::UserAgent' => 0,
|
||||||
|
'Module::CoreList' => 0,
|
||||||
'Module::ExtractUse' => 0,
|
'Module::ExtractUse' => 0,
|
||||||
'POSIX' => 0,
|
'POSIX' => 0,
|
||||||
'Parse::CPAN::Packages' => 0,
|
'Parse::CPAN::Packages' => 0,
|
||||||
@@ -26,7 +27,6 @@ my $builder = Module::Build->new(
|
|||||||
},
|
},
|
||||||
script_files => [
|
script_files => [
|
||||||
'cpanspec',
|
'cpanspec',
|
||||||
'cpanget',
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
1
MANIFEST
1
MANIFEST
@@ -1,5 +1,4 @@
|
|||||||
Build.PL
|
Build.PL
|
||||||
cpanget
|
|
||||||
cpanspec
|
cpanspec
|
||||||
MANIFEST This list of files
|
MANIFEST This list of files
|
||||||
META.yml
|
META.yml
|
||||||
|
|||||||
11
TODO
11
TODO
@@ -1,19 +1,8 @@
|
|||||||
* Planned features (as of 2005-09-19):
|
* 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.
|
* Add options to filter out Provides/Requires.
|
||||||
- Done, but the documentation needs work.
|
- 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
|
* Try to get cpan_home from CPAN::MyConfig or CPAN::Config instead of
|
||||||
hard-coding $pkgdetails.
|
hard-coding $pkgdetails.
|
||||||
|
|
||||||
|
|||||||
80
cpanget
80
cpanget
@@ -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:
|
|
||||||
31
cpanspec
31
cpanspec
@@ -133,6 +133,10 @@ Disttag (a string to append to the release number), used to
|
|||||||
differentiate builds for various releases. Defaults to the
|
differentiate builds for various releases. Defaults to the
|
||||||
semi-standard (for Fedora) string C<%{?dist}>.
|
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>
|
=item B<-s>, B<--srpm>
|
||||||
|
|
||||||
Build a source rpm from the generated spec file.
|
Build a source rpm from the generated spec file.
|
||||||
@@ -231,6 +235,7 @@ our $packager;
|
|||||||
our $release=1;
|
our $release=1;
|
||||||
our $epoch;
|
our $epoch;
|
||||||
our $disttag='%{?dist}';
|
our $disttag='%{?dist}';
|
||||||
|
our $download_only=0;
|
||||||
our $buildsrpm=0;
|
our $buildsrpm=0;
|
||||||
our $buildrpm=0;
|
our $buildrpm=0;
|
||||||
our $verbose=0;
|
our $verbose=0;
|
||||||
@@ -364,7 +369,7 @@ sub build_rpm($) {
|
|||||||
my $spec=shift;
|
my $spec=shift;
|
||||||
my $dir=getcwd();
|
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");
|
verbose("Building " . ($buildrpm ? "rpms" : "source rpm") . " from $spec");
|
||||||
|
|
||||||
@@ -496,8 +501,7 @@ sub get_description(%) {
|
|||||||
sub check_rpm($) {
|
sub check_rpm($) {
|
||||||
my $dep=shift;
|
my $dep=shift;
|
||||||
|
|
||||||
my $rpm="/bin/rpm";
|
my $rpm=which("rpm");
|
||||||
return undef if (!-x $rpm);
|
|
||||||
|
|
||||||
my @out=`$rpm -q --whatprovides "$dep"`;
|
my @out=`$rpm -q --whatprovides "$dep"`;
|
||||||
|
|
||||||
@@ -512,8 +516,7 @@ sub check_rpm($) {
|
|||||||
sub check_repo($) {
|
sub check_repo($) {
|
||||||
my $dep=shift;
|
my $dep=shift;
|
||||||
|
|
||||||
my $repoquery="/usr/bin/repoquery";
|
my $repoquery=which("repoquery");
|
||||||
return undef if (!-x $repoquery);
|
|
||||||
|
|
||||||
verbose("Running $repoquery to check for $dep. This may take a while...");
|
verbose("Running $repoquery to check for $dep. This may take a while...");
|
||||||
my @out=`$repoquery --whatprovides "$dep"`;
|
my @out=`$repoquery --whatprovides "$dep"`;
|
||||||
@@ -532,6 +535,15 @@ sub check_dep($) {
|
|||||||
return (check_rpm("perl($module)") || check_repo("perl($module)"));
|
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
|
# 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
|
# if using another locale. Also ensures writing out UTF8. (Thanks to
|
||||||
# Roy-Magne Mo for pointing out the problem and providing a solution.)
|
# Roy-Magne Mo for pointing out the problem and providing a solution.)
|
||||||
@@ -549,6 +561,7 @@ GetOptions(
|
|||||||
'release|r=i' => \$release,
|
'release|r=i' => \$release,
|
||||||
'epoch|e=i' => \$epoch,
|
'epoch|e=i' => \$epoch,
|
||||||
'disttag|d=s' => \$disttag,
|
'disttag|d=s' => \$disttag,
|
||||||
|
'download-only|D' => \$download_only,
|
||||||
'srpm|s' => \$buildsrpm,
|
'srpm|s' => \$buildsrpm,
|
||||||
'build|b' => \$buildrpm,
|
'build|b' => \$buildrpm,
|
||||||
'cpan|c=s' => \$cpan,
|
'cpan|c=s' => \$cpan,
|
||||||
@@ -576,7 +589,8 @@ if ($follow and $buildrpm) {
|
|||||||
|
|
||||||
my $prefix=$noprefix ? "" : "perl-";
|
my $prefix=$noprefix ? "" : "perl-";
|
||||||
|
|
||||||
$packager=$packager || `rpm --eval '\%packager'`;
|
my $rpm=which("rpm");
|
||||||
|
$packager=$packager || `$rpm --eval '\%packager'`;
|
||||||
|
|
||||||
chomp $packager;
|
chomp $packager;
|
||||||
|
|
||||||
@@ -640,6 +654,7 @@ for my $file (@args) {
|
|||||||
$source=$cpan . "/authors/id/" . $d->prefix();
|
$source=$cpan . "/authors/id/" . $d->prefix();
|
||||||
$file=basename($d->filename());
|
$file=basename($d->filename());
|
||||||
fetch($source, $file);
|
fetch($source, $file);
|
||||||
|
next if $download_only;
|
||||||
$name=$d->dist();
|
$name=$d->dist();
|
||||||
$version=$d->version();
|
$version=$d->version();
|
||||||
$version=~s/^v\.?//;
|
$version=~s/^v\.?//;
|
||||||
@@ -954,12 +969,12 @@ for my $file (@args) {
|
|||||||
if(!defined($package)) {
|
if(!defined($package)) {
|
||||||
# Don't print this for common false positives
|
# Don't print this for common false positives
|
||||||
unless($dep =~ /^(Config|base|5|lib)/) {
|
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;
|
next;
|
||||||
}
|
}
|
||||||
if($package->distribution->dist eq $name) {
|
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;
|
next;
|
||||||
}
|
}
|
||||||
$build_requires{$dep} ||= 0;
|
$build_requires{$dep} ||= 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user