aboutsummaryrefslogtreecommitdiffstats
path: root/make_links.pl
blob: d94a41fe2dd29f23d5344290a78460276d287557 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -w

# This script creates any missing soft links in the Debian html
# directory on master. These links are necessary so that under content
# negotiation there is a default language.
# Translators shouldn't have any need of this.

# For every <file>.html.en there needs to be a <file>.html -> <file>.html.en

$top_dir = "/debian2/web/debian.org";

check_directory($top_dir);

sub check_directory() {
	my ($curdir) = @_;
	my (@dir_list, @fil_list, @parts, $lang, $html, $name);

	opendir(DIR, $curdir) or die "can't opendir $curdir: $!";
	@dir_list = grep { -d "$curdir/$_" and $_ !~ /^..?$/ } readdir(DIR);
	rewinddir DIR;
	@fil_list = grep { -f "$curdir/$_" } readdir(DIR);
	foreach (@dir_list) {
		check_directory("$curdir/$_");
	}
	foreach $file (@fil_list) {
		@parts = split('\.', $file);
		$lang = pop @parts;
		$html = pop @parts;
		$name = join('.', @parts);
		if (defined($html) and $lang =~ /^en$/ and $html eq "html") {
			if ( ! -e "$curdir/$name.html") {
				symlink("$file", "$curdir/$name.html");
				print "  creating symlink to $file\n";
			}
		}
	}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy