merge NG auth, RT#21563
[freeside.git] / Makefile
index d5576a3..5e42531 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,7 +45,7 @@ INIT_FILE = /etc/init.d/freeside
 #INIT_FILE = /usr/local/etc/rc.d/011.freeside.sh
 
 #deb
-INIT_INSTALL = /usr/sbin/update-rc.d freeside defaults 21 20
+INIT_INSTALL = PATH=$PATH:/sbin /usr/sbin/update-rc.d freeside defaults 23 01
 #redhat, fedora
 #INIT_INSTALL = /sbin/chkconfig freeside on
 #not necessary (freebsd)
@@ -67,6 +67,7 @@ HTTPD_RESTART = /etc/init.d/apache2 restart
 #(an include directory, not a file, "Include /etc/apache/conf.d" in httpd.conf)
 #deb (3.1+), apache2
 APACHE_CONF = /etc/apache2/conf.d
+INSSERV_OVERRIDE = /etc/insserv/overrides
 
 FREESIDE_RESTART = ${INIT_FILE} restart
 
@@ -103,9 +104,6 @@ RT_DB_DATABASE = freeside
 
 TORRUS_ENABLED = 0
 
-# for cvs-upgrade-deploy target, the username who checked out the CVS copy.
-CVS_USER = ivan
-
 # for auto-version updates, so we can "make release" more things automatically
 RPM_SPECFILE = rpm/freeside.spec
 
@@ -116,20 +114,25 @@ RT_PATH = /opt/rt3
 
 #only used for dev kludge now, not a big deal
 FREESIDE_PATH = `pwd`
-PERL_INC_DEV_KLUDGE = /usr/local/share/perl/5.10.1/
+PERL_INC_DEV_KLUDGE = /usr/local/share/perl/5.14.2/
 
-VERSION=2.3.0cvs
-TAG=freeside_2_3_0
+VERSION := `grep '^$$VERSION' FS/FS.pm | cut -d\' -f2`
+TAG := freeside_`grep '^$$VERSION' FS/FS.pm | cut -d\' -f2 | perl -pe 's/\./_/g'`
 
-DEBVERSION = `echo ${VERSION} | perl -pe 's/(\d)([a-z])/\1~\2/'`-1
+#DEBVERSION = `echo ${VERSION} | perl -pe 's/(\d)([a-z])/\1~\2/'`-1
 
 TEXMFHOME := "\$$TEXMFHOME"
 
+ver:
+       @echo "${VERSION}"
+
+tag:
+       @echo "${TAG}"
+
 help:
        @echo "supported targets:"
        @echo "                   create-database create-config"
        @echo "                   install deploy"
-       @echo "                   cvs-upgrade-deploy"
        @echo "                   configure-rt create-rt"
        @echo "                   clean help"
        @echo
@@ -162,11 +165,20 @@ wikiman:
        ./bin/pod2x
 
 install-docs: docs
