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