at master 1.2 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell -i zsh -p zsh 3set -euo pipefail 4 5# cd into nixpkgs' root, get the store path of `systemd.man` 6cd "$(dirname "$0")/../../.." 7SYSTEMD_MAN_DIR="$(nix-build -A systemd.man)/share/man" 8 9# For each manual section 10for section in {1..8}; do 11 sec_dir="${SYSTEMD_MAN_DIR}/man${section}" 12 13 # skip section 3 (library calls) 14 ! [[ $section -eq 3 ]] || continue 15 16 # for each manpage in that section (potentially none) 17 for manpage in ${sec_dir}/*(N); do 18 # strip the directory prefix and (compressed) manpage suffix 19 page="$(basename "$manpage" ".${section}.gz")" 20 21 # if this is the manpage of a service unit 22 if [[ "$page" =~ ".*\.service" ]]; then 23 # ... and a manpage exists without the `.service` suffix 24 potential_alias="${sec_dir}/${page%\.service}.${section}.gz" 25 ! [[ -e "${potential_alias}" && 26 # ... which points to the same file, then skip 27 "$(gunzip -c "${potential_alias}")" == ".so ${page}.${section}" ]] || continue 28 fi 29 30 # else produce a JSON fragment, with the link to the upstream manpage (as HTML) 31 echo " \"${page}(${section})\": \"https://www.freedesktop.org/software/systemd/man/${page}.html\"," 32 done 33done