-       [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
-       cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
+       #ancient attempt to avoid overwriting customer modifications directly to production web files that's overlived its usefulness
+       #[ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
+       #cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
+       [ -h ${FREESIDE_DOCUMENT_ROOT} ] && rm ${FREESIDE_DOCUMENT_ROOT} || true
+       mkdir -p ${FREESIDE_DOCUMENT_ROOT}
+       cp -r masondocs/* masondocs/.htaccess ${FREESIDE_DOCUMENT_ROOT}
        chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
-       cp htetc/handler.pl ${MASON_HANDLER}
-       cp htetc/htpasswd.logout ${FREESIDE_CONF}
+       install -D htetc/handler.pl ${MASON_HANDLER}
+       perl -p -i -e "\
+         s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
+         s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
+       " ${MASON_HANDLER} || true
+       mkdir -p ${FREESIDE_EXPORT}/profile
+       chown freeside ${FREESIDE_EXPORT}/profile
        [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
        chown -R freeside ${MASONDATA}
 
@@ -177,6 +189,8 @@ dev-docs:
        perl -p -i -e "\
          s'###use Module::Refresh;###'use Module::Refresh;'; \
          s'###Module::Refresh->refresh;###'Module::Refresh->refresh;'; \
+         s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
+         s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
        " ${MASON_HANDLER} || true
 
 perl-modules:
@@ -184,14 +198,13 @@ perl-modules:
        [ -e Makefile ] || perl Makefile.PL; \
        make; \
        perl -p -i -e "\
-         s/%%%VERSION%%%/${VERSION}/g;\
-       " blib/lib/FS.pm;\
-       perl -p -i -e "\
          s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
          s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
          s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
          s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
+         s'%%%RT_PATH%%%'${RT_PATH}'g; \
          s'%%%MASONDATA%%%'${MASONDATA}'g;\
+         s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
        " blib/lib/FS/*.pm;\
        perl -p -i -e "\
          s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
@@ -215,7 +228,7 @@ perl-modules:
          s|%%%DIST_CONF%%%|${DIST_CONF}|g;\
        " blib/script/*
 
-install-perl-modules: perl-modules
+install-perl-modules: perl-modules install-rt-initialdata
        [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
          && rm ${PERL_INC_DEV_KLUDGE}/FS \
          && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
@@ -237,9 +250,9 @@ dev-perl-modules: perl-modules
        ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
 
 install-texmf: 
-       install -D -o freeside -m 444 etc/fslongtable.sty \
-          `kpsewhich -expand-var \\\$$TEXMFLOCAL`/tex/generic/fslongtable.sty
-       texhash `kpsewhich -expand-var \\\$$TEXMFLOCAL`
+       install -D -o freeside -m 444 etc/longtable.sty \
+         /usr/local/share/texmf/tex/latex/longtable.sty
+       texhash /usr/local/share/texmf
 
 install-init:
        #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
@@ -263,6 +276,7 @@ install-apache:
              s'%%%MASON_HANDLER%%%'${MASON_HANDLER}'g; \
            " ${APACHE_CONF}/freeside-*.conf \
          ) || true
+       [ -d ${INSSERV_OVERRIDE} ] && [ -x /sbin/insserv ] && ( install -o root -m 755 init.d/insserv-override-apache2 ${INSSERV_OVERRIDE}/apache2 && insserv -d ) || true
 
 install-selfservice:
        [ -e ~freeside ] || cp -pr /etc/skel ~freeside && chown -R freeside ~freeside
@@ -283,18 +297,17 @@ update-selfservice:
          ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
        done
 
-install: install-perl-modules install-docs install-init install-apache install-rt install-torrus install-texmf
+install-chown:
+       chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
+       chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
+       chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
+
+install: install-perl-modules install-docs install-init install-apache install-rt install-torrus install-texmf install-chown
 
 deploy: install
        ${HTTPD_RESTART}
        ${FREESIDE_RESTART}
 
-cvs-upgrade-deploy:
-       su ${CVS_USER} -c 'cvs update -d -P'
-       make install-perl-modules
-       su freeside -c "freeside-upgrade ${CVS_USER}" #not really the same user
-       make deploy
-
 dev: dev-perl-modules dev-docs
 
 create-database:
@@ -340,7 +353,7 @@ configure-rt:
                    --with-db-dba=${DB_USER} \
                    --with-db-database=${RT_DB_DATABASE} \
                    --with-db-rt-user=${DB_USER} \
-                   --with-db-rt-pass=${DB_PASSWORD} \
+                   --with-db-rt-pass="${DB_PASSWORD}" \
                    --with-web-user=freeside \
                    --with-web-group=freeside \
                    --with-rt-group=freeside \
@@ -362,13 +375,21 @@ create-rt: configure-rt
                                     --datafile ${RT_PATH}/etc/initialdata \
        || true
 
-install-rt:
+install-rt: 
        if [ ${RT_ENABLED} -eq 1 ]; then ( cd rt; make install ); fi
        if [ ${RT_ENABLED} -eq 1 ]; then 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; fi
+       if [ ${RT_ENABLED} -eq 1 ]; then \
+         chown -R freeside:freeside ${RT_PATH}/etc; fi
+
+install-rt-initialdata:
+       if [ ${RT_ENABLED} -eq 1 ] && [ -d ${RT_PATH} ]; then \
+         chown -R freeside:freeside ${RT_PATH}/etc; \
+         install -D -o freeside -g freeside -m 0440 rt/etc/initialdata \
+         ${RT_PATH}/etc/initialdata; fi
 
 configure-torrus:
        cd torrus; \
@@ -400,33 +421,31 @@ clean:
 .PHONY: release
 release:
        # Update the changelog
-       ./bin/cvs2cl
-       cvs commit -m "Updated for ${VERSION}" ChangeLog
+       #./bin/cvs2cl
+       #cvs commit -m "Updated for ${VERSION}" ChangeLog
 
        # Update the RPM specfile
-       cvs edit ${RPM_SPECFILE}
-       perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
-       perl -p -i -e "s/\d+[^\}]+/1/ if /%define\s+release\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
-       cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
+       #cvs edit ${RPM_SPECFILE}
+       #perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
+       #perl -p -i -e "s/\d+[^\}]+/1/ if /%define\s+release\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
+       #cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
 
        # Update the Debian changelog
-       cvs edit debian/changelog
-       dch -v ${DEBVERSION} -p "New upstream release"
-       cvs commit -m "Updated for ${VERSION}" debian/changelog
+       #cvs edit debian/changelog
+       #dch -v ${DEBVERSION} -p "New upstream release"
+       #cvs commit -m "Updated for ${VERSION}" debian/changelog
 
        # Make sure other people's changes are pulled in!
-       cvs update -d -P || true #it exits 1...
+       git pull
 
        # Tag the release
-       #cvs tag ${TAG}
-       cvs tag -F ${TAG}
+       git tag -f ${TAG}
 
        #cd /home/ivan
-       cvs export -r ${TAG} -d freeside-${VERSION} freeside
-       tar czvf freeside-${VERSION}.tar.gz freeside-${VERSION}
+       git archive --prefix=freeside-${VERSION}/ ${TAG} | gzip -9 >freeside-${VERSION}.tar.gz
 
        scp freeside-${VERSION}.tar.gz ivan@420.am:/var/www/www.sisd.com/freeside/
-       mv freeside-${VERSION} freeside-${VERSION}.tar.gz ..
+       mv freeside-${VERSION}.tar.gz ..
 
        #these things failing should not make release target fail, so: "|| true"