From ae04de0cb0a8b65548e009b4c3a03ba7f882e95a Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 23 Dec 2006 18:35:21 +0000 Subject: * It turns out that the people who told me that removing a conffile in the preinst was sufficient to have dpkg replace it without prompting when moving a conffile between packages were very much mistaken. As far as I can tell, the only way to do this reliably is to write out the desired new text of the conffile in the preinst. This is gross, and requires shipping the text of all conffiles in the preinst too, but there's nothing for it. Fortunately this nonsense is only required for smooth upgrades from sarge. --- debian/openssh-client.preinst | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'debian/openssh-client.preinst') diff --git a/debian/openssh-client.preinst b/debian/openssh-client.preinst index 0e200712e..9cf29dfba 100644 --- a/debian/openssh-client.preinst +++ b/debian/openssh-client.preinst @@ -1,17 +1,34 @@ #! /bin/sh -e +ETC_SSH_MODULI=@ETC_SSH_MODULI@ + +ETC_SSH_SSH_CONFIG=@ETC_SSH_SSH_CONFIG@ + action="$1" version="$2" prepare_transfer_conffile () { CONFFILE="$1" + TEXT="$2" + MODE="$3" [ -e "$CONFFILE" ] || return 0 md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')" old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)" if [ "$md5sum" = "$old_md5sum" ]; then echo >&2 "Transferring ownership of conffile $CONFFILE ..." + # We have to write out the desired new text of the conffile, + # which is tricky in the preinst, hence the nasty way we + # have to hardcode the text here. Fortunately, this is only + # necessary with sarge's dpkg and older. + if echo "$TEXT" | head -n1 | grep -q '^@.*@$'; then + echo >&2 'Unsubstituted conffile text! Please report this bug.' + exit 1 + fi + printf '%s' "$TEXT" >"$CONFFILE.dpkg-new" + chmod "$MODE" "$CONFFILE.dpkg-new" mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst" + mv -f "$CONFFILE.dpkg-new" "$CONFFILE" return 0 fi } @@ -19,8 +36,8 @@ prepare_transfer_conffile () { case $action in install|upgrade) if dpkg --compare-versions "$version" lt 0; then - prepare_transfer_conffile /etc/ssh/moduli - prepare_transfer_conffile /etc/ssh/ssh_config + prepare_transfer_conffile /etc/ssh/moduli "$ETC_SSH_MODULI" 0644 + prepare_transfer_conffile /etc/ssh/ssh_config "$ETC_SSH_SSH_CONFIG" 0644 fi ;; esac -- cgit v1.2.3