Skip to content

split-docs: calculate relative link paths correctly

Will Thompson requested to merge 738-fix-gtk-doc-symlink into master

split-docs: calculate relative link paths correctly

For cases where $1 has a single path component, like "man", the calculation using realpath works correctly, but it's subtly wrong when $1 is "gtk-doc/html", because the symlink path needs to be relative to "/usr/share/gtk-doc", not "/usr/share". As a result, the symbolic link at /usr/share/gtk-doc/html points to runtime/docs/gtk-doc/html, which resolves to /usr/share/gtk-doc/runtime/docs/gtk-doc/html which does not exist. The correct relative path is ../runtime/docs/gtk-doc/html, which resolves to /usr/share/runtime/docs/gtk-doc/html which exists.

Happily, ln -s has a --relative flag which works out the right relative path. This likely regressed in a8dbd2b0, before which the symlinks were absolute.

Closes #738 (closed), but is untested beyond experimenting with the commands in a VM. However, a revealing diff is:

$ git diff  a8dbd2b0dde7c5bff47255576e4cdaed6663965f^.. elements/split-docs.bst
diff --git a/elements/split-docs.bst b/elements/split-docs.bst
index 79005a59..b02700a6 100644
--- a/elements/split-docs.bst
+++ b/elements/split-docs.bst
@@ -17,7 +17,7 @@ public:
           fi
           mkdir -p "%{datadir}/runtime/docs/$(dirname "${2}")"
           mv "%{datadir}/${1}" "%{datadir}/runtime/docs/${2}"
-          ln -s "%{datadir}/runtime/docs/${2}" "%{datadir}/${1}"
+          ln -s --relative "%{datadir}/runtime/docs/${2}" "%{datadir}/${1}"
         fi
       }
       move_doc man man
Edited by Will Thompson

Merge request reports