- #10234: debian/rules clean
[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 = logs logs/archives logs/alerts logs/firewall bin queue queue/ossec queue/alerts queue/syscheck queue/rids queue/fts queue/syscheck queue/rootcheck queue/diff queue/agent-info queue/agentless tmp var var/run etc etc/shared stats rules active-response active-response/bin agentless .ssh
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 clean:
26         dh_testdir
27         dh_testroot
28         rm -f build-stamp
29
30         # Add here commands to clean up after the build process.
31         $(MAKE) -C $(SRCDIR) clean
32
33         # additional clean
34         rm -f $(SRCDIR)/Config.OS \
35                 $(SRCDIR)/analysisd/compiled_rules/compiled_rules.h \
36                 $(SRCDIR)/analysisd/ossec-logtest \
37                 $(SRCDIR)/isbigendian \
38                 $(SRCDIR)/isbigendian.c \
39         rm -rf $(CURDIR)/bin
40
41         dh_clean
42
43 install: build
44         dh_testdir
45         dh_testroot
46         dh_clean -k
47         dh_installdirs
48
49         # ugly directory creation
50         for i in $(SUBDIRS); do \
51                 mkdir -p -m 700 $(DESTDIR)/$$i; \
52         done
53
54         # attrs
55         chmod -R 550 $(DESTDIR)
56         chmod -R 770 $(DESTDIR)/queue/alerts
57         chmod -R 770 $(DESTDIR)/queue/ossec
58         chmod -R 750 $(DESTDIR)/queue/fts
59         chmod -R 750 $(DESTDIR)/queue/syscheck
60         chmod -R 750 $(DESTDIR)/queue/rootcheck
61         chmod -R 750 $(DESTDIR)/queue/diff
62         chmod -R 755 $(DESTDIR)/queue/agent-info
63         chmod -R 755 $(DESTDIR)/queue/rids
64         chmod -R 755 $(DESTDIR)/queue/agentless
65         chmod -R 750 $(DESTDIR)/stats
66         chmod -R 750 $(DESTDIR)/logs
67         chmod -R 550 $(DESTDIR)/rules
68         chmod 770 $(DESTDIR)/var/run
69         chmod 550 $(DESTDIR)/etc
70         chmod 770 $(DESTDIR)/etc/shared
71         chmod 700 $(DESTDIR)/.ssh
72
73         # various files installation
74         install -m 644 etc/internal_options.conf $(DESTDIR)/etc
75         install -m 644 etc/decoder.xml $(DESTDIR)/etc
76         install -m 644 src/rootcheck/db/*.txt $(DESTDIR)/etc/shared
77         if [ -e etc/ossec.mc ]; then \
78                 install -m 440 etc/ossec.mc $(DESTDIR)/etc/ossec.conf; \
79         else \
80                 install -m 440 etc/ossec-agent.conf $(DESTDIR)/etc/ossec.conf; \
81         fi
82         install -m 440 etc/ossec-*.conf $(DESTDIR)/etc
83         cp -r etc/rules/* $(DESTDIR)/rules
84         find $(DESTDIR)/rules -type f -exec chmod 640 '{}' ';'
85         install -m 750 src/agentlessd/scripts/* $(DESTDIR)/agentless
86         install -s -m 755 bin/* $(DESTDIR)/bin
87         install -m 755 src/init/ossec-*.sh $(DESTDIR)/bin
88         ln -s ossec-local.sh $(DESTDIR)/bin/ossec-control
89         install -m 755 active-response/*.sh $(DESTDIR)/active-response/bin
90         install -m 755 active-response/firewalls/*.sh \
91                 $(DESTDIR)/active-response/bin
92
93         # system init script
94         mkdir -p $(PKGDIR)/etc/init.d
95         install -m 755 src/init/ossec-hids.init $(PKGDIR)/etc/init.d/ossec-hids
96
97         # system ossec-init
98         echo "DIRECTORY=\"/var/ossec\""      >  $(PKGDIR)/etc/ossec-init.conf
99         echo "VERSION=\"`cat src/VERSION`\"" >> $(PKGDIR)/etc/ossec-init.conf
100         echo "DATE=\"`date --utc`\""         >> $(PKGDIR)/etc/ossec-init.conf
101         echo "TYPE=\"local\""                >> $(PKGDIR)/etc/ossec-init.conf
102
103 # Build architecture-independent files here.
104 binary-indep: build install
105         dh_testdir
106         dh_testroot
107         dh_installchangelogs
108         dh_installdocs
109 #       dh_installexamples
110 #       dh_installmenu
111 #       dh_installdebconf
112 #       dh_installlogrotate
113 #       dh_installemacsen
114 #       dh_installcatalogs
115 #       dh_installpam
116 #       dh_installmime
117 #       dh_installinit
118 #       dh_installcron
119 #       dh_installinfo
120 #       dh_undocumented
121         dh_installman
122         dh_link
123         dh_compress
124         dh_fixperms
125 #       dh_perl
126 #       dh_python
127         dh_installdeb
128         dh_gencontrol
129         dh_md5sums
130         dh_builddeb
131
132 # Build architecture-dependent files here.
133 binary-arch: build install
134 # We have nothing to do by default.
135
136 binary: binary-indep binary-arch
137 .PHONY: build clean binary-indep binary-arch binary install