Codebase list cyrus-sasl2 / 764e29a
Improve Berkeley DB upgrade code to note the used version and compare it with used version Ondřej Surý 12 years ago
4 changed file(s) with 75 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
00 usr/lib/libsasl2.so.*
11 usr/lib/sasl2/libsasldb*
2 usr/lib/sasl2/berkeley_db.txt
2323 # from having to guess our platform (since we know it already).
2424 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
2525 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|')
2628
2729 include /usr/share/quilt/quilt.make
2830
244246 cd $(TMPBUILD_MIT) && $(MAKE) install DESTDIR=$(TMPPKG_MIT)
245247 cd $(TMPBUILD_HEIMDAL) && $(MAKE) install DESTDIR=$(TMPPKG_HEIMDAL)
246248
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
247252 # Alter the default location and names of files to fit Debian
248253 # policy and better integrate with the Debian system.
249254 mv $(TMPPKG_MIT)/usr/sbin/pluginviewer $(TMPPKG_MIT)/usr/sbin/saslpluginviewer
2121 # 2.1.22.dfsg1-17 (db4.4 -> db4.6)
2222 # 2.1.22.dfsg1-24 (db4.6 -> db4.7)
2323 # 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
3241 # 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
3346
3447 # Make backup and handle errors
3548 db_get cyrus-sasl2/backup-sasldb2
4053 fi
4154
4255 # 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
4457 db_input high cyrus-sasl2/upgrade-sasldb2-failed || true
4558 db_go || true
4659 cp --archive "$RET" $SASLDB_FILE >/dev/null 2>&1
4760 exit 1
4861 fi
4962 fi
63
64 # Note the active Berkeley DB version
65 cp -f /usr/lib/sasl2/berkeley_db.txt /usr/lib/sasl2/berkeley_db.active
5066 fi
5167
5268 # 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