summaryrefslogtreecommitdiff
path: root/Master/setuptl/TLPM/check.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/setuptl/TLPM/check.pm')
-rw-r--r--Master/setuptl/TLPM/check.pm67
1 files changed, 67 insertions, 0 deletions
diff --git a/Master/setuptl/TLPM/check.pm b/Master/setuptl/TLPM/check.pm
new file mode 100644
index 00000000000..9000369dd3b
--- /dev/null
+++ b/Master/setuptl/TLPM/check.pm
@@ -0,0 +1,67 @@
+# This file belongs to TLPM v2.14, TeX Live Package Manager
+# Public Domain, P.Jackowski@gust.org.pl
+
+# check [-pf]
+# check the installation consistency
+
+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;