debian: Fixed permissions on raddb. (Russell Coker)
[freeradius.git] / debian / rules
1 #! /usr/bin/make -f
2 #
3 #       debian/rules file for freeradius
4 #
5
6 SHELL=/bin/bash
7
8 package = freeradius
9 tmp     = $(shell pwd)/debian/tmp
10
11 prefix  = /
12 exec_prefix     = /usr
13 mandir  = $(exec_prefix)/share/man
14 libdir  = $(exec_prefix)/lib/freeradius
15 logdir  = /var/log/freeradius
16 pkgdocdir       = $(exec_prefix)/share/doc/radiusd-freeradius
17 raddbdir        = $(prefix)/etc/raddb
18
19 build: clean
20 # Builds the binary package.
21         dh_testdir
22         # dh_testroot
23         ./configure --prefix=$(prefix) --exec-prefix=$(exec_prefix) --libdir=$(libdir) --mandir=$(mandir) --with-logdir=$(logdir) --with-thread-pool --enable-ltdl-install=no
24         make
25         touch build
26
27 # Architecture independant files.
28 binary-indep: clean
29
30 # Make a binary package (.deb file)
31 binary-arch:    build
32         dh_clean
33         dh_installdirs
34         make install prefix=$(prefix) exec_prefix=$(exec_prefix) mandir=$(mandir) libdir=$(libdir) R=$(tmp)
35         # clean up install cruft.  $$&@!%
36         rmdir $(tmp)/$(execprefix)/include
37         rm $(tmp)/$(execprefix)/usr/sbin/rc.radiusd
38         # fix install permissions
39         chmod 700 $(tmp)/$(raddbdir)
40         chmod 600 $(tmp)/$(raddbdir)/*
41         # man pages & docs
42         dh_undocumented 
43         install -g root -m 644 CREDITS $(tmp)/$(pkgdocdir)/credits
44         find doc -type f -maxdepth 1 ! -path doc/ChangeLog -exec dh_installdocs {} \;
45         dh_installchangelogs doc/ChangeLog
46         dh_compress
47         # supporting programs
48         install -g root -m 755 scripts/radiusd.cron.daily $(tmp)/$(prefix)/etc/cron.daily/freeradius
49         install -g root -m 755 scripts/radiusd.cron.monthly $(tmp)/$(prefix)/etc/cron.monthly/freeradius
50         install -g root -m 755 scripts/rc.radiusd $(tmp)/$(prefix)/etc/init.d/freeradius
51         # fix up conf file  --  all of these should be commented on in README.Debian
52         cp $(tmp)/$(raddbdir)/radiusd.conf newconf
53         cat newconf \
54                 | sed -e 's/        /   /g' \
55                 | sed -e '/^    example {/,/^   }/s/^/#deb#/' \
56                 | sed -e '/^    sql .*{/,/^     }/s/^/#deb#/' \
57                 | sed -e '/^    always .*{/,/^  }/s/^/#deb#/' \
58                 | sed -e 's/^           #       shadow          =/              shadow          =/' \
59                 | sed -e 's/^group = nobody/group = nogroup/' \
60                         > $(tmp)/$(raddbdir)/radiusd.conf
61         rm newconf
62         # 
63         dh_strip
64         dh_installdeb
65         dh_installchangelogs
66         dh_compress
67         dh_fixperms
68         dh_makeshlibs
69         dh_shlibdeps
70         dh_md5sums
71         dh_gencontrol
72         dh_builddeb
73
74 clean:  
75         dh_clean
76         [ -f Make.inc ] && make distclean || true
77         rm -f build debian/{files,substvars} debian/*.debhelper
78         rm -rf $(tmp)
79
80 binary: binary-indep binary-arch
81
82 # for the maintainer only
83 sanitycheck:
84         @echo -n "sanity: checking for overzealous undocumented file... "
85         @find man/ -type f |grep \. |sed -e 's%man/man./%%' | { \
86                 while read manpage; do \
87                         grep $$manpage debian/undocumented | read filename && echo -n $$filename; \
88                 done; \
89         } || true
90         @test -n $$filename
91         @echo good.
92
93         @echo -n "sanity: making sure conffiles lists all raddb files... "
94         @{ \
95                 tree=`find raddb/ -type f |sed -e 's/\.in$$//' |grep -v CVS |grep -v /Makefile |sort |uniq`; \
96                 debconf=`grep raddb debian/conffiles |sed -e 's%/etc/%%' |sort`; \
97                 test "$$tree" = "$$debconf"; \
98         }
99         @echo good.
100
101 .PHONY: binary binary-arch binary-indep clean sanitycheck