# # # patch "debian/changelog" # from [22e601a110b479daf2aca0a708976e37f0f471a0] # to [be8ba8773b3f75642317a363921e96c33b3673d2] # # patch "debian/monotone-server.postinst" # from [cc433d34ac39bc7d01f72fd47449feffac2581fc] # to [d43fc42c6b51df67744169eb7bf9b29b5fa43a08] # # patch "debian/monotone-server.postrm" # from [deae677274c6bc32cf9aa3296ab4e7513e044d84] # to [811119b0d931576b61590c03418117b4a9ab389e] # ============================================================ --- debian/changelog 22e601a110b479daf2aca0a708976e37f0f471a0 +++ debian/changelog be8ba8773b3f75642317a363921e96c33b3673d2 @@ -7,6 +7,18 @@ monotone (0.36-1) unstable; urgency=low * Bump debhelper build-dep to (>= 4.2.0) per cdbs docs. * Run testsuite during build. * Drop libboost-filesystem-dev build-dependency. + * monotone-server.postinst, monotone-server.postrm: Do not assume + full pathnames of ucf or adduser. Use ucfr as well as ucf. + At purge time: + - do not assume ucf, adduser, or debconf are available (closes: #434604). + - if not asked to manage the database, do not delete it. + - if deleting the database and there is a hot journal, delete that too. + - delete editor backups of ucf-managed conffiles. + - expunge the auto-generated key's passphrase from + /etc/monotone/passphrases and if that leaves the file empty, + delete it. + - do not delete the monotone user or group if leaving /var/lib/monotone + on the filesystem. -- Richard Levitte Thu, 02 Aug 2007 21:56:21 +0200 ============================================================ --- debian/monotone-server.postinst cc433d34ac39bc7d01f72fd47449feffac2581fc +++ debian/monotone-server.postinst d43fc42c6b51df67744169eb7bf9b29b5fa43a08 @@ -112,15 +112,19 @@ case "$1" in MTN_CONFDIR=/etc/monotone MTN_KEYDIR=$MTN_HOME/keys - /usr/bin/ucf --debconf-ok /usr/share/doc/monotone-server/examples/write-permissions /etc/monotone/write-permissions - /usr/bin/ucf --debconf-ok /usr/share/doc/monotone-server/examples/read-permissions /etc/monotone/read-permissions - /usr/bin/ucf --debconf-ok /usr/share/doc/monotone/contrib/get_passphrase_from_file.lua /etc/monotone/hooks.lua + ucf --debconf-ok /usr/share/doc/monotone-server/examples/write-permissions /etc/monotone/write-permissions + ucf --debconf-ok /usr/share/doc/monotone-server/examples/read-permissions /etc/monotone/read-permissions + ucf --debconf-ok /usr/share/doc/monotone/contrib/get_passphrase_from_file.lua /etc/monotone/hooks.lua + + ucfr monotone-server /etc/monotone/write-permissions + ucfr monotone-server /etc/monotone/read-permissions + ucfr monotone-server /etc/monotone/hooks.lua # if this is our first install give config files correct permissions if [ -z "$2" ]; then # create monotone user and fix permissions of files if [ -z "`id -u monotone 2>/dev/null`" ]; then - /usr/sbin/adduser --system --group --home $MTN_HOME \ + adduser --system --group --home $MTN_HOME \ --no-create-home --disabled-password --quiet \ --gecos "Monotone" monotone ============================================================ --- debian/monotone-server.postrm deae677274c6bc32cf9aa3296ab4e7513e044d84 +++ debian/monotone-server.postrm 811119b0d931576b61590c03418117b4a9ab389e @@ -18,38 +18,84 @@ set -e # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package -# source debconf stuff -. /usr/share/debconf/confmodule - case "$1" in purge) - db_get monotone-server/key - MTN_KEY="$RET" - MTN_DB=default.mtn + # note: when executing in this mode, this script cannot assume + # the existence of _any_ of the package dependencies. it must + # work using only Essential packages. hence, in several cases + # below we do cleanups only if the relevant program exists. - # remove configs from ucf database and filesystem - /usr/bin/ucf --purge /etc/monotone/write-permissions - /usr/bin/ucf --purge /etc/monotone/read-permissions - /usr/bin/ucf --purge /etc/monotone/hooks.lua + # remove config files from ucf database and filesystem + for conf in write-permissions read-permissions hooks.lua; do - rm -f /etc/monotone/write-permissions || true - rm -f /etc/monotone/read-permissions || true - rm -f /etc/monotone/hooks.lua || true + # mimic dpkg and remove backups too + for ext in '' '~' '%' .bak .ucf-new .ucf-old .ucf-dist; do + rm -f /etc/monotone/$conf$ext || true + done - if [ -n "`id -u monotone 2>/dev/null`" ]; then - /usr/sbin/deluser --quiet monotone 2>/dev/null >/dev/null - fi + # clear entries in ucf database + # note: we cannot assume ucf is still installed at this point + # (if it isn't, we don't need to worry about its database) + if which ucf > /dev/null; then + ucf --purge /etc/monotone/$conf + fi + if which ucfr > /dev/null; then + ucfr --purge monotone-server /etc/monotone/$conf + fi + done - if [ -n "`id -g monotone 2>/dev/null`" ]; then - /usr/sbin/delgroup --quiet monotone 2>/dev/null >/dev/null + # if debconf still exists and we were asked to auto-manage the + # database, delete the auto-generated key and database. don't + # delete anything else in /var/lib/monotone - there might be + # hand-created databases and keys that the admin wants to keep. + # in any case remove /var/lib/monotone(/keys) if empty. + + if [ -e /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule + + db_get monotone-server/manage-db + if [ "$RET" = true ]; then + db_get monotone-server/key + rm -f /var/lib/monotone/keys/"$RET" + + rm -f /var/lib/monotone/default.mtn + rm -f /var/lib/monotone/default.mtn-journal + + grep -v "$RET" /etc/monotone/passphrases \ + > /etc/monotone/passphrases.dpkg-new || true + if [ -s /etc/monotone/passphrases.dpkg-new ]; then + mv -f /etc/monotone/passphrases.dpkg-new \ + /etc/monotone/passphrases + else + rm -f /etc/monotone/passphrases.dpkg-new \ + /etc/monotone/passphrases + fi + + fi + # do not stop debconf, the debhelper additions will need it. fi - - # delete the auto-generated key and database. don't delete - # anything else in /var/lib/monotone - there might be - # hand-created databases and keys that the admin wants to keep. - rm -f /var/lib/monotone/$MTN_DB /var/lib/monotone/keys/$MTN_KEY - rmdir --ignore-fail-on-non-empty /var/lib/monotone/keys /var/lib/monotone + rmdir --ignore-fail-on-non-empty /var/lib/monotone/keys + rmdir --ignore-fail-on-non-empty /var/lib/monotone + # if deluser/delgroup exist, remove the server user and group. + # do not do this if /var/lib/monotone still exists (so that it + # will still have a named user owning it). + if which deluser > /dev/null && [ ! -e /var/lib/monotone ]; then + if [ -n "`id -u monotone 2>/dev/null`" ]; then + deluser --quiet monotone 2>/dev/null >/dev/null + fi + + if [ -n "`id -g monotone 2>/dev/null`" ]; then + delgroup --quiet monotone 2>/dev/null >/dev/null + fi + else + if [ -e /var/lib/monotone ]; then + reason="/var/lib/monotone still exists" + else + reason="deluser is not available" + fi + echo "warning: not deleting monotone user or group because $reason" >&2 + fi ;; remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; @@ -60,9 +106,6 @@ esac esac -# Stop debconf -db_stop - # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts.