]> git.donarmstrong.com Git - debbugs.git/blob - build
[project @ 2005-08-09 23:04:43 by cjwatson]
[debbugs.git] / build
1 #!/bin/sh
2
3 set -e
4
5 cwd="`pwd`"
6 date="`date +'%d %h %Y'`"
7
8 process () {
9         (cd config &&
10          rm -f trace &&
11          m4 -P -I "$config" -DDB_DATE="$date" \
12                 common/init.m4 config.m4 common/main.m4 - common/final.m4
13         )
14 }
15
16 txtconvert () {
17         src=$1; dst=$2
18         echo "  generating $dst from $src ..."
19         rm -f html/txt/$dst.html html/txt/$dst.out
20         perl -ne 'print unless m/^Other pages:$/ .. /^\<hr\>/' \
21                 html/$src.out >html/txt/$dst.html
22         HOME=/dev/null lynx -nolist -dump -cfg=/dev/null \
23                 file://localhost/$cwd/html/txt/$dst.html >html/txt/$dst.out
24         rm html/txt/$dst.html
25 }
26
27 config=local
28 if [ $# != 0 ]; then config="$1"; shift; fi
29 if [ $# != 0 ]; then echo >&2 'usage: ./build [<config>]'; false; fi
30
31 if [ ! -f config/$config/config.m4 ]; then echo >&2 "no such config: $config"; false; fi
32
33 errs="`echo 'm4_undivert(1)' | process | sed -ne '/[^ \t]/ s/^/ /p'`"
34 if [ "x$errs" != x ]
35 then
36         echo >&2 'unexpected residues:'
37         echo "$errs"
38         false
39 fi
40
41 echo "macro substitutions ..."
42 for f in `find -name '*.in'`
43 do
44         h="`echo $f | sed -e 's/\.in$//'`"
45         process <"$f" >"$h.out"
46         mv config/trace "$h.trace"
47         if egrep 'DBC?U?_' /dev/null "$h.out"
48         then
49                 echo >&2 'undefined macros'
50                 false
51         fi
52         [ ! -x "$f" ] || chmod +x "$h.out"
53 done
54
55 echo "documentation conversion ..."
56 txtconvert Reporting.html bug-reporting.txt
57 txtconvert Access.html bug-log-access.txt
58 txtconvert server-request.html bug-log-mailserver.txt
59 txtconvert Developer.html bug-maint-info.txt
60 txtconvert server-control.html bug-maint-mailcontrol.txt
61 txtconvert server-refcard.html bug-mailserver-refcard.txt
62
63 cgilibexist=`echo 'test -f DBC_CGILIB_PATH && echo true || echo false' | process`
64 htaccesspath=`echo DBC_HTACCESS_PATH | process`
65
66 rm -f install install.new
67 process <<'END' >install.new
68 #!/bin/sh
69         set -e
70         test -d DBC_BASE || mkdir DBC_BASE
71         bugsid () {
72                 echo "installing $1 ..."
73                 test -d "$2" || mkdir "$2"
74                 cd "$1"
75                 for f in *.out
76                 do
77                         h="`echo $f | sed -e 's/\.out$//'`"
78                         rm -f "$2/$f"
79                         cp "./$f" "$2/"
80                         mv -f "$2/$f" "$2/$h"
81                 done
82                 cd "$3"
83         }
84         bugsid scripts DBC_SCRIPT_PATH ..
85         bugsid html DBC_HTML_PATH ..
86         bugsid html/txt DBC_DOCDIR_PATH ../..
87         bugsid cgi DBC_CGI_PATH ..
88 END
89 if [ "x$htaccesspath" != x ]; then
90         process <<END >>install.new
91                 cat <<'END2' >$htaccesspath.new
92 DBC_HTACCESS_CONTENTS
93 END2
94                 mv -f $htaccesspath.new $htaccesspath
95 END
96 fi
97
98 if $cgilibexist
99 then
100         cgiii='cgi-lib already exists in DBC_CGILIB_PATH'
101 else
102         cgiii=' DBC_CGILIB_PATH'
103         process <<'END' >>install.new
104                 echo "installing cgi-lib.pl ..."
105                 cp cgi/cgi-lib.pl DBC_CGILIB_PATH.new
106                 mv -f DBC_CGILIB_PATH.new DBC_CGILIB_PATH
107 END
108 fi
109 process >>install.new <<'END'
110         echo "setting up bugs database ..."
111         DBC_SCRIPT_PATH/initialise
112         echo "done."
113         echo "You will have to intall the crontab (misc/crontab.out) yourself."
114         exit 0
115 END
116 chmod +x install.new
117 mv -f install.new install
118
119 cgi="`cd cgi && echo *.out | sed -e 's/\.out//g'`"
120
121 process <<END
122 built for $config date DB_DATE ...
123         will install unchanging files into:
124                 DBC_SCRIPT_PATH/
125                 DBC_HTML_PATH/
126                 DBC_CGI_PATH/ ($cgi)
127         $cgiii
128         will store data in:
129                 DB_HTMLDB_PATH/
130                 DBC_SPOOL_PATH/
131         will expect CGI scripts to be available in:
132                 DBC_CGI_URL/
133 END
134
135 echo "run ./install to install"
136 exit 0