summaryrefslogtreecommitdiff
path: root/systems/texlive/tlnet/tlpkg/TeXLive
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-09-16 03:01:00 +0000
committerNorbert Preining <norbert@preining.info>2023-09-16 03:01:00 +0000
commit659df224f4771e4390206a6663bcb78808d99767 (patch)
tree16bff62285b3a2dec0d2ca12822d819edc7ae3e6 /systems/texlive/tlnet/tlpkg/TeXLive
parentdeda1937c52481b2259e1061840b99e18e8ca361 (diff)
CTAN sync 202309160300
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/TeXLive')
-rw-r--r--systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm27
-rw-r--r--systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm77
2 files changed, 74 insertions, 30 deletions
diff --git a/systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm b/systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm
index 3bac015450..d19c812cfb 100644
--- a/systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm
+++ b/systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm
@@ -1,4 +1,4 @@
-# $Id: TLPDB.pm 65964 2023-02-20 17:13:02Z karl $
+# $Id: TLPDB.pm 68283 2023-09-15 13:11:11Z preining $
# TeXLive::TLPDB.pm - tlpdb plain text database files.
# Copyright 2007-2023 Norbert Preining
# This file is licensed under the GNU General Public License version 2
@@ -7,7 +7,7 @@
use strict; use warnings;
package TeXLive::TLPDB;
-my $svnrev = '$Revision: 65964 $';
+my $svnrev = '$Revision: 68283 $';
my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown";
sub module_revision { return $_modulerevision; }
@@ -2107,14 +2107,27 @@ sub remove_package {
0, # tlpdbopt_desktop_integration, desktop part
$localtlpdb->option("post_code"));
}
- #
- my @removals = &TeXLive::TLUtils::removed_dirs (@goodfiles);
+ # we want to check whether we can actually remove files
+ # there might be various reasons that this fails, like texmf-dist
+ # directory suddently becoming ro (for whatever definition of
+ # suddenly).
+ my (%by_dirs, %removed_dirs) = &TeXLive::TLUtils::all_dirs_and_removed_dirs (@goodfiles);
+ my @removals = keys %removed_dirs;
+
+ # we have already check for the existence of the dirs returned
+ for my $d (keys %by_dirs) {
+ if (! &TeXLive::TLUtils::dir_writable($d)) {
+ tlwarn("TLPDB: directories are not writable, cannot remove files: $d\n");
+ return 0;
+ }
+ }
+
# now do the removal
for my $entry (@goodfiles) {
- unlink $entry;
+ unlink $entry or tlwarn("Could not unlink $entry: $!\n");
}
for my $d (@removals) {
- rmdir $d;
+ rmdir $d or tlwarn("Could not remove directory $d: $!\n")
}
$localtlpdb->remove_tlpobj($pkg);
TeXLive::TLUtils::announce_execute_actions("disable", $tlp);
@@ -3000,4 +3013,4 @@ GNU General Public License Version 2 or later.
### tab-width: 2
### indent-tabs-mode: nil
### End:
-# vim:set tabstop=2 expandtab autoindent: #
+# vim:set tabstop=2 shiftwidth=2 expandtab autoindent: #
diff --git a/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm b/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm
index c8b1260fcb..30d53ad7c7 100644
--- a/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm
+++ b/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm
@@ -1,4 +1,4 @@
-# $Id: TLUtils.pm 66420 2023-03-07 08:30:26Z preining $
+# $Id: TLUtils.pm 68283 2023-09-15 13:11:11Z preining $
# TeXLive::TLUtils.pm - the inevitable utilities for TeX Live.
# Copyright 2007-2023 Norbert Preining, Reinhard Kotucha
# This file is licensed under the GNU General Public License version 2
@@ -8,7 +8,7 @@ use strict; use warnings;
package TeXLive::TLUtils;
-my $svnrev = '$Revision: 66420 $';
+my $svnrev = '$Revision: 68283 $';
my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown";
sub module_revision { return $_modulerevision; }
@@ -59,6 +59,8 @@ C<TeXLive::TLUtils> - TeX Live infrastructure miscellany
TeXLive::TLUtils::copy($file, $target_dir);
TeXLive::TLUtils::touch(@files);
TeXLive::TLUtils::collapse_dirs(@files);
+ TeXLive::TLUtils::all_dirs_and_removed_dirs(@files);
+ TeXLive::TLUtils::dirs_of_files(@files);
TeXLive::TLUtils::removed_dirs(@files);
TeXLive::TLUtils::download_file($path, $destination);
TeXLive::TLUtils::setup_programs($bindir, $platform);
@@ -210,6 +212,8 @@ BEGIN {
&copy
&touch
&collapse_dirs
+ &all_dirs_and_removed_dirs
+ &dirs_of_files
&removed_dirs
&install_package
&install_packages
@@ -1614,30 +1618,14 @@ sub collapse_dirs {
return @ret;
}
-=item C<removed_dirs(@files)>
-
-Returns all the directories from which all content will be removed.
-
-Here is the idea:
-
-=over 4
-
-=item create a hashes by_dir listing all files that should be removed
- by directory, i.e., key = dir, value is list of files
-
-=item for each of the dirs (keys of by_dir and ordered deepest first)
- check that all actually contained files are removed
- and all the contained dirs are in the removal list. If this is the
- case put that directory into the removal list
-
-=item return this removal list
+=item C<dirs_of_files(@files)>
-=back
+Returns all the directories in which at least one of the given
+files reside.
=cut
-sub removed_dirs {
+sub dirs_of_files {
my (@files) = @_;
- my %removed_dirs;
my %by_dir;
# construct hash of all directories mentioned, values are lists of the
@@ -1663,6 +1651,21 @@ sub removed_dirs {
$by_dir{$d} = \@a;
}
+ return %by_dir;
+}
+
+=item C<all_dirs_and_removed_dirs(@files)>
+
+Returns all the directories for files and those from which all
+content will be removed.
+
+=cut
+
+sub all_dirs_and_removed_dirs {
+ my (@files) = @_;
+ my %removed_dirs;
+ my %by_dir = dirs_of_files(@files);
+
# for each of our directories, see if we are removing everything in
# the directory. if so, return the directory; else return the
# individual files.
@@ -1698,9 +1701,37 @@ sub removed_dirs {
$removed_dirs{$d} = 1;
}
}
+ return (%by_dir, %removed_dirs);
+}
+
+=item C<removed_dirs(@files)>
+
+Returns all the directories from which all content will be removed.
+
+Here is the idea:
+
+=over 4
+
+=item create a hashes by_dir listing all files that should be removed
+ by directory, i.e., key = dir, value is list of files
+
+=item for each of the dirs (keys of by_dir and ordered deepest first)
+ check that all actually contained files are removed
+ and all the contained dirs are in the removal list. If this is the
+ case put that directory into the removal list
+
+=item return this removal list
+
+=back
+=cut
+
+sub removed_dirs {
+ my (@files) = @_;
+ my (%by_dir, %removed_dirs) = all_dirs_and_removed_dirs(@files);
return keys %removed_dirs;
}
+
=item C<time_estimate($totalsize, $donesize, $starttime)>
Returns the current running time and the estimated total time
@@ -5275,4 +5306,4 @@ GNU General Public License Version 2 or later.
### tab-width: 2
### indent-tabs-mode: nil
### End:
-# vim:set tabstop=2 expandtab: #
+# vim:set tabstop=2 shiftwidth=2 expandtab: #