Added automatic determination of the SVN revision number if a build
[sgt/puzzles] / mkunxarc.sh
1 #!/bin/sh
2
3 # Build a Unix source distribution from the Puzzles SVN area.
4 #
5 # Pass a numeric argument to have the archive tagged as that SVN
6 # revision. Otherwise, the script will work it out itself by
7 # calling `svnversion', or failing that it will not version-tag the
8 # archive at all.
9
10 case "$#" in
11 0)
12 # Ignore errors; if we can't get a version, we'll have a blank
13 # string.
14 rev=`svnversion . 2>/dev/null`
15 ;;
16 *)
17 case "$1" in *[!0-9]*) echo "Malformed revision number '$1'">&2;exit 1;;esac
18 rev="$1"
19 ;;
20 esac
21
22 if test "x$rev" != "x"; then
23 arcsuffix="-r$rev"
24 ver="-DREVISION=$rev"
25 else
26 arcsuffix=
27 ver=
28 fi
29
30 perl mkfiles.pl
31 make -s -f Makefile.doc
32
33 arcname="puzzles$arcsuffix"
34 mkdir uxarc
35 mkdir uxarc/$arcname
36 find . -name uxarc -prune -o \
37 -name CVS -prune -o \
38 -name '*.app' -prune -o \
39 -name '.[^.]*' -prune -o \
40 -name . -o \
41 -type d -exec mkdir uxarc/$arcname/{} \;
42 find . -name uxarc -prune -o \
43 -name CVS -prune -o \
44 -name '.[^.]*' -prune -o \
45 -name '*.app' -prune -o \
46 -name '*.zip' -prune -o \
47 -name '*.tar.gz' -prune -o \
48 -type f -exec ln -s $PWD/{} uxarc/$arcname/{} \;
49 if test "x$ver" != "x"; then
50 (cd uxarc/$arcname;
51 md5sum `find . -name '*.[ch]' -print` > manifest;
52 echo "$ver" > version.def)
53 fi
54 tar -C uxarc -chzof $arcname.tar.gz $arcname
55 rm -rf uxarc