summaryrefslogtreecommitdiffstats
path: root/debian/convert_docs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 06:33:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 06:33:51 +0000
commit4f0770f3df78ecd5dcaefbd214f7a1415366bca6 (patch)
tree72661b8f81594b855bcc967b819263f63fa30e17 /debian/convert_docs
parentAdding upstream version 2.4.56. (diff)
downloadapache2-4f0770f3df78ecd5dcaefbd214f7a1415366bca6.tar.xz
apache2-4f0770f3df78ecd5dcaefbd214f7a1415366bca6.zip
Adding debian version 2.4.56-1~deb11u2.debian/2.4.56-1_deb11u2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/convert_docs')
-rwxr-xr-xdebian/convert_docs111
1 files changed, 111 insertions, 0 deletions
diff --git a/debian/convert_docs b/debian/convert_docs
new file mode 100755
index 0000000..b39a58f
--- /dev/null
+++ b/debian/convert_docs
@@ -0,0 +1,111 @@
+#!/usr/bin/perl -w
+
+use strict;
+use File::Path;
+use Fatal qw/mkpath symlink open close/;
+use File::Copy;
+use File::Find;
+
+
+scalar @ARGV == 1 or die;
+
+my $TGT=$ARGV[0];
+my $SRC=$TGT.".orig";
+
+move($TGT, $SRC);
+
+# list of languages
+my @lang = glob("$SRC/index.html.*") or die;
+map { s{^.*html\.}{} } @lang;
+
+# map "ja.euc-jp" to "ja/", ...
+my %lpath;
+foreach my $l (@lang) {
+ my $t=$l;
+ $t =~ s{\..*$}{};
+ $lpath{$l}="$t/";
+}
+
+my @html;
+find(sub { $File::Find::name =~ s/^$SRC\///; push(@html, $File::Find::name) if $File::Find::name =~ /\.html$/; }, $SRC);
+
+foreach my $h (@html) {
+ my $dir="";
+ if ($h =~ m{^(.*/)}) {
+ $dir=$1;
+ }
+
+ for my $l (@lang) {
+ my $tdir="$TGT/$lpath{$l}";
+ -d "$tdir$dir" || mkpath("$tdir$dir");
+
+ my $updir=$dir;
+ $updir =~ s{[^/]+}{..}g;
+ $updir .= "..";
+
+ if ($l eq "en") {
+ conv("$SRC/$h.en", "$tdir$h", $h, $updir);
+ }
+ elsif ( -f "$SRC/$h.$l" ) {
+ conv("$SRC/$h.$l", "$tdir$h", $h, $updir);
+ }
+ else {
+ symlink("$updir/en/$h", "$tdir$h");
+ }
+
+ }
+}
+
+open(my $out, ">", "$TGT/index.html");
+print $out '<html><head>',
+ '<meta http-equiv="refresh" content="0; URL=en/index.html">',
+ "</head>\n<body>\n<table>";
+foreach my $l (sort values %lpath) {
+ print $out qq{<tr><td><a href="${l}index.html">$l</a></td></tr>\n};
+}
+print $out '</table></body></html>';
+
+move("$SRC/images", "$TGT/images");
+move("$SRC/style", "$TGT/style");
+rmdir("$TGT/style/lang");
+rmdir("$TGT/style/xsl/util");
+rmdir("$TGT/style/xsl");
+rmtree("$SRC");
+
+
+### END
+
+
+sub conv {
+ my ($old, $new, $name, $updir) = @_;
+
+ open(my $in, "<", $old);
+ local $/;
+ my $file = <$in>;
+ close($in);
+
+ # /mod/ -> /mod/index.html
+ $file =~ s{href="([^:"]*/)"}{href="${1}index.html"}g;
+
+ # style and images now one level up
+ $file =~ s{(src|href)="\.\./(style|images)}{$1="../../$2}g;
+ $file =~ s{(src|href)="(?:\./)?(style|images)}{$1="../$2}g;
+
+ foreach my $l (values %lpath) {
+ # language directories one level up
+ $file =~ s{href="\.\./$l}{href="../../$l}g;
+ $file =~ s{href="(?:\./)?$l}{href="../$l}g;
+ $file =~ s{apachectl(?!\.html)}{apache2ctl}g;
+ }
+
+ # Debian tweaks
+ $file =~ s{/usr/local/apache2/conf/httpd[.]conf}{/etc/apache2/apache2.conf}g;
+ $file =~ s{httpd[.]conf}{apache2.conf}g;
+ $file =~ s{apachectl(?!\.html)}{apache2ctl}g;
+ $file =~ s{https://www.apache.org/images/SupportApache-small.png}{$updir/images/SupportApache-small.png}g;
+
+
+ open(my $out, ">", $new);
+ print $out $file;
+ close($out);
+}