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

# incl <pkg> [-pfer] <mask>
# display a list of included packages matching <mask>

sub incl
{
      local $reg_method  = \&string2reg;
      local $incl_method = \&incl_packages;
      local $getp_method = \&get_pkg_requires_all;
      local $getf_method = \&get_pkg_contains_all;
      my $pkges = $source_pkges;
	my ($pkg,$arg,$reg);
      while(defined($arg = shift))
	{
            $arg eq ''                           and next
            or &no_opt($arg)                     and (defined $pkg ? $reg = $arg : $pkg = $arg)
	      or &is_opt($arg,'f','files')         and $incl_method = \&incl_files
	      or &is_opt($arg,'p','packages')      and $incl_method = \&incl_packages
	      or	&is_opt($arg,'e','expression') and $reg_method  = \&string2preg
	      or	&is_opt($arg,'j','justone')    and $getp_method = \&get_pkg_requires
                                                 and $getf_method = \&get_pkg_contains
	      or	&is_opt($arg,'r','recurse')    and $getp_method = \&get_pkg_requires_all
                                                 and $getf_method = \&get_pkg_contains_all
            or &is_opt($arg,'h','help')          and return $heeelp -> ('incl')
            or &rem_opt($arg) and return $error{'wrong_opt'} -> ($arg,'incl --help');
      }
	return $error{'pkg_unspec'} -> () if $pkg eq '';
      eval '$reg = $reg_method -> ($reg)';
      if($@){return $error{'wrong_reg'} -> ($reg)}
      return if &read_source();
      is_pkg($pkg,$pkges) or return $error{'pkg_not_found'} -> ($pkg);
      $incl_method -> ($pkg,$reg,$pkges);
}

sub incl_packages
{
      my ($pkg,$reg,$pkges) = @_;
      my $count = 0;
      $mess -> (grep {/$reg/ and ++$count} $getp_method -> ($pkg,$pkges));
      $mess -> ("\n");
      if($tlpm_redir < 2)
      {
            $message -> (&one_or_more($count,'package','packages'));
      }
}

sub incl_files
{
      my ($pkg,$reg,$pkges) = @_;
      my $count = 0;
	$mess -> (grep {/$reg/ and ++$count} $getf_method -> ($pkg,$pkges));$mess -> ("\n");
      if($tlpm_redir < 2)
      {
            $message -> ("$count " . ($count == 1 ? "file" : "files"));
      }
}

1;