]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - do_release
Correct maintscript syntax
[mirror_smartmontools-debian.git] / do_release
1 #!/bin/bash
2 #
3 # do a smartmontools release
4 # (C) 2003-11 Bruce Allen <ballen4705@users.sourceforge.net>,
5 # Guido Guenther <agx@sigxcpu.org>
6 # (C) 2006-13 Christian Franke <smartmontools-support@lists.sourceforge.net>
7 # $Id: do_release 3765 2013-02-05 17:17:13Z chrfranke $
8
9 # Notes on generating releases:
10 # (1) update NEWS
11 # (2) update ChangeLog -- put in release number
12 # (3) update release number in configure.ac
13 # (4) to test, run without '--commit'
14 # (5) when satisfied, add option '--commit'
15
16 set -e
17
18 # Smartmontools Signing Key (through 2014)
19 KEYID=0x8F6ED8AA
20
21 inc_release()
22 {
23 MINOR=`echo $VERSION | cut -d. -f2`
24 MAJOR=`echo $VERSION | cut -d. -f1`
25 PERL_OLD=$MAJOR\\.$MINOR
26 ((++MINOR))
27 NEW_VERSION=$MAJOR.$MINOR
28 PERL_NEW=$MAJOR\\.$MINOR
29 NEW_RELEASE="RELEASE_${NEW_VERSION//\./_}"
30 echo "New Version: $NEW_VERSION"
31 echo "New Release: $NEW_RELEASE"
32 }
33
34 COMMIT=
35 RC=
36
37 case "$1" in
38 --commit) COMMIT=yes; shift ;;
39 esac
40
41 case "$*" in
42 RC[1-9]) RC="$1" ;;
43 FINAL) ;;
44 *) echo "Usage: $0 [--commit] RC[1-9]|FINAL"; exit 1 ;;
45 esac
46
47 # Check workdir
48 case "`/bin/pwd`" in
49 */trunk/smartmontools) WDROOT="../.."; DIRPAT="trunk" ;;
50 */branches/*/smartmontools) WDROOT="../../.."; DIRPAT="branches/*" ;;
51 *) echo "`/bin/pwd`: no trunk or branch working dir"; exit 1 ;;
52 esac
53
54 if [ ! -d "$WDROOT/tags" ]; then
55 echo "tags directory missing"; exit 1
56 fi
57
58 REVX="`(cd $WDROOT && svnversion)`" || exit 1
59 REV="${REVX/%[PM]/}"; REV="${REV/%[PM]/}"
60 if [ -n "${REV//[0-9]/}" ]; then
61 echo "Working directory not clean: $REVX"; exit 1
62 fi
63
64 (cd $WDROOT && svn status) | while read s; do
65 case "`echo $s | tr -s ' '`" in
66 "M "$DIRPAT/smartmontools/ChangeLog) echo "$s: OK";;
67 "M "$DIRPAT/smartmontools/NEWS) echo "$s: OK";;
68 "M "$DIRPAT/smartmontools/configure.ac) echo "$s: OK";;
69 *) echo "$s: not allowed"; exit 1;;
70 esac
71 done
72 if [ $? -ne 0 ]; then
73 exit 1
74 fi
75
76 # Get release number
77 VERSION=`sed -n 's|^AC_INIT[^,]*, *\([0-9.]*\) *,.*$|\1|p' configure.ac`
78 if [ -z "$VERSION" ]; then
79 echo "AC_INIT not found in configure.ac"; exit 1
80 fi
81 VERSIONRC="$VERSION"
82 RELEASE="RELEASE_${VERSION//\./_}"
83
84 if [ "$RC" ]; then
85 VERSIONRC="${VERSION}-${RC/#RC/rc}"
86 RELEASE="${RELEASE}_${RC}"
87 fi
88
89 if [ -e "$WDROOT/tags/$RELEASE" ]; then
90 echo "tags/$RELEASE exists"; exit 1
91 fi
92
93 echo "r$REV: Release $VERSIONRC $RELEASE"
94
95 # Update timestamp
96 smartmontools_release_date=`date -u +"%Y-%m-%d"`
97 smartmontools_release_time=`date -u +"%T %Z"`
98 cat configure.ac | sed "s|smartmontools_release_date=.*|smartmontools_release_date=${smartmontools_release_date}|" > configure.tmp
99 cat configure.tmp | sed "s|smartmontools_release_time=.*|smartmontools_release_time=\"${smartmontools_release_time}\"|" > configure.ac
100 rm -f configure.tmp
101
102 # Review changes
103 svn diff
104 echo "==================================================================="
105 echo ">>> Continuing in 20 seconds ..."
106 sleep 20
107 set -v
108
109 # Create tag and commit
110 if [ "$COMMIT" = "yes" ]; then
111 svn mkdir $WDROOT/tags/$RELEASE
112 svn copy ../smartmontools $WDROOT/tags/$RELEASE/smartmontools
113 svn commit -m "Release $VERSIONRC $RELEASE" $WDROOT
114 fi
115
116 # Build
117 ./autogen.sh
118
119 mkdir build
120 cd build
121 ../configure
122 make distcheck || exit 1
123 make maintainer-clean
124 cd ..
125
126 TARFILE=smartmontools-$VERSIONRC.tar.gz
127
128 mv -f build/smartmontools-$VERSION.tar.gz $TARFILE
129 rm -rvf build
130
131 md5sum $TARFILE > $TARFILE.md5
132
133 # Increase release number
134 if [ -z "$RC" -a "$DIRPAT" = "trunk" ]; then
135 inc_release
136 if [ "$COMMIT" = "yes" ]; then
137 perl -p -i.bak -e "s/$PERL_OLD/$PERL_NEW/" configure.ac
138 # svn commit -m "Bump release number to $NEW_VERSION" configure.ac
139 fi
140 fi
141
142 # Sign tarball
143 if [ -n "$KEYID" ] && gpg --list-secret-keys $KEYID >/dev/null 2>/dev/null; then
144 gpg --default-key $KEYID --armor --detach-sign ./smartmontools-$VERSIONRC.tar.gz
145 fi
146