summaryrefslogtreecommitdiff
path: root/Master/tlpkg/libexec/place
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-11-05 23:42:37 +0000
committerKarl Berry <karl@freefriends.org>2011-11-05 23:42:37 +0000
commitce341d8d9d57f279d0730262b2db30d370cebaa4 (patch)
tree935e28f19eb513a27e79ed36c851136355afee3d /Master/tlpkg/libexec/place
parentf9b4593f28389832c5573550b53b9e5569163cf8 (diff)
remove newly-empty directories
git-svn-id: svn://tug.org/texlive/trunk@24519 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/libexec/place')
-rwxr-xr-xMaster/tlpkg/libexec/place39
1 files changed, 37 insertions, 2 deletions
diff --git a/Master/tlpkg/libexec/place b/Master/tlpkg/libexec/place
index ae88853fee9..73c212205af 100755
--- a/Master/tlpkg/libexec/place
+++ b/Master/tlpkg/libexec/place
@@ -64,7 +64,7 @@ if (-d "texmf-dist") { $Type = "Package"; }
elsif (-d "texmf") { $Type = "TLCore"; }
else { die "$cooked_master: no top level texmf or texmf-dist"; }
-die "top-level README in $Root, that can't be right" if <*/README>;
+die "top-level README under $TOP, that can't be right" if <*/README>;
# get all files in the existing package, if there is one.
# In the unusual case when we have both Master and Build, we'll assume
@@ -115,6 +115,7 @@ my ($new_build_files,$existing_build_files) = &build_files ($cooked_pkg,$DEST);
my @new_build_files = @$new_build_files;
# Figure out removals relative to old package.
+my %dirs_with_removals;
&xchdir ($cooked_master);
find (\&files, "."); # sets %New to all new files under Master
foreach $file (sort keys %Old) {
@@ -128,6 +129,8 @@ foreach $file (sort keys %Old) {
# remove no longer existing files.
if (! $New{$file}) {
&xsystem ("svn remove $M/$file");
+ (my $old_dir = "$M/$file") =~ s,/[^/]*$,,;
+ $dirs_with_removals{$old_dir}++;
}
my $dname = dirname ("$M/$file");
@@ -160,6 +163,18 @@ if (keys %Old == 0) { # new package
# this file will often change, so be sure and include it.
$dirs{"$M/tlpkg/tlpsrc/$package.tlpsrc"}++;
+# Now that all the files have been added, look for newly-empty
+# directories in the previous package incarnation. We can only do this
+# when not chicken, since otherwise the old files will still exist and
+# the directories will not be empty.
+if (! $chicken) {
+ for my $empty_dir (&empty_dirs (keys %dirs_with_removals)) {
+ &xsystem ("cd $M && svn remove $empty_dir # empty dir");
+ # already in %dirs, so don't need to add.
+ }
+}
+
+
# include any directories with existing files in Build.
for my $bf (@$existing_build_files) {
(my $dir = $bf) =~ s,/[^/]*$,,;
@@ -391,7 +406,27 @@ sub build_files {
-sub files { # subroutine for &find, updating %New.
+# return list of empty (except for .svn) DIRS.
+#
+sub empty_dirs {
+ my (@dirs) = @_;
+ my @ret = ();
+
+ for my $d (@dirs) {
+ opendir (DIR, $d) || die "opendir($d) failed: $!";
+ my @dirents = readdir (DIR);
+ closedir (DIR) || warn "closedir($d) failed: $!";
+ my @remainder = grep { $_ !~ /^\.(|\.|svn)$/ } @dirents;
+ push (@ret, $d) if @remainder == 0;
+ }
+ return @ret;
+}
+
+
+
+# subroutine for &find, updating the global %New.
+#
+sub files {
if (-f || -l) { # consider files and symlinks
my $This = $File::Find::name;
$This =~ s,^\./,,; # omit leading ./