Improve Berkeley DB upgrade code to note the used version and compare it with used version
Ondřej Surý
12 years ago
23 | 23 | # from having to guess our platform (since we know it already). |
24 | 24 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) |
25 | 25 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) |
26 | ||
27 | BDB_VERSION ?= $(shell LC_ALL=C dpkg-query -l 'libdb[45].[0-9]-dev' | grep ^ii | sed -e 's|.*\s\libdb\([45]\.[0-9]\)-dev\s.*|\1|') | |
26 | 28 | |
27 | 29 | include /usr/share/quilt/quilt.make |
28 | 30 | |
244 | 246 | cd $(TMPBUILD_MIT) && $(MAKE) install DESTDIR=$(TMPPKG_MIT) |
245 | 247 | cd $(TMPBUILD_HEIMDAL) && $(MAKE) install DESTDIR=$(TMPPKG_HEIMDAL) |
246 | 248 | |
249 | # Note the version of Berkeley DB used to build this package | |
250 | echo $(BDB_VERSION) > $(TMPPKG_MIT)/usr/lib/sasl2/berkeley_db.txt | |
251 | ||
247 | 252 | # Alter the default location and names of files to fit Debian |
248 | 253 | # policy and better integrate with the Debian system. |
249 | 254 | mv $(TMPPKG_MIT)/usr/sbin/pluginviewer $(TMPPKG_MIT)/usr/sbin/saslpluginviewer |
21 | 21 | # 2.1.22.dfsg1-17 (db4.4 -> db4.6) |
22 | 22 | # 2.1.22.dfsg1-24 (db4.6 -> db4.7) |
23 | 23 | # 2.1.23.dfsg1-4 (db4.7 -> db4.8) |
24 | if dpkg --compare-versions "$2" "lt-nl" 2.1.23.dfsg1-4; then | |
25 | ||
26 | # If the database contains no users, just wipe it out, | |
27 | # it will be recreated later in the current format | |
28 | if [ -e $SASLDB_FILE ] && \ | |
29 | [ `sasldblistusers2 | wc -l` -eq 0 ]; then | |
30 | rm $SASLDB_FILE | |
31 | elif [ -e $SASLDB_FILE ]; then | |
24 | # 2.1.23.dfsg1-8 (db4.8 -> db5.1) | |
25 | ||
26 | if [ -r /usr/lib/sasl2/berkeley_db.active ]; then | |
27 | OLD_BDB=$(cat /usr/lib/sasl2/berkeley_db.active) | |
28 | else | |
29 | if dpkg --compare-versions "$2" "lt-nl" 2.1.23.dfsg1-4; then | |
30 | OLD_BDB=4.7 | |
31 | elif dpkg --compare-versions "$2" "lt-nl" 2.1.23.dfsg1-9; then | |
32 | OLD_BDB=4.8 | |
33 | fi | |
34 | fi | |
35 | ||
36 | # Read the compiled-in Berkeley DB version | |
37 | NEW_BDB=$(cat /usr/lib/sasl2/berkeley_db.txt) | |
38 | ||
39 | if [ "$OLD_BDB" != "$NEW_BDB" ]; then | |
40 | if [ -e $SASLDB_FILE ]; then | |
32 | 41 | # The database exists and has users, begin upgrade procedure |
42 | # | |
43 | # Well, this code doesn't break anything, but since Cyrus SASL | |
44 | # doesn't use transactional environment and the database format | |
45 | # was not changed since db3 it also doesn't do anything at all | |
33 | 46 | |
34 | 47 | # Make backup and handle errors |
35 | 48 | db_get cyrus-sasl2/backup-sasldb2 |
40 | 53 | fi |
41 | 54 | |
42 | 55 | # Upgrade SASL database and handle errors |
43 | if ! db4.8_upgrade $SASLDB_FILE >/dev/null 2>&1; then | |
56 | if ! db${NEW_BDB}_upgrade $SASLDB_FILE >/dev/null 2>&1; then | |
44 | 57 | db_input high cyrus-sasl2/upgrade-sasldb2-failed || true |
45 | 58 | db_go || true |
46 | 59 | cp --archive "$RET" $SASLDB_FILE >/dev/null 2>&1 |
47 | 60 | exit 1 |
48 | 61 | fi |
49 | 62 | fi |
63 | ||
64 | # Note the active Berkeley DB version | |
65 | cp -f /usr/lib/sasl2/berkeley_db.txt /usr/lib/sasl2/berkeley_db.active | |
50 | 66 | fi |
51 | 67 | |
52 | 68 | # Create a statoverride for the default saslauthd run directory, |
0 | #!/bin/sh | |
1 | # preinst script for sasl2-bin | |
2 | # | |
3 | # see: dh_installdeb(1) | |
4 | ||
5 | set -e | |
6 | ||
7 | # summary of how this script can be called: | |
8 | # * <new-preinst> `install' | |
9 | # * <new-preinst> `install' <old-version> | |
10 | # * <new-preinst> `upgrade' <old-version> | |
11 | # * <old-preinst> `abort-upgrade' <new-version> | |
12 | # for details, see http://www.debian.org/doc/debian-policy/ or | |
13 | # the debian-policy package | |
14 | ||
15 | SASLDB_FILE=/etc/sasldb2 | |
16 | ||
17 | case "$1" in | |
18 | install) | |
19 | ;; | |
20 | ||
21 | upgrade) | |
22 | # If the database contains no users, just wipe it out, | |
23 | # it will be recreated later in the current format | |
24 | if [ -e $SASLDB_FILE ] && [ "$(sasldblistusers2 | wc -l)" -eq 0 ]; then | |
25 | rm -f $SASLDB_FILE | |
26 | fi | |
27 | ;; | |
28 | ||
29 | abort-upgrade) | |
30 | ;; | |
31 | ||
32 | *) | |
33 | echo "preinst called with unknown argument \`$1'" >&2 | |
34 | exit 1 | |
35 | ;; | |
36 | esac | |
37 | ||
38 | # dh_installdeb will replace this with shell code automatically | |
39 | # generated by other debhelper scripts. | |
40 | ||
41 | #DEBHELPER# | |
42 | ||
43 | exit 0 |