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