Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 101 lines (77 sloc) 2.008 kb
7a1df31 Initial version
Dave Cross authored
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Parse::RPM::Spec;
7
8 my $spec = shift || die "No spec given\n";
9
10 my $s = Parse::RPM::Spec->new({ file => $spec });
11
12 my $rpm_cmd = 'rpm -q --whatprovides';
13 my $repo_cmd = 'repoquery -C --whatprovides';
14 my $format = q(--queryformat='%{name}~%{version}~%{vendor}');
15
16 my (@ok, @errs);
17
18 foreach (@{$s->requires}) {
19 my ($cap, $op, $ver) = split;
20
21 my $err;
22 $err->{cap} = $cap;
23
24 next if $cap =~ /COMPAT/;
25
26 my $rpm_out = run_cmd("$rpm_cmd $format '$cap'");
27
28 if ($rpm_out =~ /no package provides/i) {
29 $err->{not_installed} = 1;
30 $err->{ver_req} = $ver;
31 } else {
32 my ($rpm_name, $rpm_ver, $rpm_vend) = split /~/, $rpm_out;
33
34 if (defined $ver) {
35 if ($rpm_ver < $ver) {
36 $err->{rpm} = $rpm_name;
37 $err->{vnd_cur} = $rpm_vend;
38 $err->{ver_cur} = $rpm_ver;
39 $err->{ver_req} = $ver;
40 } else {
41 push @ok, $cap;
42 next;
43 }
44 } else {
45 push @ok, $cap;
46 next;
47 }
48 }
49
50 my $repo_out = run_cmd("$repo_cmd $format '$cap'");
51 $repo_out =~ s/\|\|//;
52
53 unless ($repo_out) {
54 $err->{diy} = 1;
55 next;
56 }
57
58 my ($repo_name, $repo_ver, $repo_vend) = split /~/, $repo_out;
59
60 $err->{ava_rpm} = $repo_name;
61 $err->{ava_ver} = $repo_ver;
62 $err->{ava_vnd} = $repo_vend;
63
64 if (defined $ver and $ver > $repo_ver) {
65 $err->{diy} = 1;
66 }
67
68 push @errs, $err;
69 }
70
71 unless (@errs) {
72 print "All dependencies satisfied\n";
73 } else {
74 print "The following dependencies are missing:\n";
75 foreach (@errs) {
76 print $_->{cap}, "\n";
77 print "You need $_->{ver_req} of $_->{rpm}.\n";
78 if ($_->{diy}) {
79 print "You'll have to build it yourself\n";
80 if ($_->{ava_name}) {
81 print "The most recent version available is $_->{ava_ver}\n";
82 print "from $_->{ava_vnd}.\n";
83 }
84 } else {
85 print "You can get $_->{ava_rpm} version $_->{ava_ver} ",
86 "from $_->{ava_vnd}\n";
87 }
88 print "\n";
89 }
90 }
91
92 sub run_cmd {
93 my $cmd = shift;
94
95 # print "[$cmd]\n";
96
97 chomp (my $output = `$cmd`);
98
99 return $output;
100 }
Something went wrong with that request. Please try again.