return svcnum from order_pkg, RT#9906
[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 = db_type_is_configured_during_pkg_install_by_dbconfig-common_not_at_build_time
19
20 #no chance, it doesn't get backslash-interpolted now...
21 #DEBVERSION                    = `head -1 debian/changelog | cut -d')' -f1 | cut -c11-`
22 DEBVERSION                    = 1.7.3~rc2-1
23 export VERSION                = $(DEBVERSION) (Debian)
24
25 export FREESIDE_CONF          = /etc/freeside
26 export FREESIDE_LOG           = /var/log/freeside
27 export FREESIDE_LOCK          = /var/lock/freeside
28 export FREESIDE_CACHE         = $(TMP)/var/cache/freeside
29 FREESIDE_CACHE         = $(TMP)/var/cache/freeside
30
31 #XXX huh?
32 export FREESIDE_EXPORT        = /var/spool/freeside
33
34 #XXX own subdir?
35 export MASON_HANDLER          = $(TMP)-webui/usr/share/freeside/handler.pl
36
37 export APACHE_VERSION         = 2
38 export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui/usr/share/freeside/www
39 export INIT_FILE              = $(TMP).init
40 export INIT_INSTALL           = /bin/true
41 export HTTPD_RESTART          = /bin/true
42 #export APACHE_CONF            = $(TMP)-webui/etc/apache2/conf.d
43 export APACHE_CONF            = $(TMP)-webui/etc/freeside/apache2
44 export FREESIDE_RESTART       = /bin/true
45
46 #XXX root?
47 export INSTALLGROUP           = adm
48
49 export SELFSERVICE_MACHINES   = 
50
51 #prompt ?   XXX these are runtime, not buildtime :/
52 export RT_DOMAIN              = `dnsdomainname`
53 export RT_TIMEZONE            = `cat /etc/timezone`
54
55 export HOSTNAME               = `hostname -f`
56 export FREESIDE_URL           = http://$(HOSTNAME)/freeside/
57
58 #specific to deb pkg, for purposes of saving off a permanent copy of default
59 #config for postinst and that sort of thing
60 export DIST_CONF           = $(TMP)/usr/share/freeside/default_conf
61
62 #XXX yuck.  proper RT layout is entirely necessary
63 #this seems to infect way to much of RT with the build location, requiring
64 # a kludge to hack it out afterwords.  look into using fakeroot (didn't
65 # realize it would need to be explicit argh)
66 # (but leaving it for now, otherwise can't get RT to put files where we need em)
67 export RT_PATH                = $(TMP)/var/opt/freeside/rt
68
69 # This has to be exported to make some magic below work.
70 export DH_OPTIONS
71
72 configure: configure-stamp
73 configure-stamp:
74         dh_testdir
75         # Add here commands to configure the package.
76         
77         touch configure-stamp
78
79
80 build: build-stamp
81 build-stamp: 
82         dh_testdir
83         # Add commands to compile the package here
84         
85         ( cd FS/ && $(PERL) Makefile.PL INSTALLDIRS=vendor )
86
87         $(MAKE) -e perl-modules
88
89         #TEST#
90
91         touch $@
92
93 clean:
94         dh_testdir
95         dh_testroot
96         dh_clean build-stamp install-stamp
97
98         # Add here commands to clean up after the build process.
99         $(MAKE) -e clean
100         #|| true #XXX freeside clean target fucked
101
102         dh_clean 
103
104 install: install-stamp
105 install-stamp: build-stamp
106         dh_testdir
107         dh_testroot
108         dh_clean -k
109         dh_installdirs
110
111         # Add here commands to install package into
112         # debian/<package>-whatever.
113         ( cd FS/ && $(MAKE) -e DESTDIR=$(TMP)-lib install )
114
115         #false laziness w/install-perl-modules now
116         #install this for postinst later (no create-config)
117         install -d $(DIST_CONF)
118         #install conf/[a-z]* $(DEFAULT_CONF)
119         #CVS is not [a-z]
120         install `ls -d conf/[a-z]* | grep -v CVS` $(DIST_CONF)
121
122         install -d $(FREESIDE_DOCUMENT_ROOT)
123         install -d $(FREESIDE_CACHE)/masondata #MASONDATA
124         $(MAKE) -e install-docs
125
126         #hack the build dir out of Freeside too.  oh yeah, sucky.
127         perl -p -i -e "\
128           s'${TMP}(-webui)?''g;\
129         " ${TMP}-webui/usr/share/freeside/handler.pl \
130           ${TMP}/usr/share/perl5/FS/* \
131           ${TMP}/usr/share/perl5/FS/*/* \
132           ${TMP}/usr/bin/*
133
134         rm -r $(FREESIDE_DOCUMENT_ROOT).*
135
136         install -d $(APACHE_CONF)
137         install debian/freeside.apache-alias.conf $(APACHE_CONF)/freeside-alias.conf
138         FREESIDE_DOCUMENT_ROOT=/usr/share/freeside/www MASON_HANDLER=/usr/share/freeside/handler.pl FREESIDE_CONF=/etc/freeside $(MAKE) -e install-apache
139
140         $(MAKE) -e install-init
141
142         #RT
143         #(configure-rt)
144
145         # XXX need to adjust db-type, db-database, db-rt-user, db-rt-pass
146         # based on info from dbc
147         ( cd rt; \
148           cp config.layout.in config.layout; \
149           perl -p -i -e "\
150             s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
151             s'%%%MASONDATA%%%'${FREESIDE_CACHE}/masondata'g;\
152           " config.layout; \
153           ./configure --prefix=${RT_PATH} \
154                       --enable-layout=Freeside \
155                       --with-db-type=Pg \
156                       --with-db-dba=freeside \
157                       --with-db-database=_DBC_DBNAME_ \
158                       --with-db-rt-user=_DBC_DBUSER_ \
159                       --with-db-rt-pass=_DBC_DBPASS_ \
160                       --with-web-user=freeside \
161                       --with-web-group=freeside \
162                       --with-rt-group=freeside \
163         )
164
165         #(create-rt)
166         install -d $(RT_PATH)
167         ( cd rt; make install )
168         #hack the build dir out of RT.  yeah, sucky.
169         perl -p -i -e "\
170           s'${TMP}''g;\
171         " ${RT_PATH}/etc/RT_Config.pm \
172           ${RT_PATH}/lib/RT.pm \
173           ${RT_PATH}/bin/mason_handler.fcgi \
174           ${RT_PATH}/bin/mason_handler.scgi \
175           ${RT_PATH}/bin/standalone_httpd \
176           ${RT_PATH}/bin/webmux.pl \
177           ${RT_PATH}/bin/rt-crontool \
178           ${RT_PATH}/sbin/rt-dump-database \
179           ${RT_PATH}/sbin/rt-setup-database
180         
181         #hack @INC dir out of RT (well, handler.pl) too.
182         perl -p -i -e "\
183           s'/opt/rt3/'/var/opt/freeside/rt/'g;\
184         " ${TMP}-webui/usr/share/freeside/handler.pl
185
186         mv ${RT_PATH}/etc/RT_Config.pm ${RT_PATH}/etc/RT_Config.pm.dbc
187
188         perl -p -i -e "\
189           s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
190           s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
191           s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
192         " ${RT_PATH}/etc/RT_SiteConfig.pm
193
194         install -D debian/dbconfig-common.install $(DBC_SCRIPTS)/install/pgsql
195         install -D debian/dbconfig-common.install $(DBC_SCRIPTS)/install/mysql
196         
197         install -D debian/dbconfig-common.upgrade $(DBC_SCRIPTS)/upgrade/pgsql/$(DEBVERSION)
198         install -D debian/dbconfig-common.upgrade $(DBC_SCRIPTS)/upgrade/mysql/$(DEBVERSION)
199         
200         dh_install
201
202         touch $@
203
204 binary-arch:
205 # We have nothing to do here for an architecture-independent package
206
207 binary-indep: build install
208         dh_testdir
209         dh_testroot
210         dh_installchangelogs ChangeLog
211         dh_installdocs #freeside.docs README AGPL
212         dh_installexamples eg/*
213 #       dh_installmenu
214         dh_installdebconf       
215 #       dh_installlogrotate     
216         dh_installinit
217         dh_installcron
218 #       dh_installinfo
219         dh_installman
220         dh_perl
221         dh_link
222         dh_compress 
223         dh_fixperms
224         dh_installdeb
225         dh_gencontrol
226         dh_md5sums
227         dh_builddeb
228
229 binary: binary-indep binary-arch
230 .PHONY: build clean binary-indep binary-arch binary install