summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/rdeps119
1 files changed, 119 insertions, 0 deletions
diff --git a/bin/rdeps b/bin/rdeps
new file mode 100755
index 0000000..83578f6
--- /dev/null
+++ b/bin/rdeps
@@ -0,0 +1,119 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+rdeps - List ProteanOS package reverse dependencies
+
+=cut
+
+use strict;
+use warnings;
+no indirect;
+use autovivification;
+use English qw(-no_match_vars);
+
+use LWP::Simple;
+use POSIX qw(strftime);
+
+my $SOURCE_URL = 'http://git.proteanos.com/depsdot/depsdot.git/';
+my $BASE_URL = 'http://files.proteanos.com/pub/proteanos/feeds/dev/trunk';
+my @DEP_FIELDS = qw(Build-Depends Depends Recommends Suggests Pre-Depends);
+
+my @rdeps;
+
+sub read_list
+{
+ my ($list, $dep, $is_src) = @_;
+
+ foreach my $para (split(m{\n\n}, get($list))) {
+ my $package = undef;
+ my $source = undef;
+ my @deps;
+ foreach my $line (split(m{\n}, $para)) {
+ my ($name, $value) = split(m{\s*:\s*}, $line);
+ if ($name eq 'Package') {
+ $package = $value;
+ }
+ if ($name eq 'Source') {
+ $source = $value;
+ }
+ if (grep(m{^\Q$name\E$}, @DEP_FIELDS)) {
+ push(@deps, split(m{\s*,\s*}, $value));
+ }
+ }
+ next if not defined($source);
+ map({ $_ =~ s{[\s(].*$}{}; } @deps); # Vim: )
+ if (grep(m{^\Q$dep\E$}, @deps) and not
+ grep(m{^\Q$source\E$}, @rdeps)) {
+ push(@rdeps, $source);
+ }
+ }
+
+ return;
+}
+
+sub usage
+{
+ my ($fh) = @_;
+
+ $fh->printf("Usage: %s <pkg>\n", $PROGRAM_NAME);
+
+ return;
+}
+
+sub main
+{
+ my $dep;
+ my @manifest;
+
+ if ($#ARGV lt 0) {
+ usage(*STDERR);
+ return 1;
+ }
+ $dep = $ARGV[0];
+
+ @manifest = split(m{\n}, get($BASE_URL . '/Manifest'));
+ foreach my $aps (@manifest) {
+ read_list($BASE_URL . '/' . $aps . '/Packages', $dep,
+ ($aps =~ m{^src/}));
+ }
+ STDOUT->print(join("\n", sort(@rdeps)));
+
+ return 0;
+}
+
+exit(main());
+
+__END__
+
+=head1 SYNOPSIS
+
+B<rdeps>
+
+=head1 DESCRIPTION
+
+B<rdeps> lists the source packages providing build- and run-time dependencies of
+a ProteanOS binary package.
+
+=head1 OUTPUT
+
+B<rdeps> writes a list of source packages to standard output.
+
+=head1 COPYRIGHT
+
+Copyright (C) 2019-2020 Patrick McDermott
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+=cut