summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 1eb312ba4e8a407ab2b52592f63dc7be7a5a9ec6 (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#!/usr/bin/make -f
# -*- makefile -*-

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

# If set to a true value then MakeMaker's prompt function will
# always return the default without waiting for user input.
#export PERL_MM_USE_DEFAULT=1

PERL   ?= /usr/bin/perl
#PACKAGE = $(shell dh_listpackages)
PACKAGE = freeside
TMP     = $(CURDIR)/debian/$(PACKAGE)
#DBC_SCRIPTS = $(TMP)/usr/share/dbconfig-common/scripts/freeside

##this is gotten from dbconfig-common
DB_TYPE = Pg

#Data source
DATASOURCE = DBI:${DB_TYPE}:dbname=freeside

#no chance, it doesn't get backslash-interpolted now...
##DEBVERSION                    = `head -1 debian/changelog | cut -d')' -f1 | cut -c11-`
#DEBVERSION                    = 1.7.3~rc2-1
#export VERSION                = $(DEBVERSION) (Debian)

#export FREESIDE_CONF          = /etc/freeside
#export FREESIDE_LOG           = /var/log/freeside
#export FREESIDE_LOCK          = /var/lock/freeside
#export FREESIDE_CACHE         = $(TMP)/var/cache/freeside
#FREESIDE_CACHE         = $(TMP)/var/cache/freeside

#XXX huh?
#export FREESIDE_EXPORT        = /var/spool/freeside

export FREESIDE_CONF = $(TMP)/usr/local/etc/freeside
export FREESIDE_LOG = $(TMP)/usr/local/etc/freeside
export FREESIDE_LOCK = $(TMP)/usr/local/etc/freeside
export FREESIDE_CACHE = $(TMP)/usr/local/etc/freeside
export FREESIDE_EXPORT = $(TMP)/usr/local/etc/freeside

export DIST_CONF = ${FREESIDE_CONF}/default_conf

#XXX own subdir?
#export MASON_HANDLER          = /usr/share/freeside/handler.pl
export MASON_HANDLER=$(TMP)-webui/usr/local/etc/freeside/handler.pl

export APACHE_VERSION        := $(shell /usr/sbin/apache2 -v | grep -q '\/2\.4\.' && echo '2.4' || echo '2')
export APACHE_DOCUMENT_ROOT  := $(shell [ ${APACHE_VERSION} = '2.4' ] && echo '/var/www/html' || echo '/var/www')
export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui$(APACHE_DOCUMENT_ROOT)/freeside
export INIT_FILE              = $(TMP).init
export INIT_INSTALL           = /bin/true
export HTTPD_RESTART          = /bin/true
export APACHE_CONF           := $(shell [ ${APACHE_VERSION} = '2.4' ] && echo "$(TMP)-webui/etc/apache2/conf-available" || echo "$(TMP)-webui/etc/apache2/conf.d")
export TORRUS_CONF           := $(shell [ ${APACHE_VERSION} = '2.4' ] && echo "$(TMP)-torrus/etc/apache2/conf-available" || echo "$(TMP)-torrus/etc/apache2/conf.d")
export FREESIDE_RESTART       = /bin/true

#XXX root?
export INSTALLGROUP           = adm

export SELFSERVICE_MACHINES   = 

#prompt ?   XXX these are runtime, not buildtime :/
export RT_DOMAIN              =  freeside.biz
export RT_TIMEZONE            = US/Eastern
export HOSTNAME               = localhost
export FREESIDE_URL           = http://$(HOSTNAME)/freeside/

#specific to deb pkg, for purposes of saving off a permanent copy of default
#config for postinst and that sort of thing
#export DIST_CONF           = /usr/share/freeside/default_conf

#XXX yuck.  proper RT layout is entirely necessary
#this seems to infect way to much of RT with the build location, requiring
# a kludge to hack it out afterwords.  look into using fakeroot (didn't
# realize it would need to be explicit argh)
# (but leaving it for now, otherwise can't get RT to put files where we need em)
export RT_PATH                = $(TMP)-lib/opt/rt3

export TEXMF_PATH             = $(TMP)-lib/usr/local/share/texmf/tex/latex

# This has to be exported to make some magic below work.
export DH_OPTIONS

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.
	
	touch configure-stamp


build: build-stamp
build-stamp: 
	dh_testdir
	# Add commands to compile the package here
	
	( cd FS/ && $(PERL) Makefile.PL INSTALLDIRS=vendor && $(MAKE) )
	$(MAKE) perl-modules
	
	( cd fs_selfservice/FS-SelfService/ && $(PERL) Makefile.PL && $(MAKE) )
	
	#install this for freeside-setup
	install -d $(DIST_CONF)
	install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)

	#TEST#

	touch $@

