meson: fix build/man/{man,html} to support page redirects

Commands like build/man/man journald.conf.d would show the installed
man page (or an error if the page cannot be found in the global search
path), and not the one in the build directory. If the man page is
a redirect, or the .html is a symlink, resolve it, build the target,
and show that.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-08-07 18:42:22 +02:00
parent 7eac7b4c62
commit 4338ab8163
2 changed files with 20 additions and 2 deletions

View File

@ -11,5 +11,14 @@ ninja -C "@BUILD_ROOT@" version.h
target="man/$1.html"
ninja -C "@BUILD_ROOT@" "$target"
fullname="@BUILD_ROOT@/$target"
redirect="$(readlink "$fullname" 2>/dev/null)"
if [ -n "$redirect" ]; then
ninja -C "@BUILD_ROOT@" "man/$redirect"
fullname="@BUILD_ROOT@/man/$redirect"
fi
set -x
exec xdg-open "@BUILD_ROOT@/$target"
exec xdg-open "$fullname"

View File

@ -16,4 +16,13 @@ if [ -z "$target" ]; then
exit 1
fi
ninja -C "@BUILD_ROOT@" "$target"
exec man "@BUILD_ROOT@/$target"
fullname="@BUILD_ROOT@/$target"
redirect="$(sed -n -r '1 s|^\.so man[0-9]/(.*)|\1|p' "$fullname")"
if [ -n "$redirect" ]; then
ninja -C "@BUILD_ROOT@" "man/$redirect"
fullname="@BUILD_ROOT@/man/$redirect"
fi
exec man "$fullname"