gitman

Export manpages from git repositories
git clone git://jacobedwards.org/gitman
Log | Files | Refs | README | LICENSE

commit 24a670864bc7f735aae8aa9ce9203125094203f0
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Sun, 26 Oct 2025 11:43:32 -0500

Initial commit

This adds a fully functional script, manual, README and LICENSE.

Diffstat:
ALICENSE | 13+++++++++++++
AREADME | 22++++++++++++++++++++++
Agitman | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Agitman.1 | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 175 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2025 Jacob R. Edwards <jacob@jacobedwards.org> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIE +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README b/README @@ -0,0 +1,22 @@ +gitman +====== + +The gitman project was specifically designed for hosting manpages +on a website using OpenBSD's man.cgi, but it would be easy to use +for other applications as well. + +It should work on Linux too, although using makewhatis(8) might not +make sense in that environment since it appears to be a central +database. + +Setting up man.cgi +------------------ + +To setup man.cgi, download the OpenBSD source tree to /usr/src and +go to /usr/src/usr.bin/mandoc/. Then follow the instructions in the +Makefile: + + # To configure, run: cp cgi.h.example cgi.h; vi cgi.h + # To build, run: make man.cgi + # To install, run: sudo make installcgi + # After that, read: man man.cgi.8 diff --git a/gitman b/gitman @@ -0,0 +1,70 @@ +#!/bin/sh +# +# Copyright (c) 2025 Jacob R. Edwards <jacob@jacobedwards.org> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +set -e + +while test $# -gt 0 +do + case "$1" in + (-d) prefix="${2:?-d requires an argument}"; shift ;; + (-*) echo 'usage: gitman [-d dir] [repo ...]' 1>&2; exit 1 ;; + (--) shift; break ;; + (*) break ;; + esac + shift +done + +if test -z "$prefix"; then + if test -e /etc/gitman; then + prefix="$(</etc/gitman)" + else + prefix=. + fi +fi + +gitls() { + git ls-tree --full-tree -r HEAD +} + +gitman() { + s="${1##*.}" + sprefix="$2"/man$s + mkdir -p "$sprefix" + name="$(basename "$1")" + path="$sprefix"/"$name" + git show HEAD:"$1" > "$path" + echo "$path" +} + +case "$(uname)" in +(OpenBSD) makewhatis() { command makewhatis -d "$prefix" "$@" ;} ;; +esac + +pages="$( + for d in "${@:-"${GIT_DIR:?No repositories given}"}" + do + GIT_DIR="$d" + export GIT_DIR + for f in $(gitls | awk '/\.[0-9]$/ { print $NF }') + do + gitman "$f" "$prefix" + done + done +)" +IFS=' +' +makewhatis $pages +echo "$pages" diff --git a/gitman.1 b/gitman.1 @@ -0,0 +1,70 @@ +./" +./" Copyright (c) 2025 Jacob R. Edwards <jacob@jacobedwards.org> +./" +./" Permission to use, copy, modify, and distribute this software for any +./" purpose with or without fee is hereby granted, provided that the above +./" copyright notice and this permission notice appear in all copies. +./" +./" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIE +./" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +./" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +./" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +./" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +./" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +./" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +./" +.Dd October 26, 2025 +.Dt GITMAN 1 +.Os +.Sh NAME +.Nm gitman +.Nd Export manpages from git repositories +.Sh SYNOPSIS +.Nm +.Op Fl d Ar dir +.Op Ar repo ... +.Sh DESCRIPTION +The +.Nm +utility writes manpages found in the given git repositories (or +.Ev GIT_DIR +if none are specified) to the prefix +directory, then updates it's +.Pa mandoc.db +with +.Xr makewhatis 8 . +.Pp +The options are described below: +.Bl -tag -width Ds +.It Fl d Ar dir +Set the export directory for manpages. Defaults to the contents of +.Pa /etc/gitman , +or the current working directory if it doesn't exist. +.El +.Sh FILES +.Bl -tag -width Ds +.It Pa /etc/gitman +The default export directory if +.Fl d +isn't specified. +.El +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +.Pp +Write the manpages +from the repositories under +.Pa ~/git/ +to +.Pa /var/www/man/main +along with a +.Xr makewhatis 8 +database: +.Pp +.Dl $ gitman -d /var/www/man/main ~/git/* +.Sh SEE ALSO +.Xr git-ls-tree 1 , +.Xr git-show 1 , +.Xr makewhatis 8 +.Sh AUTHORS +.An Jacob R. Edwards Aq Mt jacob@jacobedwards.org