forked from google/xsecurelock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-release.sh
executable file
·110 lines (99 loc) · 2.33 KB
/
build-release.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
#!/bin/sh
set -ex
thisversion=$(grep '^define(\[thisversion\],\[' configure.ac | cut -d '[' -f 3 | cut -d ']' -f 1)
nextversion=$(grep '^define(\[nextversion\],\[' configure.ac | cut -d '[' -f 3 | cut -d ']' -f 1)
if [ x"$thisversion" = x"$nextversion" ]; then
echo >&2 "Please bump nextversion in configure.ac first!"
echo >&2 "Follow semantic versioning when doing so."
echo >&2 "Changes since last version:"
git log v"$thisversion".. >&2
exit 1
fi
# Inform caller about semver requirements.
if git grep "REMOVE IN v${nextversion%%.*}\\>" .; then
echo >&2 'Stuff to do before next semver!'
exit 1
fi
# Are we on master?
if [ x"$(git rev-parse --abbrev-ref HEAD)" != x'master' ]; then
echo >&2 'Must be on master.'
exit 1
fi
# Bump the version.
sed -i -e '
s/^define(\[thisversion\],\[.*/define([thisversion],['"$nextversion"'])/
' configure.ac
# Generate a tarball.
tardir=xsecurelock-$nextversion
tarball=$tardir.tar.gz
rm -f "$tarball"
sh autogen.sh
./config.status --recheck || ./configure --with-pam-service-name=common-auth
make clean
rm -f version.c
make dist GIT_VERSION=v$nextversion
ls -l "$tarball"
# Extra stuff added by "make dist".
tar_extra="
Makefile.in
aclocal.m4
compile
configure
depcomp
install-sh
missing
version.c
"
# Stuff that only makes sense to have in git.
git_extra="
.gitignore
build-release.sh
"
# Compare tarball to git file listing.
tar_content=$(tar tf "$tarball" | cut -d / -f 2- | grep '[^/]$')
git_content=$(git ls-files -c)
tar_only=$(
{
echo "$tar_content"
echo "$tar_extra"
echo "$tar_extra"
echo "$git_content"
echo "$git_content"
} | sort | uniq -u
)
git_only=$(
{
echo "$tar_content"
echo "$tar_content"
echo "$git_extra"
echo "$git_extra"
echo "$git_content"
} | sort | uniq -u
)
if [ -n "$tar_only" ]; then
echo >&2 "tar only: " $tar_only
exit 1
fi
if [ -n "$git_only" ]; then
echo >&2 "git only: " $git_only
exit 1
fi
# Do a test build.
rm -rf "$tardir"
tar xvf "$tarball"
cd "$tardir"
grep "$nextversion" version.c
./configure --with-pam-service-name=common-auth
make
make install DESTDIR=$PWD/tmp
find tmp
cd ..
rm -rf "$tardir"
# Confirm OK.
set +x
echo 'You may now tag the release:'
echo " git commit -a -m 'Bump version to $nextversion.'"
echo " git tag -a v$nextversion"
echo " git push origin HEAD"
echo " git push origin tag v$nextversion"
echo "Then upload $tarball to github."