home » dokk/manpages.git
ID: cc4485f3f3f9a707159fbff911b1a229a2ea5134
43 lines — 2K — View raw


SHELL = /bin/bash

# The mirror to download from
MIRROR ?=

# The path where debiman will save files.
DEBIMAN_SERVING_DIR ?=

# Name of the distribution to be processed
CODENAME ?=

# This just prints out variables for displaying
vars:
	@echo "MIRROR=${MIRROR}"
	@echo "CODENAME=${CODENAME}"
	@echo "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 -remote_mirror="${MIRROR}" -sync_codenames="${CODENAME}" -sync_suites= -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 other formats
# Manpage files are named "page.section.lang".
# TODO ! -name "stress-ng.1.en" ! -name "md.4.en"
#      this is a hack for skipping the parsing 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 convert