[Pkg-privacy-commits] [pond] 02/03: automatically generate manpages using help2man

Ximin Luo infinity0 at debian.org
Tue Oct 6 10:55:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository pond.

commit f26b19cdbe2ef00ea6318d65b26ccb0628f6f0c1
Author: Ximin Luo <infinity0 at debian.org>
Date:   Tue Oct 6 12:30:30 2015 +0200

    automatically generate manpages using help2man
---
 debian/control    |  3 ++-
 debian/man-helper | 17 +++++++++++++++++
 debian/mk-manpage | 19 +++++++++++++++++++
 debian/rules      | 12 ++++++++++++
 4 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index 1875b37..d910f50 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,8 @@ Build-Depends: debhelper (>= 9), dh-golang, golang-go,
  golang-go.crypto-dev,
  golang-goprotobuf-dev,
  golang-golang-x-net-dev,
- libtspi-dev
+ libtspi-dev,
+ help2man
 Standards-Version: 3.9.6
 Homepage: https://github.com/agl/pond
 Vcs-Git: https://anonscm.debian.org/git/pkg-privacy/packages/pond.git
diff --git a/debian/man-helper b/debian/man-helper
new file mode 100755
index 0000000..6eb5d1a
--- /dev/null
+++ b/debian/man-helper
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -e
+
+case $1 in
+--help)
+	$H2M_TARGET 2>&1 "--help" | {
+		read x;
+		echo "Usage: $(basename "$H2M_TARGET") [options]"
+		echo;
+		echo "Options:"
+		cat
+	};
+	;;
+--version)
+	echo "$H2M_VERSION"
+	;;
+esac
diff --git a/debian/mk-manpage b/debian/mk-manpage
new file mode 100755
index 0000000..972ec42
--- /dev/null
+++ b/debian/mk-manpage
@@ -0,0 +1,19 @@
+#!/bin/sh
+set -e
+
+test -d debian || exit 1
+
+bin="$GOPATH/bin/$1"
+name="$1"
+NAME="$(echo "$1" | tr a-z A-Z)"
+desc="$2"
+
+H2M_TARGET="$bin" \
+  help2man -N -n "$desc" \
+  debian/man-helper > "debian/$name.1"
+
+sed -e "s/man-helper/$name/g" \
+    -e "s/MAN-HELPER/$NAME/g" \
+    -i "debian/$name.1"
+
+echo "debian/$name.1" >> debian/manpages
diff --git a/debian/rules b/debian/rules
index daa4805..0856880 100755
--- a/debian/rules
+++ b/debian/rules
@@ -36,11 +36,19 @@ export DH_GOPKG_SUBDIRS := $(shell find . \
 # https://cryptojedi.org/crypto/#dclxvi not yet in Debian, so disable bn256cgo
 export DH_GOPKG_TESTDATA := client editstate
 
+MKMAN = H2M_VERSION=$(DEB_VERSION_UPSTREAM) GOPATH=$(DH_BUILDDIR) debian/mk-manpage
+
 %:
 	dh $@ --buildsystem=golang --with=golang
 
 override_dh_auto_build:
 	cd $(DH_BUILDDIR) && GOPATH=$$PWD go install $(GOFLAGS) -v $(DH_GOPKG_SUBDIRS:%=$(DH_GOPKG)/%)
+	for i in $(POND_BIN_RENAME); do ln -s $$i $(DH_BUILDDIR)/bin/pond-$$i; done
+	rm -f debian/manpages
+	$(MKMAN) pond-client "run a pond client"
+	$(MKMAN) pond-editstate "edit a pond state file"
+	$(MKMAN) pond-server "run a pond server"
+	for i in $(POND_BIN_RENAME); do rm $(DH_BUILDDIR)/bin/pond-$$i; done
 
 override_dh_auto_test:
 	cp -R --parents -t $(DH_BUILDDIR)/src/$(DH_GOPKG) $(DH_GOPKG_TESTDATA:%=%/testdata)
@@ -50,3 +58,7 @@ override_dh_auto_install:
 	dh_auto_install
 	rm -rf $(DH_INSTALLDIR)/usr/share/gocode
 	for i in $(POND_BIN_RENAME); do mv $(DH_INSTALLDIR)/usr/bin/$$i $(DH_INSTALLDIR)/usr/bin/pond-$$i; done
+
+override_dh_auto_clean:
+	dh_auto_clean
+	rm -f debian/*.1 debian/manpages

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/pond.git



More information about the Pkg-privacy-commits mailing list