]> andersk Git - test.git/blame - commit
Use 2048-bit RSA keys for auto-generated certificates.
[test.git] / commit
CommitLineData
3a0490f9
MG
1#!/bin/bash -e
2
02cb5113
MG
3# The script ensures that all commands succeed unless an error occurred. If it
4# does though, the shell terminates the script and our exit handler runs.
3a0490f9
MG
5trap 'tput bel || :; echo Failed! >&2' EXIT
6
02cb5113
MG
7# Ask the user a yes/no question. This function does not require the user to
8# press ENTER after making a selection.
3a0490f9
MG
9yes_no() {
10 local c
11 while :; do
12 c="$(set +e
13 trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
14 stty -echo iuclc -icanon 2>/dev/null
15 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
16 case "$c" in
17 " 0a") if [ -n "$1" ]; then
18 [ $1 -eq 0 ] && echo "Y" || echo "N"
19 return $1
20 fi
21 ;;
22 " 79") echo "Y"
23 return 0
24 ;;
25 " 6e") echo "N"
26 return 1
27 ;;
28 "") echo "Aborted" >&2
29 exit 1
30 ;;
31 *) # The user pressed an unrecognized key. As we are not echoing
32 # any incorrect user input, alert the user by ringing the bell.
33 (tput bel) 2>/dev/null || :
34 ;;
35 esac
36 done
37}
38
02cb5113
MG
39# Build Debian package and create all the files that are needed by the
40# distribution maintainer.
41debian_package() {
42 set -e
43 (
44 # Try to build the package. If things fail, let the exit handler remove all
45 # temporary files.
46 trap 'rm -rf "${prj}-${ver}" "${prj}_${ver}"*' EXIT
47
48 # Clean up any old temporary files
49 rm -rf "${prj}-${ver}" "${prj}_${ver}"*
50
51 # Extract the distribution source archive
52 tar zfx "${prj}-${ver}.tar.gz"
53
54 # We want to ship the "debian" directory with the source archive that
55 # users download directly from the project web site. This allows them to
56 # easily build their own Debian package by following the instructions in
57 # INSTALL.Debian.
58 # But when preparing our package for direct integration with Debian-based
59 # distributions, we have to instead remove the "debian" directory, as the
60 # distribution prefers that third-party projects are not built "natively".
61 mv "${prj}-${ver}/debian" "${prj}_${ver}_debian"
62 tar zfc "${prj}_${ver}.orig.tar.gz" "${prj}-${ver}"
63 mv "${prj}_${ver}_debian" "${prj}-${ver}/debian"
64
65 # Reset compatibility level
66 echo 7 >"${prj}-${ver}/debian/compat"
e70a6646
MG
67 sed -i -e 's/debhelper *([^0-9]*[^)]*)/debhelper (>= 7.0.0)/' \
68 "${prj}-${ver}/debian/control"
69 sed -i -e 's/dh_clean *-k/dh_prep/' "${prj}-${ver}/debian/rules"
02cb5113 70
f77e8221
MG
71 # Check that the version number in the debian/changelog file matches
72 if [ "$(sed -e 's/^'"${prj}"' *(\([^-]*\)-.*).*/\1/;t1;d;:1;q' \
73 "${prj}-${ver}/debian/changelog")" != "${ver}" ]; then
74 echo "Debian changelog file does not match current version number!" >&2
75 exit 1
76 fi
77
02cb5113
MG
78 # Build Debian packages.
79 (cd "${prj}-${ver}"
80 fakeroot dpkg-buildpackage -sa -us -uc || :)
81 trap '' EXIT
e70a6646
MG
82
83 # Run lintian
3e80ca60 84 lintian --verbose -I ${prj}_${ver}*_*.changes
f77e8221 85 ) || exit 1
02cb5113
MG
86
87 # Revert any changes that might be pending in distributions/debian/*
88 local revert="$(svn st |
89 grep distributions/debian |
90 grep '^[^?]' |
91 awk '{ print $2 }' |
92 tac)"
93 if [ -n "${revert}" ]; then
94 svn revert ${revert}
95 rm -f ${revert}
96 fi
97
98 # Create distributions/debian if it does not exist yet.
99 mkdir -p distributions/debian
100 for i in distributions distributions/debian; do
101 if [ -z "$(svn st "${i}" 2>/dev/null | grep -v '^[?]')" ]; then
102 svn add --depth=empty "${i}"
103 fi
104 done
105
106 # If this version of files already exists in the distribution directory,
107 # we are not yet ready to cut a new release. Just clean up and exit.
108 for i in "${prj}_${ver}"[-.]*.*; do
109 [ -r "distributions/debian/${i}" ] && {
110 rm $(ls "${prj}_${ver}"[-.]* | egrep -v '_*.changes|_*.deb')
111 return 0
112 }
113 done
114
115 # Move new Debian files into release area.
116 mv $(ls "${prj}_${ver}"[-.]* | egrep -v '_*.changes|_*.deb') \
117 distributions/debian/
118 svn add distributions/debian/"${prj}_${ver}"[-.]*.*
119
120 # Let the caller know that we added new packages.
121 return 1
122}
123
124# Quick sanity check that we are running from the correct directory
3a0490f9 125test -r configure.ac
02cb5113
MG
126
127# Make sure there are no stale files
3a0490f9 128svn update
02cb5113
MG
129
130# Determine Subversion revision number, project name, and public version
131# number
c593cf68 132{
02cb5113
MG
133 rev=$(($(svn info | sed -e 's/^Revision: \(.*\)/\1/;t1;d;:1;q')+1))
134 prj="$(sed -e 's/^AC_INIT(\([^,]*\),.*/\1/;t1;d;:1;q' configure.ac)"
135 ver="$(sed -e 's/^AC_INIT([^,]*, *\([^,]*\),.*/\1/;t1;d;:1;q' configure.ac)"
c593cf68 136} 2>/dev/null
02cb5113
MG
137
138# Update "configure.ac" with the next Subversion revision number. This
139# information will trickle down into various source files where it becomes
140# part of the user-visible version information.
3990005e 141sed -i -e 's/^\(VCS_REVISION=\).*/\1'"${rev}"'/' configure.ac
1cfd1ec8 142touch shellinabox/vt100.jspp shellinabox/shell_in_a_box.jspp
02cb5113 143
3990005e
MG
144# If the manual page has been changed, make sure that the time stamp will be
145# changed, too.
146if [ -n "$(svn st shellinabox/shellinaboxd.man.in 2>/dev/null |
147 grep '^M')" ]; then
148 sed -i -e 's/^\([.]TH .*\)"[^"]*"/\1"'"$(date +'%b %d, %Y')"'"/
149 s/2008-2[01][0-9][0-9]/2008-'"$(date +'%Y')"'/g' \
150 shellinabox/shellinaboxd.man.in
151fi
152
153# Always update the year in the user visible copyright statement(s)
154for i in shellinabox/shell_in_a_box.jspp \
155 shellinabox/vt100.jspp \
156 COPYING \
157 debian/copyright; do
158 sed -i -e 's/\(2[01][0-9][0-9]-\)2[01][0-9][0-9]/\1'"$(date +'%Y')"'/g' "$i"
159done
160
161# If a source file has changed, make sure to update the year in the copyright
162# statement for that particular file.
163svn st | egrep '^[MA]' | awk '{ print $2 }' |
164 egrep '^(shellinabox|libhttp|demo)/' |
165 egrep '[.](html|h|c|css|jspp)$' |
166 while read -r f; do
167 sed -i -e 's/\(2[01][0-9][0-9]-\)2[01][0-9][0-9]/\1'"$(date +'%Y')"'/g' "$f"
168 done
169
02cb5113
MG
170# For now, Ubuntu/Hardy is still quite popular. We want to make it easy for
171# our users to build Debian packages from source. So, make sure we lock the
172# compatibility level at 6. Once we no longer care about maintaining strict
173# backwards compatibility, we can lift this restriction.
af93d23c 174echo 6 >debian/compat
e70a6646
MG
175sed -i -e 's/debhelper *([^0-9]*[^)]*)/debhelper (>= 6.0.0)/' debian/control
176sed -i -e 's/dh_prep/dh_clean *-k/' debian/rules
02cb5113
MG
177
178# Build all the sources, create the distribution tar archive, and run some
179# basic sanity checks.
3a0490f9 180make all distcheck
02cb5113
MG
181
182# Build Debian package and create all the files that are needed by the
183# distribution maintainer.
184msg=
370c62a9 185debian_package || {
02cb5113
MG
186 msg="${msg}
187NOTICE: New version released. Please do not forget to notify distributions"
370c62a9
MG
188 if [ -r ~/.shellinabox-notifier ]; then
189 while read e; do
190 {
191 echo "This is an automatically generated e-mail notification that"
192 echo "a new release of ShellInABox has just been made available"
193 echo "on the project's website at http://shellinabox.com"
194 echo
195 echo "You had previously requested to be notified when this happens."
196 } | mail -s "New ShellInABox release" "$e"
197 done
198 else
199 msg="${msg}
200NOTICE: Could not find ~/.shellinabox-notifier. Not sending e-mail..."
201 fi
202}
02cb5113 203
3a0490f9 204svn diff $(svn st |
02cb5113 205 egrep -v ' configure$| aclocal.m4$|distributions|^[?]' |
3a0490f9
MG
206 sed -e 's/^[^ ]* *//') | less
207echo -n 'Commit these changes (Y/n): '
208yes_no 0 || exit 1
209svn commit
02cb5113 210echo "${msg}"
3a0490f9
MG
211
212trap '' EXIT
213exit 0
This page took 0.106471 seconds and 5 git commands to generate.