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.
5 trap 'tput bel || :; echo Failed! >&2' EXIT
7 # Ask the user a yes/no question. This function does not require the user to
8 # press ENTER after making a selection.
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)"
17 " 0a") if [ -n "$1" ]; then
18 [ $1 -eq 0 ] && echo "Y" || echo "N"
28 "") echo "Aborted" >&2
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 || :
39 # Build Debian package and create all the files that are needed by the
40 # distribution maintainer.
44 # Try to build the package. If things fail, let the exit handler remove all
46 trap 'rm -rf "${prj}-${ver}" "${prj}_${ver}"*' EXIT
48 # Clean up any old temporary files
49 rm -rf "${prj}-${ver}" "${prj}_${ver}"*
51 # Extract the distribution source archive
52 tar zfx "${prj}-${ver}.tar.gz"
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
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"
65 # Reset compatibility level
66 echo 7 >"${prj}-${ver}/debian/compat"
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"
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
78 # Build Debian packages.
80 fakeroot dpkg-buildpackage -sa -us -uc || :)
84 lintian --verbose -I ${prj}_${ver}*_*.changes
87 # Revert any changes that might be pending in distributions/debian/*
88 local revert="$(svn st |
89 grep distributions/debian |
93 if [ -n "${revert}" ]; then
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}"
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')
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}"[-.]*.*
120 # Let the caller know that we added new packages.
124 # Quick sanity check that we are running from the correct directory
127 # Make sure there are no stale files
130 # Determine Subversion revision number, project name, and public version
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)"
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.
141 sed -i -e 's/^\(VCS_REVISION=\).*/\1'"${rev}"'/' configure.ac
142 touch shellinabox/vt100.jspp shellinabox/shell_in_a_box.jspp
144 # If the manual page has been changed, make sure that the time stamp will be
146 if [ -n "$(svn st shellinabox/shellinaboxd.man.in 2>/dev/null |
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
153 # Always update the year in the user visible copyright statement(s)
154 for i in shellinabox/shell_in_a_box.jspp \
155 shellinabox/vt100.jspp \
158 sed -i -e 's/\(2[01][0-9][0-9]-\)2[01][0-9][0-9]/\1'"$(date +'%Y')"'/g' "$i"
161 # If a source file has changed, make sure to update the year in the copyright
162 # statement for that particular file.
163 svn st | egrep '^[MA]' | awk '{ print $2 }' |
164 egrep '^(shellinabox|libhttp|demo)/' |
165 egrep '[.](html|h|c|css|jspp)$' |
167 sed -i -e 's/\(2[01][0-9][0-9]-\)2[01][0-9][0-9]/\1'"$(date +'%Y')"'/g' "$f"
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.
174 echo 6 >debian/compat
175 sed -i -e 's/debhelper *([^0-9]*[^)]*)/debhelper (>= 6.0.0)/' debian/control
176 sed -i -e 's/dh_prep/dh_clean *-k/' debian/rules
178 # Build all the sources, create the distribution tar archive, and run some
179 # basic sanity checks.
182 # Build Debian package and create all the files that are needed by the
183 # distribution maintainer.
187 NOTICE: New version released. Please do not forget to notify distributions"
188 if [ -r ~/.shellinabox-notifier ]; then
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"
195 echo "You had previously requested to be notified when this happens."
196 } | mail -s "New ShellInABox release" "$e"
200 NOTICE: Could not find ~/.shellinabox-notifier. Not sending e-mail..."
205 egrep -v ' configure$| aclocal.m4$|distributions|^[?]' |
206 sed -e 's/^[^ ]* *//') | less
207 echo -n 'Commit these changes (Y/n): '