#!/usr/bin/perl -w # Adjust links in the po/maint hierarchy. # Copyright © 1996, 1997, 1998, 1999, 2000 Progiciels Bourbeau-Pinard inc. # François Pinard , 1996. BEGIN { unshift @INC, "$ENV{'HOME'}/po"; } use Po::Registry; use strict; $ENV{'PATH'} = '/usr/local/bin:/usr/bin'; chdir $podir or die "Cannot change to $podir: $!\n"; print "set -e\n"; print "cd $podir\n"; ## Make an inventory of all PO files, keep those with highest versions. my %po; open LIST, 'cd trans && find * -type f |' or die "Cannot list PO files\n"; while () { chop; if (/^(.*)\/($DOMAIN)-($VERSION)\.($TEAM?)\.po(~?)$/o && $1 eq $4) { next if $5; my ($domain, $team, $version) = ($2, $1, $3); if (! defined $po{"$domain-$team"} || &compare_versions ($version, $po{"$domain-$team"}) > 0) { $po{"$domain-$team"} = $version; } } else { warn "Not recognized as a PO file name: trans/$_\n"; } } close LIST; ## Make an inventory of all maintainer links. open LIST, 'cd maint && find * -type l |' or die "Cannot list maintainer files\n"; while () { chop; if (/^($DOMAIN)\/($TEAM).po$/) { my ($domain, $team) = ($1, $2); $_ = readlink "maint/$domain/$team.po"; if (/\.\.\/\.\.\/trans\/($TEAM)\/($DOMAIN)-($VERSION)\.($TEAM)\.po$/o && $1 eq $team && $2 eq $domain && $4 eq $team) { my $version = $3; if (! defined $po{"$domain-$team"}) { print "\n"; print "rm maint/$domain/$team.po\n"; } else { if ($po{"$domain-$team"} ne $version) { my $new_version = $po{"$domain-$team"}; print "\n"; print "rm maint/$domain/$team.po\n"; print "# Was $_\n"; print "ln -s ../../teams/PO/$team/$domain-$new_version.$team.po maint/$domain/$team.po\n"; } delete $po{"$domain-$team"}; } } else { warn "Symbolic link not valid: maint/$domain/$team.po\n"; } } else { warn "Not recognized as a maintainer file name: $_\n"; } } close LIST; ## Create missing links. my $po; print "\n" if %po; foreach $po (sort keys %po) { my ($domain, $team) = $po =~ /^($DOMAIN)-(.*)/; my $version = $po{$po}; print "ln -s ../../teams/PO/$team/$domain-$version.$team.po maint/$domain/$team.po\n"; } exit 0;