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