home » dokk/manpages.git
ID: 12f02b2db5a6ab8bd85a48476cf3116af450a637
35 lines — 1K — View raw


SHELL = /bin/bash
DEBIMAN_SERVING_DIR ?= ./


# This just prints out variables for displaying
vars:
	@echo "Using envvar DEBIMAN_SERVING_DIR = ${DEBIMAN_SERVING_DIR}"


# Note: the behaviour of debiman is to download all the manpages, then render them all.
# This cannot be changed. Since we're only interested in the raw manpages and not
# the HTML output, -only_render_pkgs is a hack that will make debiman render only one
# page (0ad) and quit.
download: vars
	debiman -sync_codenames="bookworm" -serving_dir="${DEBIMAN_SERVING_DIR}" -only_render_pkgs="0ad"

# Extract downloaded pages since they're compressed by default
extract: vars
	find "${DEBIMAN_SERVING_DIR}" -type f,l -name "*.gz" -exec gunzip --decompress --force --keep "{}" \;

# Convert manpages from roff to plaintext
# Manpage files are named "page.section.lang".
# TODO ! -name "stress-ng.1.en" ! -name "md.4.en"
#      this is a hack for skipping the rendering of those pages. The version of mandoc
#      in Debian is outdated and gets stuck in a infinite loop. Remove this hack if
#      using a more recent mandoc.
convert: vars
	while IFS= read -r file; do \
		echo "$${file}"; \
		cp "$${file}" "$${file}.roff"; \
		mandoc -T utf8             "$${file}" > "$${file}.roff.txt"; \
		mandoc -T html -O fragment "$${file}" > "$${file}.roff.html"; \
	done < <( find "${DEBIMAN_SERVING_DIR}" -type f -name "*.*.*" ! -name "*.gz" ! -name "*.roff" ! -name "*.txt" ! -name "*.html" ! -name "stress-ng.1.en" ! -name "md.4.en" )

.PHONY: vars download extract