summaryrefslogtreecommitdiff
path: root/debian/rules
blob: d1da11e69bdf119e48836d3e74b2a7faf0247d3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/make -f
#export DH_VERBOSE=1

# TODO
# without -pie build fails during perl module build somehow...
export DEB_BUILD_MAINT_OPTIONS := hardening=+all,-pie
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

LIB_VERSION = 30
UPSTREAM_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ':' | sed 's/ //' | sed 's/~dfsg.*$$//')
COMPAT_VERSION = $(UPSTREAM_VERSION)~dfsg
PYTHON_VERSION = 1.0a1

MIB_MODULES = smux ucd-snmp/dlmod mibII/mta_sendmail disman/event-mib
EXCL_MIB_MODULES =

OLD_MIBS_DIR="/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp"
MIBS_DIR="/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf"

ifeq (linux,$(DEB_BUILD_ARCH_OS))
MIB_MODULES += ucd-snmp/diskio ucd-snmp/lmsensorsMib etherlike-mib/dot3StatsTable
IPV6 = --enable-ipv6
DEB_DH_GENCONTROL_ARGS=-- -Vos-specific-dev="libsensors4-dev"
else
ifeq (kfreebsd,$(DEB_BUILD_ARCH_OS))
IPV6 = --disable-ipv6
DEB_DH_GENCONTROL_ARGS=-- -Vos-specific-dev="libkvm-dev"
endif
endif
ifeq (hurd,$(DEB_BUILD_ARCH_OS))
IPV6 = --enable-ipv6
EXCL_MIB_MODULES += mibII
else
MIB_MODULES += host
endif

%:
	dh $@ --with autotools-dev,autoreconf,python2

override_dh_auto_configure:
	dh_auto_configure -- --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \
	  --with-persistent-directory=/var/lib/snmp \
	  --enable-ucd-snmp-compatibility \
	  --enable-shared --with-cflags="$(CFLAGS) -DNETSNMP_USE_INLINE" \
	  --with-ldflags="$(LDFLAGS)" \
	  --with-perl-modules="INSTALLDIRS=vendor" --enable-as-needed \
	  $(IPV6) --with-logfile=none \
	  --without-rpm --with-libwrap --with-openssl \
	  --without-dmalloc --without-efence --without-rsaref \
	  --with-sys-contact="root" --with-sys-location="Unknown" \
	  --with-mib-modules="$(MIB_MODULES)" \
	  --with-out-mib-modules="$(EXCL_MIB_MODULES)" \
	  --enable-mfd-rewrites \
	  --with-mnttab=/etc/mtab \
	  --with-mibdirs="\$$HOME/.snmp/mibs:$(MIBS_DIR):$(OLD_MIBS_DIR)" \
	  --with-mysql \
	  --with-defaults
# --with-python-modules=""  # don't specify it, since dh_python2 cannot handle it.
# --with-dnssec-local-validation  # not enabled since libval doesn't exist in Debian yet

override_dh_clean:
	dh_clean
	rm -rf `find . -name .libs` \
	       python/build         \
	       python/netsnmp_python.egg-info

override_dh_strip:
	dh_strip -plibsnmp$(LIB_VERSION) --dbg-package=libsnmp$(LIB_VERSION)-dbg
	dh_strip

override_dh_makeshlibs:
	dh_makeshlibs -plibsnmp$(LIB_VERSION) -V"libsnmp$(LIB_VERSION) (>= $(COMPAT_VERSION))"

override_dh_install:
	cd python; python setup.py build --basedir=$(CURDIR) ; \
		   python setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb --basedir=$(CURDIR) ; \
		   find $(CURDIR) -name *.pyc -delete
	install $(CURDIR)/EXAMPLE.conf $(CURDIR)/debian/snmpd/etc/snmp/snmpd.conf
	dh_install

override_dh_installdocs:
	dh_installdocs --link-doc=libsnmp$(LIB_VERSION) \
		       -plibsnmp-dev \
		       -plibsnmp$(LIB_VERSION)-dbg \
		       -ppython-netsnmp \
		       -psnmpd \
		       -psnmptrapd \
		       -psnmp
	dh_installdocs  -plibsnmp-perl -ptkmib -plibsnmp-base
	# dh_installdocs has a bug when --link-doc is called it don't install copyright file to referenced package
	# so specify to copy it
	install -d $(CURDIR)/debian/libsnmp$(LIB_VERSION)/usr/share/doc/libsnmp$(LIB_VERSION)/
	install -m644 debian/copyright $(CURDIR)/debian/libsnmp$(LIB_VERSION)/usr/share/doc/libsnmp$(LIB_VERSION)/

override_dh_fixperms:
	dh_fixperms
	chmod -x debian/libsnmp-dev/etc/snmp/*.conf
	chmod 600 debian/snmpd/etc/snmp/snmp*d.conf

override_dh_auto_test:
	# prevent test since it fails with network configuration under pbuilder/etc.
	true

get-orig-source:
	@uscan --download-version $(UPSTREAM_VERSION) --destdir /tmp --force-download --no-symlink
	@tar xf /tmp/net-snmp-$(UPSTREAM_VERSION).tar.gz -C /tmp
	@rm -rf /tmp/net-snmp-$(UPSTREAM_VERSION)/doc
	@cd /tmp/net-snmp-$(UPSTREAM_VERSION)/mibs; \
	 grep ^iana ianalist | while read iana mibs; do rm -f `echo $$mibs | sed -e s/$$/.txt/`; done; \
	 cat rfclist | while read rfc mibs; do rm -f `echo $$mibs | sed 's/:/.txt /g' | sed 's/$$/.txt/'`; done
	@rm -f /tmp/net-snmp-$(UPSTREAM_VERSION)/mibs/RFC-1215.txt
	@cd /tmp; tar cJf net-snmp_$(COMPAT_VERSION).orig.tar.xz net-snmp-$(UPSTREAM_VERSION)
	@rm -rf /tmp/net-snmp-$(UPSTREAM_VERSION)