Commit 4c2284e2 authored by Julien Muchembled's avatar Julien Muchembled

dist: refactoring, ship systemd services for Debian, fix section of re6stnet manpage

debian/rules is split into reusable parts for SlapOS-based packages.
parent 77c9df3b
DESTDIR = /
PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man
MANPAGELIST := $(patsubst %,docs/%,re6st-conf.1 re6st-registry.1 re6stnet.8)
NM = /etc/NetworkManager/dispatcher.d/50re6stnet
all: $(MANPAGELIST)
%.1 %.8: %.rst
rst2man $< $@
install: install-noinit
for x in daemon/*.service; \
do install -Dpm 0644 $$x $(DESTDIR)/lib/systemd/system/$${x##*/}; \
done
install-noinit: install-man
set -e $(DESTDIR)$(PREFIX) /bin/re6stnet; [ -x $$1$$2 ] || \
python2.7 setup.py install --prefix=$(PREFIX) --root=$(DESTDIR); \
install -d $$1/sbin; mv $$1$$2 $$1/sbin
install -Dpm 0644 daemon/README.conf $(DESTDIR)/etc/re6stnet/README
install -Dpm 0644 daemon/logrotate.conf $(DESTDIR)/etc/logrotate.d/re6stnet
install -Dp daemon/network-manager $(DESTDIR)$(NM)
install-man: $(MANPAGELIST)
set -e; for x in $^; \
do install -Dpm 0644 $$x $(DESTDIR)$(MANDIR)/man$${x##*.}/$${x##*/}; \
done
install-ifupdown:
set -e; for a in up down; do \
set $(DESTDIR)/etc/network/if-$$a.d/re6stnet; \
install -d $${1%/*}; \
printf '#!/bin/sh -e\n[ "$$METHOD" = NetworkManager -o "$$IFACE" = lo ] ||exec $(NM) "$$IFACE" %s\n' $$a >$$1; \
chmod +x $$1; \
done
clean:
find -name '*.pyc' -delete
rm -rf build dist re6stnet.egg-info $(MANPAGELIST)
PACKAGE = $(shell dh_listpackages)
TMP = $(CURDIR)/debian/$(PACKAGE)
INIT = $(TMP)/etc/init.d
ifdef VERSION
define CHANGELOG
$(PACKAGE) ($(VERSION)) nexedi; urgency=low
-- $(shell git var GIT_COMMITTER_IDENT |sed 's/[^>]*$$//') $(shell date -R)
endef
export CHANGELOG
.PHONY: debian/changelog
debian/changelog:
echo "$$CHANGELOG" >$@
endif
override_dh_install:
make DESTDIR=$(TMP) PREFIX=/usr install-noinit install-ifupdown
override_dh_installinit:
install -d $(INIT)
sed 's/#NAME#/re6st-registry/; s/#DEPENDS#//; s,#DAEMON_DIR#,/usr/bin,' \
<debian/init.d >$(INIT)/re6st-registry
sed 's/#NAME#/re6stnet/; s/#DEPENDS#/re6st-registry/; s,#DAEMON_DIR#,/usr/sbin,; /^case/i\
cd $$CONFDIR; $$DAEMON @$$NAME.conf --test "main_interface != '\'lo\''" ||\
case "$$1" in start) exit 0;; restart|force-reload) set stop;; esac\
' <debian/init.d >$(INIT)/re6stnet
# First install *.service then update scripts.
for x in $(INIT)/*; do set dh_installinit --name=$${x##*/} && \
chmod +x $$x && "$$@" --noscripts && "$$@" --onlyscripts; \
done
...@@ -2,7 +2,7 @@ Source: re6stnet ...@@ -2,7 +2,7 @@ Source: re6stnet
Maintainer: Julien Muchembled <jm@nexedi.com> Maintainer: Julien Muchembled <jm@nexedi.com>
Section: net Section: net
Priority: optional Priority: optional
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 7.4.3), python-docutils | python3-docutils Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 8), python-docutils | python3-docutils
Standards-Version: 3.9.1 Standards-Version: 3.9.1
Package: re6stnet Package: re6stnet
...@@ -10,4 +10,6 @@ Architecture: all ...@@ -10,4 +10,6 @@ Architecture: all
Depends: ${misc:Depends}, python (>= 2.6.6-3), python-pkg-resources, python-argparse, python-openssl (>= 0.13), openvpn (>= 2.3), babeld (= 1.6.2-nxd1), iproute2 | iproute, openssl Depends: ${misc:Depends}, python (>= 2.6.6-3), python-pkg-resources, python-argparse, python-openssl (>= 0.13), openvpn (>= 2.3), babeld (= 1.6.2-nxd1), iproute2 | iproute, openssl
Recommends: ${python:Recommends}, logrotate Recommends: ${python:Recommends}, logrotate
Suggests: ndisc6 Suggests: ndisc6
Conflicts: re6st-node
Replaces: re6st-node
Description: resilient, scalable, IPv6 network application Description: resilient, scalable, IPv6 network application
#!/bin/sh -e #!/bin/sh
set -e
[ "$DPKG_MAINTSCRIPT_PACKAGE" ] if [ "$1" = purge ]; then
# https://lists.debian.org/debian-mentors/2015/12/msg00367.html
[ "$1" = purge ] && for d in lib log; do [ -x /usr/sbin/re6stnet ] && exit
d=/var/$d/$DPKG_MAINTSCRIPT_PACKAGE for d in lib log; do
[ ! -d "$d" ] || rm -r "$d" || : d=/var/$d/re6stnet
done [ ! -d "$d" ] || rm -r "$d" || :
done
fi
#DEBHELPER# #DEBHELPER#
../daemon/re6st-registry.service
\ No newline at end of file
../daemon/re6stnet.service
\ No newline at end of file
#!/usr/bin/make -f #!/usr/bin/make -f
# -*- makefile -*- # -*- makefile -*-
# source package automatically created by stdeb 0.6.0+git
MANPAGELIST := $(patsubst %.rst, %.1, $(wildcard docs/*.rst))
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1 #export DH_VERBOSE=1
INIT=debian/re6stnet/etc/init.d VERSION = $(shell python re6st/version.py)
NM=/etc/NetworkManager/dispatcher.d/50re6stnet
.PHONY: debian/changelog
build-package: debian/changelog build-package: debian/changelog
dpkg-buildpackage -us -uc -b dpkg-buildpackage -us -uc -b
debian/changelog: include debian/common.mk
printf 're6stnet (%s) nexedi; urgency=low\n\n -- %s %s\n' \
"`python re6st/version.py`" \
"`git var GIT_COMMITTER_IDENT |sed 's/\(.*>\) .*/\\1/'`" \
"`date -R`" >debian/changelog
override_dh_auto_clean:
dh_auto_clean
rm -f $(MANPAGELIST)
%.1: %.rst
rst2man $< $@
override_dh_install:
dh_install
install -d debian/re6stnet/usr/sbin
mv debian/re6stnet/usr/bin/re6stnet debian/re6stnet/usr/sbin
install -Dpm 0644 daemon/README.conf debian/re6stnet/etc/re6stnet/README
install -Dpm 0644 daemon/logrotate.conf debian/re6stnet/etc/logrotate.d/re6stnet
install -Dp daemon/network-manager debian/re6stnet$(NM)
for a in up down; do \
set debian/re6stnet/etc/network/if-$$a.d/re6stnet; \
install -d $${1%/*}; \
printf '#!/bin/sh -e\n[ "$$METHOD" = NetworkManager -o "$$IFACE" = lo ] ||exec $(NM) "$$IFACE" %s\n' $$a >$$1; \
chmod +x $$1; \
done
override_dh_installinit:
install -d $(INIT)
sed 's/#NAME#/re6st-registry/; s/#DEPENDS#//; s,#DAEMON_DIR#,/usr/bin,' \
<debian/init.d >$(INIT)/re6st-registry
sed 's/#NAME#/re6stnet/; s/#DEPENDS#/re6st-registry/; s,#DAEMON_DIR#,/usr/sbin,; /^case/i\
cd $$CONFDIR; $$DAEMON @$$NAME.conf --test "main_interface != '\'lo\''" ||\
case "$$1" in start) exit 0;; restart|force-reload) set stop;; esac\
' <debian/init.d >$(INIT)/re6stnet
for x in re6st-registry re6stnet; \
do chmod +x $(INIT)/$$x && dh_installinit --onlyscripts --name=$$x; \
done
override_dh_installman: $(MANPAGELIST)
dh_installman $^
override_dh_python2: override_dh_python2:
dh_python2 --no-guessing-deps --depends=pyOpenSSL --recommends=miniupnpc dh_python2 --no-guessing-deps --depends=pyOpenSSL --recommends=miniupnpc
override_dh_auto_clean:
make clean
%: %:
dh $@ --with python2 --buildsystem=python_distutils dh $@ --with python2 --buildsystem=python_distutils
%define _builddir %(pwd) %define _builddir %(pwd)
%define ver %(python re6st/version.py) %define ver %(python re6st/version.py)
Summary: resilient, scalable, IPv6 network application Summary: resilient, scalable, IPv6 network application
Name: re6stnet Name: re6stnet
Version: %(set %ver; echo ${1%%-*}) Version: %(set %ver; echo ${1%%-*})
Release: %(set %ver; echo ${1#*-}) Release: %(set %ver; echo ${1#*-})
License: GPLv2+ License: GPLv2+
Group: Applications/Internet Group: Applications/Internet
BuildArch: noarch BuildArch: noarch
Requires: babeld = 1.6.2-nxd1 Requires: babeld = 1.6.2-nxd1
Requires: iproute Requires: iproute
Requires: openssl Requires: openssl
Requires: openvpn >= 2.3 Requires: openvpn >= 2.3
Requires: python >= 2.7 Requires: python >= 2.7
Requires: pyOpenSSL >= 0.13 Requires: pyOpenSSL >= 0.13
Requires: python-setuptools Requires: python-setuptools
Recommends: python-miniupnpc
Conflicts: re6st-node
%description %description
%build %build
for x in docs/*.rst make
do rst2man $x ${x%%.rst}.1
done
%install %install
set $RPM_BUILD_ROOT /lib/systemd/system set $RPM_BUILD_ROOT
python2.7 setup.py install --prefix %_prefix --root=$1 make install PREFIX=%_prefix MANDIR=%_mandir DESTDIR=$1
install -d $1%_sbindir $1%_mandir/man1 $1$2 # Exclude man pages because they will be compressed.
install -Dpm 0644 docs/*.1 $1%_mandir/man1 find $1 -mindepth 1 -path \*%_mandir -prune -o \
install -Dpm 0644 daemon/*.service $1$2 -name re6st\* -prune -printf /%%P\\n > INSTALLED
install -Dp daemon/network-manager $1/etc/NetworkManager/dispatcher.d/50re6stnet
install -Dpm 0644 daemon/README.conf $1/etc/re6stnet/README.conf
install -Dpm 0644 daemon/logrotate.conf $1/etc/logrotate.d/re6stnet
mv $1%_bindir/re6stnet $1%_sbindir
find $1 -mindepth 1 -type d -name re6st\* -printf /%%P\\n > INSTALLED
%clean %clean
find "$RPM_BUILD_ROOT" -delete rm -rf "$RPM_BUILD_ROOT" INSTALLED
rm INSTALLED
%files -f INSTALLED %files -f INSTALLED
%doc README
%_bindir/*
%_sbindir/*
%_mandir/*/* %_mandir/*/*
/lib/systemd/system/* /etc/NetworkManager
/etc/NetworkManager/dispatcher.d/50re6stnet
/etc/logrotate.d/re6stnet
%post %post
if [ $1 -eq 1 ]; then if [ $1 -eq 1 ]; then
...@@ -65,7 +54,3 @@ if [ $1 -ge 1 ] ; then ...@@ -65,7 +54,3 @@ if [ $1 -ge 1 ] ; then
# only try to restart the registry (doing same for re6stnet could be troublesome) # only try to restart the registry (doing same for re6stnet could be troublesome)
/bin/systemctl try-restart re6st-registry.service >/dev/null 2>&1 || : /bin/systemctl try-restart re6st-registry.service >/dev/null 2>&1 || :
fi fi
%changelog
* Mon Dec 10 2012 Julien Muchembled <jm@nexedi.com>
- Initial package
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment