summaryrefslogtreecommitdiff
path: root/Master/setuptl/TLPM/check.pm
blob: b5273b8cd31dce6ff0de4b6f55647493a33566ad (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
67
# This file belongs to TLPM v2.16, TeX Live Package Manager
# Public Domain, P.Jackowski@gust.org.pl

# check [-pf]
# check the existence of files and packages

sub check
{
    my $arg;
    local $tl_target_new;
    $check_method = \&check_pkges;
    while(defined($arg = shift))
      {
        $arg eq ''                           and next
            or &is_opt($arg,'f','files')     and $check_method = \&check_files
            or &is_opt($arg,'p','packages')  and $check_method = \&check_pkges
            or &is_opt($arg,'d','directory') and do {$tl_target_new = shift;1}
            or &is_opt($arg,'h','help')      and return $heeelp -> ('check')
            or &rem_opt($arg)                and return $error{'wrong_opt'} -> ($arg,'check --help');
      }# force reading the target, even if already defined
      $tl_target_new ||= $tl_target;
      $tl_target_indeed = $false;
      return if &read_target();
      return if &open_log();
      $check_method -> ();
      &close_log();
}

sub check_files
{
      my ($fcount,$pcount) = (0,0);
      my $pkg;
      my @miss;
      foreach $pkg (&get_pkg_all($target_pkges))
      {
            @miss = grep {not(-f "$tl_target$chr_dirsep$_")} &get_pkg_contains($pkg,$target_pkges);
            next unless scalar @miss;
            ++$pcount;
            $fcount += scalar @miss;
            $messf -> ($row_fmt . "missing %s\n",$pkg,join(",\n" . ' ' x ($row_skip + 8),@miss));
      }
      if($tlpm_redir < 2)
      {
            $message -> (&one_or_more($fcount,'missing file','missing files') . ' in ' .
                         &one_or_more($pcount,'package','packages'));
      }
}

sub check_pkges
{
      my $pcount = 0;
      my $pkg;
      my @miss;
      foreach $pkg (&get_pkg_all($target_pkges))
      {
            @miss = &get_pkg_miss($pkg,$target_pkges);
            next unless scalar @miss;
            ++$pcount;
            $messf -> ($row_fmt . "missing %s\n",$pkg,join(",\n" . ' ' x ($row_skip + 8),@miss));
      }
      if($tlpm_redir < 2)
      {
            $message -> ("$pcount missing " . ($pcount == 1 ? "package" : "packages"));
      }
}

1;