Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 # Uncomment this to turn on verbose mode.
5 #export DH_VERBOSE=1
6
7 # If set to a true value then MakeMaker's prompt function will
8 # always return the default without waiting for user input.
9 #export PERL_MM_USE_DEFAULT=1
10
11 PERL   ?= /usr/bin/perl
12 #PACKAGE = $(shell dh_listpackages)
13 PACKAGE = freeside
14 TMP     = $(CURDIR)/debian/$(PACKAGE)
15 #DBC_SCRIPTS = $(TMP)/usr/share/dbconfig-common/scripts/freeside
16
17 ##this is gotten from dbconfig-common
18 DB_TYPE = Pg
19
20 #Data source
21 DATASOURCE = DBI:${DB_TYPE}:dbname=freeside
22
23 #no chance, it doesn't get backslash-interpolted now...
24 ##DEBVERSION                    = `head -1 debian/changelog | cut -d')' -f1 | cut -c11-`
25 #DEBVERSION                    = 1.7.3~rc2-1
26 #export VERSION                = $(DEBVERSION) (Debian)
27
28 #export FREESIDE_CONF          = /etc/freeside
29 #export FREESIDE_LOG           = /var/log/freeside
30 #export FREESIDE_LOCK          = /var/lock/freeside
31 #export FREESIDE_CACHE         = $(TMP)/var/cache/freeside
32 #FREESIDE_CACHE         = $(TMP)/var/cache/freeside
33
34 #XXX huh?
35 #export FREESIDE_EXPORT        = /var/spool/freeside
36
37 export FREESIDE_CONF = $(TMP)/usr/local/etc/freeside
38 export FREESIDE_LOG = $(TMP)/usr/local/etc/freeside
39 export FREESIDE_LOCK = $(TMP)/usr/local/etc/freeside
40 export FREESIDE_CACHE = $(TMP)/usr/local/etc/freeside
41 export FREESIDE_EXPORT = $(TMP)/usr/local/etc/freeside
42
43 export DIST_CONF = ${FREESIDE_CONF}/default_conf
44
45 #XXX own subdir?
46 #export MASON_HANDLER          = /usr/share/freeside/handler.pl
47 export MASON_HANDLER=$(TMP)-webui/usr/local/etc/freeside/handler.pl
48
49 #export FREESIDE_DOCUMENT_ROOT = /usr/share/freeside/www
50 export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui/var/www/freeside
51 export INIT_FILE              = $(TMP).init
52 export INIT_INSTALL           = /bin/true
53 export HTTPD_RESTART          = /bin/true
54 #export APACHE_CONF           = /etc/apache2/conf.d
55 export APACHE_CONF            = $(TMP)-webui/etc/freeside/apache2
56 export FREESIDE_RESTART       = /bin/true
57
58 #XXX root?
59 export INSTALLGROUP           = adm
60
61 export SELFSERVICE_MACHINES   = 
62
63 #prompt ?   XXX these are runtime, not buildtime :/
64 export RT_DOMAIN              =  freeside.biz
65 export RT_TIMEZONE            = US/Eastern
66 export HOSTNAME               = localhost
67 export FREESIDE_URL           = http://$(HOSTNAME)/freeside/
68
69 #specific to deb pkg, for purposes of saving off a permanent copy of default
70 #config for postinst and that sort of thing
71 #export DIST_CONF           = /usr/share/freeside/default_conf
72
73 #XXX yuck.  proper RT layout is entirely necessary
74 #this seems to infect way to much of RT with the build location, requiring
75 # a kludge to hack it out afterwords.  look into using fakeroot (didn't
76 # realize it would need to be explicit argh)
77 # (but leaving it for now, otherwise can't get RT to put files where we need em)
78 export RT_PATH                = $(TMP)/opt/rt3
79
80 # This has to be exported to make some magic below work.
81 export DH_OPTIONS
82
83 configure: configure-stamp
84 configure-stamp:
85         dh_testdir
86         # Add here commands to configure the package.
87         
88         touch configure-stamp
89
90
91 build: build-stamp
92 build-stamp: 
93         dh_testdir
94         # Add commands to compile the package here
95         
96         ( cd FS/ && $(PERL) Makefile.PL INSTALLDIRS=vendor && $(MAKE) )
97         $(MAKE) perl-modules
98         
99         ( cd fs_selfservice/FS-SelfService/ && $(PERL) Makefile.PL && $(MAKE) )
100         
101         #install this for freeside-setup
102         install -d $(DIST_CONF)
103         install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
104
105         #TEST#
106
107         touch $@
108
109 clean:
110         dh_testdir
111         dh_testroot
112         dh_clean build-stamp install-stamp
113
114         # Add here commands to clean up after the build process.
115         $(MAKE) -e clean
116         #|| true #XXX freeside clean target fucked
117
118         dh_clean 
119
120 install: install-stamp
121 install-stamp: build-stamp
122         dh_testdir
123         dh_testroot
124         dh_clean -k
125         dh_installdirs
126
127         # Add here commands to install package into
128         # debian/<package>-whatever.
129
130         install -d $(FREESIDE_DOCUMENT_ROOT)
131         install -d $(TMP)-webui/usr/local/etc/freeside/
132         install -d $(TMP)/usr/local/etc/freeside/
133         install -d $(FREESIDE_CACHE)/masondata #MASONDATA
134 #       install -d $(TMP)-lib/usr/bin
135
136         ( cd FS/ && $(MAKE) -e DESTDIR=${TMP}-lib install)
137
138         # Install configuration files
139         install -d -o freeside ${FREESIDE_CONF}
140
141         touch ${FREESIDE_CONF}/secrets
142         chown freeside ${FREESIDE_CONF}/secrets
143         chmod 600 ${FREESIDE_CONF}/secrets
144
145         /bin/echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
146         chmod 600 ${FREESIDE_CONF}/secrets
147         chown freeside ${FREESIDE_CONF}/secrets
148
149         mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
150         chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
151
152         mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
153         chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
154
155         mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
156         chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
157
158         #install this for freeside-setup
159         install -d $(DIST_CONF)
160         #install conf/[a-z]* $(DEFAULT_CONF)
161         #CVS is not [a-z]
162         install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
163
164         # Install interfaces
165         $(MAKE) -e DESTDIR=$(TMP)-webui install-docs
166         
167         # Install tex
168         install -D -o freeside -m 444 etc/longtable.sty \
169         $(TMP)-lib/usr/local/share/texmf/tex/latex/longtable.sty
170         texhash $(TMP)-lib/usr/local/share/texmf
171
172         # Create Apache configurations
173         install -d $(APACHE_CONF)
174         $(MAKE) -e DESTDIR=$(APACHE_CONF) install-apache
175
176         #Hack the build dir out of apache config
177
178         perl -p -i -e "\
179          s'${TMP}(-webui)?''g;\
180         "  $(TMP)-webui/etc/freeside/apache2/*
181
182         # Install init
183         $(MAKE) -e DESTDIR=$(TMP) install-init
184
185         #hack the build dir out of Freeside too.  oh yeah, sucky.
186         perl -p -i -e "\
187           s'${TMP}(-webui)?''g;\
188         " ${TMP}/usr/local/etc/freeside/handler.pl \
189           ${TMP}/usr/share/perl5/FS/* \
190           ${TMP}/usr/share/perl5/FS/*/* \
191           ${TMP}/usr/bin/*
192
193         #hack the build dur out of lib
194         perl -p -i -e "\
195           s'${TMP}-lib?''g;\
196           s'${TMP}(-webui)?''g;\
197         " ${TMP}/usr/local/etc/freeside/handler.pl \
198           ${TMP}-lib/usr/share/perl5/FS/*.pm \
199           ${TMP}-lib/usr/share/perl5/FS/*/*.pm 
200         
201         #hack the build dir out of Freeside binaries
202
203         perl -p -i -e "\
204           s'${TMP}?''g;\
205         " ${TMP}-lib/usr/bin/* \
206           ${TMP}-webui/usr/local/etc/freeside/handler.pl
207
208         # Self-service
209         
210         ( cd fs_selfservice/FS-SelfService/; $(MAKE) -e DESTDIR=${TMP}-selfservice-lib install ) 
211         install -d -o freeside -g freeside ${TMP}-selfservice-lib/usr/local/freeside
212         touch ${TMP}-selfservice-lib/usr/local/freeside/selfservice_socket 
213         chown -R freeside ${TMP}-selfservice-lib/usr/local/freeside
214         chmod 600 ${TMP}-selfservice-lib/usr/local/freeside/selfservice_socket
215         
216         install -d -o freeside -g freeside ${TMP}-selfservice-ui/var/www/
217         cp -R fs_selfservice/FS-SelfService/cgi ${TMP}-selfservice-ui/var/www/selfservice-DIST
218         chown freeside.freeside ${TMP}-selfservice-ui/var/www/selfservice-DIST/*.cgi ${TMP}-selfservice-ui/var/www/selfservice-DIST/*/*.cgi;
219         chmod 755 ${TMP}-selfservice-ui/var/www/selfservice-DIST/*.cgi ${TMP}-selfservice-ui/var/www/selfservice-DIST/*/*.cgi
220
221         # NG-selfservice
222
223         install -d ${TMP}-ng-selfservice/var/www/
224         cp -R ng_selfservice ${TMP}-ng-selfservice/var/www/ng_selfservice-DIST/
225
226         #RT Config
227
228         ( cd rt; \
229           cp config.layout.in config.layout; \
230           perl -p -i -e "\
231             s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
232             s'%%%MASONDATA%%%'${FREESIDE_CACHE}/masondata'g;\
233           " config.layout; \
234           ./configure --prefix=${RT_PATH} \
235                 --enable-layout=Freeside \
236                 --with-db-type=Pg \
237                 --with-db-dba=freeside \
238                 --with-db-database=freeside \
239                 --with-db-rt-user=freeside \
240                 --with-db-rt-pass="" \
241                 --with-web-user=freeside \
242                 --with-web-group=freeside \
243                 --with-rt-group=freeside \
244                 --with-web-handler=modperl2 )
245
246         ##(create-rt)
247         #$(MAKE) -e DESTDIR=${TMP}-lib create-rt
248         install -d $(RT_PATH)
249         install -d $(RT_PATH)/share
250
251         ( cd rt; $(MAKE) install )
252         
253         ##hack the build dir out of RT.  yeah, sucky.
254
255         perl -p -i -e "\
256         s'${TMP}(-webui)''g;\
257         s'${TMP}''g;\
258         " ${TMP}/opt/rt3/etc/*.pm \
259                 ${TMP}/opt/rt3/lib/*.pm \
260                 ${TMP}/opt/rt3/lib/RT/*.pm \
261                 ${TMP}/opt/rt3/etc/upgrade/* \
262                 ${TMP}/opt/rt3/sbin/* \
263                 ${TMP}/opt/rt3/bin/* \
264
265         # Default RT Settings
266         perl -p -i -e "\
267                 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
268                 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
269                 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
270                 " ${RT_PATH}/etc/RT_SiteConfig.pm
271
272         dh_install
273
274         #touch $@
275
276 binary-arch:
277 # We have nothing to do here for an architecture-independent package
278
279 binary-indep: build install
280         dh_testdir
281         dh_testroot
282         dh_installdeb install
283         dh_installdocs #freeside.docs README AGPL
284         dh_installexamples eg/*
285 #       dh_installmenu
286         dh_installdebconf       
287 #       dh_installlogrotate     
288         dh_installinit --no-start 
289         dh_installcron
290 #       dh_installinfo
291         dh_installman
292         dh_perl
293         dh_link
294         dh_compress 
295         dh_fixperms -X/var/www/selfservice-DIST -X/usr/local/freeside
296         dh_gencontrol
297         dh_md5sums
298         dh_builddeb
299
300 binary: binary-indep binary-arch
301 .PHONY: build clean binary-indep binary-arch binary install