Check the search path for rpm, rpmbuild, etc.

This commit is contained in:
Dennis Kaarsemaker committed 2011-08-31 21:00:26 +02:00
1 parent f3017f18fc
commit 8eb8dc287f
2 files changed
+14 -9

No files matched your search

-3
View File
@@ -3,9 +3,6 @@
* 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.
* 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.
+14 -6
View File
@@ -369,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");
@@ -501,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"`;
@@ -517,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"`;
@@ -537,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.)
@@ -582,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;