9d9f117008bf7fbcda44ffd729e8cced1e63e848
[ossec-hids.git] / debian / rules
1 #!/usr/bin/make -f
2
3 # Uncomment this to turn on verbose mode.
4 #export DH_VERBOSE=1
5
6 # Directories
7 SRCDIR = $(CURDIR)/src
8 PKGDIR = $(CURDIR)/debian/ossec-hids
9 DESTDIR = $(PKGDIR)/var/ossec
10
11 # OSSEC INSTALL SUBDIRS
12 SUBDIRS = .ssh active-response active-response/bin agentless bin etc etc/shared logs logs/alerts logs/archives logs/firewall queue queue/agent-info queue/agentless queue/alerts queue/diff queue/fts queue/ossec queue/rids queue/rootcheck queue/syscheck rules stats tmp var var/run
13
14 ###################### main ######################
15
16 build: build-stamp
17 build-stamp:
18         dh_testdir
19         dh_clean
20
21         $(MAKE) -C $(SRCDIR) setlocal all build
22
23         touch build-stamp
24
25 build-arch: build
26 build-indep: build
27
28 clean:
29         dh_testdir
30         dh_testroot
31         rm -f build-stamp
32
33         # Add here commands to clean up after the build process.
34         $(MAKE) -C $(SRCDIR) clean
35
36         # additional clean
37         rm -f $(SRCDIR)/Config.OS \
38                 $(SRCDIR)/analysisd/compiled_rules/compiled_rules.h \
39                 $(SRCDIR)/analysisd/ossec-logtest \
40                 $(SRCDIR)/isbigendian \
41                 $(SRCDIR)/isbigendian.c \
42                 $(SRCDIR)/analysisd/ossec-makelists
43         rm -rf $(CURDIR)/bin
44
45         dh_clean
46
47 install: build
48         dh_testdir
49         dh_testroot
50         dh_prep
51         dh_installdirs
52
53         # ugly directory creation
54         for i in $(SUBDIRS); do \
55                 mkdir -p -m 700 $(DESTDIR)/$$i; \
56         done
57
58         # various files installation
59         install -m 644 etc/internal_options.conf $(DESTDIR)/etc
60         install -m 644 etc/decoder.xml $(DESTDIR)/etc
61         install -m 644 src/rootcheck/db/*.txt $(DESTDIR)/etc/shared
62         if [ -e ossec-debian.conf ]; then \
63                 install -m 440 ossec-debian.conf $(DESTDIR)/etc/ossec.conf; \
64         else \
65                 install -m 440 etc/ossec-local.conf $(DESTDIR)/etc/ossec.conf; \
66         fi
67         install -m 440 etc/ossec-*.conf $(DESTDIR)/etc
68         cp -r etc/rules/* $(DESTDIR)/rules
69         install -m 750 src/agentlessd/scripts/* $(DESTDIR)/agentless
70         install -s -m 755 bin/* $(DESTDIR)/bin
71         install -m 755 src/init/ossec-*.sh $(DESTDIR)/bin
72         ln -s ossec-local.sh $(DESTDIR)/bin/ossec-control
73         install -m 755 active-response/*.sh $(DESTDIR)/active-response/bin
74         install -m 755 active-response/firewalls/*.sh \
75                 $(DESTDIR)/active-response/bin
76
77         # attrs
78         chmod -R 550 $(DESTDIR)
79         chmod -R 770 $(DESTDIR)/queue/alerts
80         chmod -R 770 $(DESTDIR)/queue/ossec
81         chmod -R 750 $(DESTDIR)/queue/fts
82         chmod -R 750 $(DESTDIR)/queue/syscheck
83         chmod -R 750 $(DESTDIR)/queue/rootcheck
84         chmod -R 750 $(DESTDIR)/queue/diff
85         chmod -R 755 $(DESTDIR)/queue/agent-info
86         chmod -R 755 $(DESTDIR)/queue/rids
87         chmod -R 755 $(DESTDIR)/queue/agentless
88         chmod -R 750 $(DESTDIR)/stats
89         chmod -R 750 $(DESTDIR)/logs
90         chmod -R 550 $(DESTDIR)/rules
91         chmod 770 $(DESTDIR)/var/run
92         chmod 550 $(DESTDIR)/etc
93         chmod 440 $(DESTDIR)/etc/internal_options.conf
94         chmod -R 770 $(DESTDIR)/etc/shared
95         chmod 700 $(DESTDIR)/.ssh
96         chmod 755 $(DESTDIR)/active-response/bin/*
97         chmod 550 $(DESTDIR)/bin/*
98         chmod 440 $(DESTDIR)/etc/ossec.conf
99
100         # fixups: no need for execute bits on files there
101         find $(DESTDIR)/rules -type f -exec chmod ugo-x '{}' ';'
102         find $(DESTDIR)/etc -type f -exec chmod ugo-x '{}' ';'
103
104         # system init script
105         mkdir -p $(PKGDIR)/etc/init.d
106         if [ -e ossec-hids-debian.init ]; then \
107                 install -m 755 ossec-hids-debian.init \
108                         $(PKGDIR)/etc/init.d/ossec-hids; \
109         else \
110                 install -m 755 src/init/ossec-hids.init \
111                         $(PKGDIR)/etc/init.d/ossec-hids; \
112         fi
113
114         # system ossec-init
115         echo "DIRECTORY=\"/var/ossec\""      >  $(PKGDIR)/etc/ossec-init.conf
116         echo "VERSION=\"`cat src/VERSION`\"" >> $(PKGDIR)/etc/ossec-init.conf
117         echo "DATE=\"$(shell date --utc -d "$(shell dpkg-parsechangelog | sed -ne 's/Date: //p')")\""   >> $(PKGDIR)/etc/ossec-init.conf
118         echo "TYPE=\"local\""                >> $(PKGDIR)/etc/ossec-init.conf
119
120 # Build architecture-independent files here.
121 binary-indep: build install
122 # We have nothing to do by default.
123
124 # Build architecture-dependent files here.
125 binary-arch: build install
126         dh_testdir
127         dh_testroot
128         dh_installchangelogs
129         dh_installdocs
130 #       dh_installexamples
131 #       dh_installmenu
132 #       dh_installdebconf
133 #       dh_installlogrotate
134 #       dh_installemacsen
135 #       dh_installcatalogs
136 #       dh_installpam
137 #       dh_installmime
138 #       dh_installinit
139 #       dh_installcron
140 #       dh_installinfo
141 #       dh_undocumented
142         dh_lintian
143         dh_installman
144         dh_link
145         dh_compress
146         dh_fixperms
147 #       dh_perl
148 #       dh_python
149         dh_installdeb
150         dh_shlibdeps
151         dh_gencontrol
152         dh_md5sums
153         dh_builddeb
154
155 binary: binary-indep binary-arch
156 .PHONY: build clean binary-indep binary-arch binary install