debian swirl logo

Back to the packages list swap-cwm

#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2009, 2011, 2013 Jonas Smedegaard 
# Description: Main Debian packaging script for Cwm
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .

include /usr/share/cdbs/1/rules/upstream-tarball.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/python-distutils.mk

libpkg = python-swap
pkg = swap-cwm
cmds = cant cwm delta
manpages = $(cmds:%=debian/%.1)

DEB_UPSTREAM_URL = http://www.w3.org/2000/10/swap
DEB_UPSTREAM_PACKAGE = cwm
DEB_UPSTREAM_TARBALL_MD5 = e89a71e4f48ee5f9c89d4ba2e88f5a73

DEB_INSTALL_CHANGELOGS_ALL = doc/changes.html
DEB_INSTALL_DOCS_$(libpkg) += *.html
DEB_INSTALL_MANPAGES_$(pkg) = $(manpages)

DEB_CLEAN_EXCLUDE = README~ setup.py~

# Install directly into Python library package
DEB_PYTHON_DESTDIR = $(CURDIR)/debian/$(cdbs_curpkg)

ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
build/$(libpkg):: debian/stamp-python-check
debian/stamp-python-check: debian/python-module-stampdir/$(libpkg)
		$(MAKE) -C test post-install P="python$(cdbs_python_compile_version)"
		touch $@

clean::
		rm -rf test/,diffs test/,temp
		rm -f test/pyc-check debian/stamp-python-check
endif

# Move scripts from library to cwm package and fix hashbang
# - Strip hardcoded python version
# - Use default system Python
# (binary-fixup rule is too late for dh_pycentral dependency resolving)
common-binary-indep:: debian/$(pkg)/usr/bin
debian/$(pkg)/usr/bin: install/$(libpkg)
		mkdir -p debian/$(pkg)/usr
		mv debian/$(libpkg)/usr/bin debian/$(pkg)/usr/
		egrep -r -l -Z '^#! ?/(usr/)?(local/)?bin/(env )?python[[:print:]]*$$' debian/$(pkg)/usr/bin \
			| xargs -r -0 perl -pi -e 's,^#! ?/(usr/)?(local/)?bin/(env )?python[[:print:]]*$$,#!/usr/bin/python$(cdbs_python_compile_version),'

# Fix filename of scripts
# - strip extension
binary-post-install/$(pkg)::
		mv debian/$(cdbs_curpkg)/usr/bin/cant.py debian/$(cdbs_curpkg)/usr/bin/cant

# Strip hashbang from Python modules
binary-fixup/$(libpkg)::
		egrep -r -l -Z '^#! ?/(usr/)?(local/)?bin/(env )?python[[:print:]]*$$' debian/$(cdbs_curpkg)/usr/share/py* \
			| xargs -r -0 perl -ni -e 'print unless m,^#! ?/(usr/)?(local/)?bin/(env )?python[[:print:]]*$$,'

# generate manpage based on --help of script itself
# (using wrappers to emulate --version and provide --description)
common-post-build-indep:: $(manpages)
$(manpages): %.1 : %
		chmod +x $<
	help2man --name= "$$($< --description)" --no-info --output=$@ $<
		perl -i -0 -p \
			-e 's/^\.PP\noptions:\n\.PP$$/.SH OPTIONS/m; # fix marking options as a headline' \
			-e 's/^(\\fB\\-\\-.*?)=\\fR([^ ]*)/$$1\\fR=\\fI$$2\\fR/mg; # fix option value hilite' \
			-e 's/^(\w)$$/.B $$1/mg; # fix mode flags hilite' \
			-e 's/^\\fB\\-\\-(.*?)\\fR([^ ]*) +/.TP\n.B \\--$$1$$2\n/mg; # improve option listing' \
			-e 's/^(\.TP\n\.B.*\n[^\.].*\n)\.IP(\n\(.*)\n\.PP$$/$$1.RS$$2/mg; # keep option lines together' \
			$@

clean::
		rm -f $(manpages)

# Needed for our packaging
CDBS_BUILD_DEPENDS += help2man

# tools needs library
CDBS_DEPENDS_$(pkg) = $(libpkg)

# Needed (sometimes) at runtime
CDBS_SUGESTS_$(libpkg) = python-crypto, python-rdflib, $(pkg)
CDBS_SUGESTS_$(pkg) = python-crypto, python-rdflib, otter

Builds:

python-swap
semantic web area for play
swap-cwm
rdf/xml and rdf/n3 semantic web data processor