r2033: move initialize code for better .system compilation
[clsql.git] / make-upstream.sh
1 #!/bin/bash 
2 #
3 # Creates upstream packages
4 # Programmer: Kevin Rosenberg
5
6 set -e # abort on error
7
8 usage () {
9     progname="`basename \"$0\"`"
10
11     cat >&2 <<EOF
12 Usage: $progname [options]
13 Creates upstream archives
14 Options:
15   -c   Commit and tag CVS tree with current version numbers
16   -t   Tag CVS tree with current version numbers
17   -h   Print this brief help
18 EOF
19 }
20
21 # Command line
22 while [ $# != 0 ]; do
23     value="`echo x\"$1\" | sed -e 's/^x-.//'`"
24     case "$1" in
25         -h)  usage; exit 0           ;;
26         -c)  opt_commit=1; opt_tag=1 ;;
27         -t)  opt_tag=1               ;;
28          *)  usage; exit 0           ;;
29     esac
30     shift
31 done
32
33 DEBPKG=cl-sql
34 PKG=clsql
35 TOPDIR=`pwd`
36
37 VERSION=`sed -n -e "s/${DEBPKG} (\(.*\)-[0-9.]).*/\1/p" < debian/changelog  |head -1`
38
39 PACKAGE_DIR=/usr/local/src/Packages/${DEBPKG}
40 DISTDIR=${PKG}-${VERSION}
41 DEBDIR=${DEBPKG}-${VERSION}
42
43 if [ ! -z ${opt_commit} ]; then
44     cvs commit -m 'Debian build'
45 fi
46
47 if [ ! -z ${opt_tag} ]; then
48     UPSTREAM_TAG=upstream_version_`echo ${VERSION} | tr . _`
49     echo "(Re-)tagging with Upstream tag '${UPSTREAM_TAG}'"
50     cvs -q rtag -d $UPSTREAM_TAG $PKG > /dev/null
51     cvs -q tag -F $UPSTREAM_TAG > /dev/null
52
53 fi
54
55 if [ -f ${PACKAGE_DIR}/${DEBPKG}_${VERSION}.orig.tar.gz ]; then
56   echo "File ${PACKAGE_DIR}/${DEBPKG}_${VERSION}.orig.tar.gz already exists."
57   echo -n "Are you sure that you want to create a new upstream archive? (y/N): "
58   read answer
59   case $answer in
60       [Yy]*) nop= ;;
61       *) echo "Not building"
62          exit 1
63           ;;
64   esac
65 fi
66
67 # Prepare for archive
68 cd ..
69 rm -f ${PKG}_${VERSION}.tar.gz ${DEBPKG}_${VERSION}.orig.tar.gz
70 rm -rf ${DISTDIR} ${DEBDIR} ${DISTDIR}.zip
71 cp -a ${TOPDIR} ${DISTDIR}
72
73 echo "Cleaning distribution directory ${DISTDIR}"
74 cd ${DISTDIR}
75 rm -f upload.sh make-debian.sh make-upstream.sh cvsbp-prepare.sh 
76 rm -f test-suite/test.config
77 rm -f `find . -type f -name .cvsignore`
78 rm -rf `find . -type d -name CVS`
79 rm -f `find . -type f -name '*~' -or -name '.#*'  -or -name '#*#' -or -name ".*~"`
80 rm -f `find doc -type f -name \*.tex -or -name \*.aux -or \
81   -name \*.log -or -name \*.out -or -name \*.dvi`
82 cd ..
83
84 echo "Creating upstream archives"
85 rm -rf ${DISTDIR}/debian
86 GZIP=-9 tar czf ${DISTDIR}.tar.gz ${DISTDIR}
87
88 cp -a ${DISTDIR} ${DEBDIR}
89 GZIP=-9 tar czf ${DEBPKG}_${VERSION}.orig.tar.gz ${DEBDIR}
90
91 unix2dos `find ${DISTDIR} -type f -name \*.cl -or -name \*.list -or \
92     -name \*.system -or -name Makefile -or -name ChangeLog -or \
93     -name COPYRIGHT -or -name TODO -or -name README -or -name INSTALL -or \
94     -name NEWS -or -name \*.sgml -or -name COPYING\* -or -name catalog`
95 zip -rq ${DISTDIR}.zip ${DISTDIR}
96
97 cp -a ${TOPDIR}/debian ${DEBDIR}
98 rm -f ${DEBDIR}/debian/.cvsignore 
99 rm -rf ${DEBDIR}/debian/CVS
100
101 rm -rf ${DISTDIR} ${DEBDIR}
102
103 echo "Moving upstream archives to ${PACKAGE_DIR}"
104 mkdir -p /usr/local/src/Packages/${DEBPKG}
105 rm -f ${PACKAGE_DIR}/${DISTDIR}.zip ${PACKAGE_DIR}/${DEBPKG}_${VERSION}.orig.tar.gz
106 mv ${DISTDIR}.zip ${DEBPKG}_${VERSION}.orig.tar.gz ${DISTDIR}.tar.gz ${PACKAGE_DIR}
107
108 cd ${TOPDIR}
109 exit 0