-
Notifications
You must be signed in to change notification settings - Fork 9
/
dist.sh
executable file
·136 lines (106 loc) · 2.96 KB
/
dist.sh
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
#!/bin/sh
REPOS="https://svn.apache.org/repos/asf/serf"
if test $# != 1; then
echo "USAGE: $0 TAG"
exit 1
fi
version=$1
# provide for examining dist.sh output before creating a tag
if test "${version}" = "trunk"; then
url="${REPOS}/trunk"
else
url="${REPOS}/tags/${version}"
fi
release="serf-${version}"
# on Mac OS, TMPDIR is scary long. we want an unexpanded form in $short
work="${TMPDIR-/tmp}/serf-dist.$$"
short='${TMPDIR}'/serf-dist.$$
echo "Preparing ${release} in ${short} ..."
mkdir "${work}"
cd "${work}"
echo "Exporting latest serf ..."
svn export --quiet "${url}" "${release}" || exit 1
echo "`find ${release} -type f | wc -l` files exported"
prepare_directory()
{
cd "${release}"
# Remove anything that should not be in the distribution
echo "Removing from release: dist.sh STATUS"
rm dist.sh
[ -r STATUS ] && rm STATUS
major="`sed -n '/SERF_MAJOR_VERSION/s/[^0-9]*//gp' serf.h`"
minor="`sed -n '/SERF_MINOR_VERSION/s/[^0-9]*//gp' serf.h`"
patch="`sed -n '/SERF_PATCH_VERSION/s/[^0-9]*//gp' serf.h`"
actual_version="${major}.${minor}.${patch}"
cd "${work}"
if test "${version}" != "trunk" -a "${version%%-*}" != "${actual_version}"; then
echo "ERROR: exported version '${actual_version}' does not match '${version}'"
exit 1
fi
}
prepare_directory
tarball="${work}/${release}.tar"
tar -cf "${tarball}" "${release}"
bzip2 "${tarball}"
echo "${short}/${release}.tar.bz2 ready."
# Let's redo everything for a Windows .zip file
echo "Saving ${release} as ${release}.unix"
mv "${release}" "${release}.unix"
echo "Exporting latest serf using CRLF ..."
svn export --native-eol=CRLF --quiet "${url}" "${release}" || exit 1
echo "`find ${release} -type f | wc -l` files exported"
prepare_directory
if ! diff -brq "${release}.unix" "${release}"; then
echo "ERROR: export directories differ."
exit 1
fi
zipfile="${work}/${release}.zip"
zip -9rq "${zipfile}" "${release}"
echo "${short}/${release}.zip ready."
echo "Saving ${release} as ${release}.win"
mv "${release}" "${release}.win"
cd ${work}
# allow checksum tool names to be overridden
[ -n "$MD5SUM" ] || MD5SUM=md5sum
[ -n "$SHA1SUM" ] || SHA1SUM=sha1sum
[ -n "$SHA512SUM" ] || SHA512SUM=sha512sum
echo ""
echo "Done:"
sign_file()
{
if [ -n "$SIGN" ]; then
type gpg > /dev/null 2>&1
if [ $? -eq 0 ]; then
if test -n "$user"; then
args="--default-key $user"
fi
for ARG in $@
do
gpg --armor $args --detach-sign $ARG
done
else
type pgp > /dev/null 2>&1
if [ $? -eq 0 ]; then
if test -n "$user"; then
args="-u $user"
fi
for ARG in $@
do
pgp -sba $ARG $args
done
fi
fi
fi
}
ls -l "${release}.tar.bz2" "${release}.zip"
sign_file ${release}.tar.bz2 ${release}.zip
echo ""
echo "md5sums:"
$MD5SUM "${release}.tar.bz2" "${release}.zip"
echo ""
echo "sha1sums:"
$SHA1SUM "${release}.tar.bz2" "${release}.zip"
echo ""
echo "sha512sums:"
$SHA512SUM "${release}.tar.bz2" "${release}.zip"
echo ""