clean:
	dh_testdir
	dh_testroot
	dh_clean build-stamp install-stamp

	# Add here commands to clean up after the build process.
	$(MAKE) -e clean
	#|| true #XXX freeside clean target fucked

	dh_clean 

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install package into
	# debian/<package>-whatever.

	install -d $(FREESIDE_DOCUMENT_ROOT)
	install -d $(TMP)-webui/usr/local/etc/freeside/
	install -d $(TMP)-webui/etc/insserv/overrides/
	install -d $(TMP)/usr/local/etc/freeside/
#	install -d $(TMP)-lib/usr/bin

	( cd FS/ && $(MAKE) -e DESTDIR=${TMP}-lib install)

        # Install configuration files
	install -d -o freeside ${FREESIDE_CONF}

	touch ${FREESIDE_CONF}/secrets
	chown freeside ${FREESIDE_CONF}/secrets
	chmod 600 ${FREESIDE_CONF}/secrets

	/bin/echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
	chmod 600 ${FREESIDE_CONF}/secrets
	chown freeside ${FREESIDE_CONF}/secrets

	mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
	chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"

	mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
	chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"

	mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
	chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"

	#install this for freeside-setup
	install -d $(DIST_CONF)
	#install conf/[a-z]* $(DEFAULT_CONF)
	#CVS is not [a-z]
	install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)

	# Install interfaces
	$(MAKE) -e DESTDIR=$(TMP)-webui install-docs
	
	# Install tex
	install -d ${TEXMF_PATH}
	install -o freeside -m 444 etc/*.sty ${TEXMF_PATH}

	# Create Apache configurations
	install -d $(APACHE_CONF)
	$(MAKE) -e DESTDIR=$(APACHE_CONF) install-apache
	install -o root -m 755 init.d/insserv-override-apache2 $(TMP)-webui/etc/insserv/overrides/apache2

        #Hack the build dir out of apache config

	perl -p -i -e "\
         s'${TMP}(-webui)?''g;\
        " $(APACHE_CONF)/*

	# Install init
	$(MAKE) -e DESTDIR=$(TMP) install-init

	#hack the build dir out of Freeside too.  oh yeah, sucky.
	perl -p -i -e "\
	  s'${TMP}(-webui)?''g;\
	" ${TMP}/usr/local/etc/freeside/handler.pl \
	  ${TMP}/usr/share/perl5/FS/* \
	  ${TMP}/usr/share/perl5/FS/*/* \
	  ${TMP}/usr/bin/*

	#hack the build dur out of lib
	perl -p -i -e "\
          s'${TMP}-lib?''g;\
	  s'${TMP}(-webui)?''g;\
        " ${TMP}/usr/local/etc/freeside/handler.pl \
	  ${TMP}-lib/usr/share/perl5/FS/*.pm \
	  ${TMP}-lib/usr/share/perl5/FS/*/*.pm 
        
        #hack the build dir out of Freeside binaries

	perl -p -i -e "\
          s'${TMP}?''g;\
        " ${TMP}-lib/usr/bin/* \
	  ${TMP}-webui/usr/local/etc/freeside/handler.pl

	# Self-service
	
	( cd fs_selfservice/FS-SelfService/; $(MAKE) -e DESTDIR=${TMP}-selfservice-lib install ) 
	install -d -o freeside -g freeside ${TMP}-selfservice-lib/usr/local/freeside
	touch ${TMP}-selfservice-lib/usr/local/freeside/selfservice_socket 
	chown -R freeside ${TMP}-selfservice-lib/usr/local/freeside
	chmod 600 ${TMP}-selfservice-lib/usr/local/freeside/selfservice_socket
	
	install -d -o freeside -g freeside ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/
	cp -R fs_selfservice/FS-SelfService/cgi ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST
	chown freeside.freeside ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST/*.cgi ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST/*/*.cgi;
	chmod 755 ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST/*.cgi ${TMP}-selfservice-ui$(APACHE_DOCUMENT_ROOT)/selfservice-DIST/*/*.cgi

	# NG-selfservice

	install -d ${TMP}-ng-selfservice$(APACHE_DOCUMENT_ROOT)/
	cp -R ng_selfservice ${TMP}-ng-selfservice$(APACHE_DOCUMENT_ROOT)/ng_selfservice-DIST/

	# Torrus 
	
	install -d ${TORRUS_CONF}
	install -o root -m 755 htetc/freeside-torrus.conf $(TORRUS_CONF)/

	( cd torrus; \
	torrus_user=freeside var_user=freeside var_group=freeside ./configure; \
	$(MAKE) -e DESTDIR=${TMP}-torrus/; \
	$(MAKE) -e DESTDIR=${TMP}-torrus/ install; \
	perl -p -i -e "\
	    s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
	" ${TMP}-torrus/usr/local/etc/torrus/conf/torrus-siteconfig.pl )

	#RT Config

	( cd rt; \
          cp config.layout.in config.layout; \
          perl -p -i -e "\
            s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
            s'%%%MASONDATA%%%'${FREESIDE_CACHE}/masondata'g;\
          " config.layout; \
          ./configure --prefix=${RT_PATH} \
		--enable-layout=Freeside \
		--with-db-type=Pg \
		--with-db-dba=freeside \
		--with-db-database=freeside \
		--with-db-rt-user=freeside \
		--with-db-rt-pass="" \
		--with-web-user=freeside \
		--with-web-group=freeside \
		--with-rt-group=freeside \
		--with-web-handler=modperl2 )

        ##(create-rt)
	#$(MAKE) -e DESTDIR=${TMP}-lib create-rt
	install -d $(RT_PATH)
	install -d $(RT_PATH)/share

	( cd rt; $(MAKE) config-install dirs files-install fixperms instruct )
	cp -r rt/share/static/images ${FREESIDE_DOCUMENT_ROOT}/rt/NoAuth/
	
	##hack the build dir out of RT.  yeah, sucky.

	perl -p -i -e "\
	s'${TMP}(-webui|-lib)''g;\
	s'${TMP}''g;\
	" ${TMP}-lib/opt/rt3/etc/*.pm \
		${TMP}-lib/opt/rt3/lib/*.pm \
		${TMP}-lib/opt/rt3/lib/RT/*.pm \
		${TMP}-lib/opt/rt3/etc/upgrade/* \
		${TMP}-lib/opt/rt3/sbin/* \
		${TMP}-lib/opt/rt3/bin/* \

	# Default RT Settings
	perl -p -i -e "\
		s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
		s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
		s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
		" ${RT_PATH}/etc/RT_SiteConfig.pm

	dh_install

	#touch $@

binary-arch:
# We have nothing to do here for an architecture-independent package

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdeb install
	dh_installdocs #freeside.docs README AGPL
	dh_installexamples eg bin
#	dh_installmenu
	dh_installdebconf	
#	dh_installlogrotate	
	dh_installinit --no-start 
	dh_installcron
#	dh_installinfo
	dh_installman
	dh_perl
	dh_link
	dh_compress 
	dh_fixperms -X/var/www/selfservice-DIST -X/usr/local/freeside
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install