diff options
author | Peter Karlsson <peterk> | 2004-03-25 07:58:23 +0000 |
---|---|---|
committer | Peter Karlsson <peterk> | 2004-03-25 07:58:23 +0000 |
commit | 0436a454c0edaae5a0208d1e166863f00accb4ca (patch) | |
tree | fc0e5734f3f9c6e18a1be129788aee78cdbba917 /remove_stale.pl | |
parent | d032eb22b7d9a6116650a6e40d3060c5b94e8b44 (diff) |
When removing one installed HTML file, touch all the related translated WML
files so that the next build will update the list of translated languages
not to include the removed language.
CVS version numbers
remove_stale.pl: 1.11 -> 1.12
Diffstat (limited to 'remove_stale.pl')
-rwxr-xr-x | remove_stale.pl | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/remove_stale.pl b/remove_stale.pl index 89a29383d84..5abcbd3aa94 100755 --- a/remove_stale.pl +++ b/remove_stale.pl @@ -24,8 +24,16 @@ unless (-d 'english' && getopts('d')) exit; } +# Read the list of languages +my @languages = readlanguages('Makefile'); + # Recurse. -my $files = &recurse('.') || 'No'; +my $files = 0; +foreach my $language (@languages) +{ + $files += &recurse("./$language"); +} +$files ||= 'No'; print "\n$files stale translations found.\n"; print "Use -d option to remove files.\n" if $files ne 'No' && !$opt_d; @@ -133,6 +141,11 @@ sub recurse my $extra = $installed; $extra =~ s/\.no\.html$/.nb.html/; + # Check for translations to other languages, they + # need to have their .wml file touched + my @translations = (); + @translations = &findtranslations($source); + # Remove or report. if ($opt_d) { @@ -161,6 +174,15 @@ sub recurse or die "Unable to remove $icslocal: $!\n"; } + # Touch translation sources to update the list of + # translations on them + foreach my $translation (@translations) + { + print "Touching $translation\n"; + system('/usr/bin/touch', $translation) == 0 + or warn "touch: error code $?"; + } + print "Removing $direntry\n"; unlink $direntry or die "Unable to remove $direntry: $!\n"; @@ -177,6 +199,10 @@ sub recurse if -f $icsinstalled; print " local ICS file: $icslocal\n" if -f $icslocal; + foreach my $translation (@translations) + { + print " translation in $translation\n"; + } } } } @@ -195,3 +221,48 @@ sub recurse return $count; } + +# Read the list of active languages from the Makefile +sub readlanguages +{ + my $source = shift; + my (@languages, $langsrc); + open MAKE, '<', $source or die "Cannot read $source: $!\n"; + LANGUAGES: while (<MAKE>) + { + if (/LANGUAGES := (.*)/) + { + $langsrc = $1; + while ($langsrc =~ /\\$/) + { + my $nextline = <MAKE>; + chomp $nextline; + $langsrc =~ s/\\$/$nextline/; + } + } + } + close MAKE; + + return split /\s+/, $langsrc; +} + +# Locate all translated copies of this wml file +sub findtranslations +{ + my $wml = shift; + my @files; + + # Remove the first component of the path (which contains the + # current language) + my $tail = $wml; + $tail =~ s(^\./[^/]+/)(); + + # Locte all translated copies + foreach my $language (@languages) + { + my $translated = "./$language/$tail"; + push @files, $translated if -f $translated; + } + + return @files; +} |