summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tl-print-dependencies
blob: 2a18a9dd5360b04a89360b1f103daf11b104fd38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env perl
# $Id$
# Originally written by Norbert Preining and Karl Berry, 2015.  Public domain.
# 
# Recursively give dependencies of a given package

my $vc_id = '$Id$';
my $Master;

BEGIN {
  chomp ($mydir = `dirname $0`);  # we are in Master/tlpkg/bin
  unshift (@INC, "$mydir/..");
}

use TeXLive::TLPDB;
use TeXLive::TLUtils;

my $prg = TeXLive::TLUtils::basename($0);

my @print_packages;
my $tlpdb;
my %done;

exit (&main());


sub main {
  chomp ($Master = `cd $mydir/../.. && pwd`);
  $tlpdb = TeXLive::TLPDB->new ("root" => $Master);
  die "Cannot find tlpdb in $Master!" unless defined $tlpdb;

  @print_packages = @ARGV;
  print_next();
  exit(0);
}

sub print_next {
  return if (!@print_packages);
  my $pkg = shift @print_packages;
  # skip packages we have already printed
  if (!$done{$pkg}) {
    my $tlp = $tlpdb->get_package($pkg);
    if ($tlp) {
      # mark as done
      $done{$pkg} = 1;
      my @deps = $tlp->depends;
      # drop .ARCH deps
      @deps = grep(!/\.ARCH$/, @deps);
      # only print a line when there are deps
      if (@deps) {
        push @print_packages, @deps;
        print "$pkg: @deps\n";
      }
    } else {
      print "$pkg: MISSING\n";
    }
  }
  print_next();
}

# Local Variables:
# perl-indent-level: 2
# tab-width: 2
# indent-tabs-mode: nil
# End:
# vim: sw=2 expandtab