3 ### Build script for Debian packages
5 ### (c) 2008 Mark Wooding
8 ###----- Licensing notice ---------------------------------------------------
10 ### This program is free software; you can redistribute it and/or modify
11 ### it under the terms of the GNU General Public License as published by
12 ### the Free Software Foundation; either version 2 of the License, or
13 ### (at your option) any later version.
15 ### This program is distributed in the hope that it will be useful,
16 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ### GNU General Public License for more details.
20 ### You should have received a copy of the GNU General Public License
21 ### along with this program; if not, write to the Free Software Foundation,
22 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ###--------------------------------------------------------------------------
31 Usage: $0 [-vr] BUILDOPT
45 ## Parse simple options.
47 while getopts "hvr" opt
; do
56 ## Parse the build options.
67 checkout
) checkout
=yes checkoutrev
=HEAD
;;
68 checkout
=*) checkout
=yes checkoutrev
=${opt#*=} ;;
69 nocheckout
) checkout
=no
;;
70 release
) build
=release
;;
71 norelease
) build
=test ;;
73 setup | distcheck | debian | upload | clean
)
76 nosetup | nodistcheck | nodebian | noupload | noclean
)
86 ###--------------------------------------------------------------------------
87 ### Utility functions.
89 exec 3>&2 4>/dev
/null
5>&2
94 echo "$(tput bold; tput setaf $colour)$message$(tput sgr0; tput op)" >&5
113 "$@" 2>&3 || fail
"$1: exit $?"
116 run
() { runx
"$@" >&3; }
119 echo -n
"(test $*)" >&4
120 if "$@" >&4 2>&4; then
129 ###--------------------------------------------------------------------------
132 ## Find the top-level package directory.
133 while [ ! -f configure.ac
-a
! -f configure.
in -a
! -f .links
]; do
136 fail
"couldn't find top-level directory"
141 assign srcpath $
(pwd)
143 ## Construct the output directory.
144 assign releasepath
$srcpath/dist-
$build
145 chmod -R
+w
$releasepath 2>/dev
/null||
:
146 rm -rf
$releasepath 2>/dev
/null ||
:
150 exec 4>$releasepath/mdw-build.log
3>&4 ||
151 fail
"Failed to create log."
155 ## Maybe check out a copy of the source.
156 case "$checkout,$setup,$(yesno [ -d $srcpath/.git ])" in
158 fail
"Inconsistent options: can't check out without setup."
161 info
"No Git repository found."
165 [ "$(git ls-files -m)" = "" ] ||
166 fail
"working tree has uncommitted changes"
168 run git clone
-sn
$srcpath/.git _source
169 assign srcpath
$releasepath/_source
171 run git checkout
-b mdw-build
$checkoutrev
175 ## Maybe refresh the build machinery.
182 ## Initialize the build directory.
183 if [ -e
$srcpath/configure
]; then
184 assign buildpath
$releasepath/_build
187 run
$srcpath/configure
189 info
"no configure script"
190 assign buildpath
$srcpath
194 ## Discover the release name.
195 cat >find-distdir.mk
<<'EOF'
200 assign distdir $
(make -f find-distdir.mk print-distdir
)
202 ## Get a tarball distribution.
214 if ! tar tfz
$buildpath/$distdir.
tar.gz |
grep -q RELEASE
; then
215 fail
"missing RELEASE file in distribution"
218 run
mv $buildpath/$distdir.
tar.gz .
220 ## Maybe build the Debian packages.
221 case "$debian,$(yesno [ -d $srcpath/debian ])" in
223 info
"No debian directory found."
227 run
tar xvfz
$distdir.
tar.gz
229 run dpkg-buildpackage
-k$
(mdw-conf releasekey
)
233 ## Maybe upload Debian packages.
235 case "$upload,$build" in
237 info
"Test build: not uploading."
240 cp $distdir.
tar.gz
/home
/ftp/pub
/mdw
/
243 run dput
-f $
(mdw-conf dput-target metalzone
) *.changes
251 rm -rf
$releasepath/$distdir
252 rm -rf
$releasepath/_source
253 rm -rf
$releasepath/_build
260 ###----- That's all, folks --------------------------------------------------