summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 56eb6ed244bf9dbf1d5038439d04926c0b2ad5b3 (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/make -f
# debian/rules for samhain
# Copyright (C) 2001 to 2016 by Javier Fernandez-Sanguino

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This is the debhelper compatability version to use.
# export DH_COMPAT=5

# Disable dnmalloc for most architectures except for
# those known to work (i386 and amd64).
# For more information see:
# http://www.la-samhna.de/samhain/manual/dnmalloc.html
ifeq (linux,$(DEB_HOST_ARCH_OS))
ifeq (amd64,$(DEB_HOST_ARCH))
DNMALLOC = --enable-dnmalloc
else ifeq (i386,$(DEB_HOST_ARCH))
DNMALLOC = --enable-dnmalloc
else
DNMALLOC = --disable-dnmalloc
endif
else
ifeq (amd64,$(DEB_HOST_ARCH))
DNMALLOC = --enable-dnmalloc
else ifeq (i386,$(DEB_HOST_ARCH))
DNMALLOC = --enable-dnmalloc
else
DNMALLOC = --disable-dnmalloc
endif
endif

ifeq (x86_64,$(DEB_HOST_GNU_CPU))
DISABLE_ASM = --disable-asm
endif

%:
	dh $@ --with-autoreconf

override_dh_auto_configure:
	./configure --prefix=/usr --mandir=\$${prefix}/share/man \
		--with-config-file=/etc/samhain/samhainrc \
		--with-state-dir=/var/lib/samhain  \
		--with-prelude \
		$(DNMALLOC) \
		$(DISABLE_ASM) \
		--enable-network=no  \
		--enable-login-watch \
		--enable-mounts-check \
		--enable-logfile-monitor \
		--enable-process-check \
		--enable-port-check \
		--enable-suidcheck \
		--with-pid-file=/var/run/samhain/samhain.pid \
		--with-log-file=/var/log/samhain/samhain.log 

override_dh_clean:
	[ ! -f Makefile ] || $(MAKE) distclean
	-rm -f samhainrc.install
	-rm -f build-stamp build-server-stamp build-client-stamp
	dh_clean


override_dh_installdirs:
	dh_installdirs
	# Fix the permissions
	chmod o-rX `pwd`/debian/samhain/var/log/samhain \
		`pwd`/debian/samhain/var/lib/samhain \
		`pwd`/debian/samhain/etc/samhain

override_dh_install:
	$(MAKE) install install-boot DESTDIR=`pwd`/debian/samhain
	# However, remove the rc.d links
	-rm -rf `pwd`/debian/samhain/etc/rc?.d
	# Remove /var/run/samhain from the package, it is created by the init script
	-rm -rf `pwd`/debian/samhain/var/run/samhain


override_dh_installdocs:
	dh_installdocs
	[ -f debian/samhain/usr/share/doc/samhain/MANUAL-2_4.html.tar ] && \
		cd debian/samhain/usr/share/doc/samhain && \
		tar xf MANUAL-2_4.html.tar && mv MANUAL-2_4 manual.html && \
		rm -f MANUAL-2_4.html.tar

override_dh_installinit:
	dh_installinit -- defaults 19

override_dh_installchangelogs:
	dh_installchangelogs docs/Changelog

# TODO: create install targets for client and server
# Builds the server (Yule)
# See http://www.la-samhna.de/samhain/manual/yule.html
build-server: build-server-stamp
build-server-stamp:
	dh_testdir
	./configure --prefix=/usr --mandir=\$${prefix}/share/man \
		--with-config-file=/etc/yule/yulerc \
		--with-state-dir=/var/lib/yule  \
		--with-prelude \
		$(DNMALLOC) \
		--enable-network=server  \
		--enable-login-watch \
		--enable-mounts-check \
		--enable-logfile-monitor \
		--enable-process-check \
		--enable-port-check \
		--enable-suidcheck \
		--with-pid-file=/var/run/samhain/yule.pid \
		--with-log-file=/var/log/samhain/yule.log 
	$(MAKE)
	touch build-server-stamp

# Build the Samhain client 
build-client: build-client-stamp
build-client-stamp:
	dh_testdir
	./configure --prefix=/usr --mandir=\$${prefix}/share/man \
		--with-config-file=/etc/samhain/samhainrc \
		--with-state-dir=/var/lib/samhain  \
		--with-prelude \
		$(DNMALLOC) \
		--enable-network=client \
		--enable-login-watch \
		--enable-mounts-check \
		--enable-logfile-monitor \
		--enable-process-check \
		--enable-port-check \
		--enable-suidcheck \
		--with-pid-file=/var/run/samhain/samhain.pid \
		--with-log-file=/var/log/samhain/samhain.log 
	$(MAKE)
	touch build-client-stamp


get-orig-source:
	@echo "Retrieving source"
	wget -q -O samhain-current.tar.gz  http://la-samhna.de/samhain/samhain-current.tar.gz
	@echo "Extracting source"
	tar -zxf samhain-current.tar.gz
	@echo "Verifying source"
	# Take the latest version
	file=`tar -ztf samhain-current.tar.gz |grep -v asc | head -1`; \
	gpgfile=`tar -ztf samhain-current.tar.gz |grep asc | head -1`; \
	newfile=`echo $$file | sed -e 's/-/_/; s/\.tar/.orig.tar/'`; \
	mv $$file $$newfile; \
	gpg -q --verify $$gpgfile $$newfile 
	rm -f samhain-current.tar.gz