]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix it so that relative file links work
authorAlan T. DeKok <aland@freeradius.org>
Tue, 29 Jan 2019 16:03:19 +0000 (11:03 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 29 Jan 2019 16:03:19 +0000 (11:03 -0500)
Makefile
scripts/asciidoc/conf2adoc

index ef5574aefdef4ca0c7e30134258cc09af6df822d..5ad59029278e185484c71a2eb14985393535ff1c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -363,7 +363,7 @@ asciidoc/%.adoc: raddb/%.md
 asciidoc/%.adoc: raddb/%
        @echo ADOC $^
        @mkdir -p $(dir $@)
-       @./scripts/asciidoc/conf2adoc -a ${top_srcdir}/asciidoc < $^ > $@
+       @./scripts/asciidoc/conf2adoc -a ${top_srcdir}/asciidoc -o $@ < $^
 
 asciidoc/%.html: asciidoc/%.adoc
        @echo HTML $^
index 436f1c963459278b12406ae66e9468acccba0f2b..afeb12d4e5a0859a74ebcf65272c5aad70f0dfb7 100755 (executable)
@@ -6,13 +6,14 @@
 #
 #
 use File::Basename;
+use File::Spec;
 use Getopt::Std;
 
 $was_raw = 0;
 $raw = 0;
 $blank = 0;
 
-getopts('a:');
+getopts('a:o:');
 
 $script_dir = dirname(__FILE__);
 $filename = "$script_dir/links.txt";
@@ -39,7 +40,13 @@ $links{"mods-available/"} = "$opt_a/mods-available/README.adoc";
 
 sub process_file {
        my $input = shift;
-       my $output = shift;
+       my $output_file = shift;
+
+       if (!defined $output_file) {
+           $output = STDOUT;
+       } else {
+           open $output, ">$output_file" or die "Failed creating $output_file: $!\n";
+       }
 
        while (<$input>) {
                #
@@ -147,6 +154,21 @@ sub process_file {
 
                        if ($links{$key} =~ /^http/) {
                                $link = "`link:" . $links{$key} . "[" . $key . "]`";
+
+                       } elsif ($links{$key} =~ /^$opt_a/) {
+                               #
+                               #  Link to the *relative* path for the file.
+                               #  Note that we're passed "-a foo/asciidoc",
+                               #  and also an output file of "asciidoc/bar.adoc"
+                               #  So we need to strip out one level of "asciidoc/"
+                               #
+                               my $absdir = dirname($opt_a . "/" . $output_file);
+                               $absdir =~ s,asciidoc/asciidoc,asciidoc/,;
+
+                               my $relative = File::Spec->abs2rel($links{$key}, $absdir);
+
+                               $link = "link:" . $relative . "[" . $key . "]";
+
                        } else {
                                $link = "<<" . $links{$key} . "," . $key . ">>";
                        }
@@ -192,4 +214,4 @@ if (!defined $opt_a) {
        $opt_a = "";
 }
 
-process_file(STDIN, STDOUT);
+process_file(STDIN, $opt_o);