summaryrefslogtreecommitdiff
path: root/debian/openssh-client.preinst
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2006-12-23 18:35:21 +0000
committerColin Watson <cjwatson@debian.org>2006-12-23 18:35:21 +0000
commitae04de0cb0a8b65548e009b4c3a03ba7f882e95a (patch)
tree002b0415576f0581ef3f866261951ddb9fe2eb8b /debian/openssh-client.preinst
parent309e8aeed9f3d4b7b5e9ad7089889533023b6e73 (diff)
* 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.
Diffstat (limited to 'debian/openssh-client.preinst')
-rw-r--r--debian/openssh-client.preinst21
1 files changed, 19 insertions, 2 deletions
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 @@
1#! /bin/sh -e 1#! /bin/sh -e
2 2
3ETC_SSH_MODULI=@ETC_SSH_MODULI@
4
5ETC_SSH_SSH_CONFIG=@ETC_SSH_SSH_CONFIG@
6
3action="$1" 7action="$1"
4version="$2" 8version="$2"
5 9
6prepare_transfer_conffile () { 10prepare_transfer_conffile () {
7 CONFFILE="$1" 11 CONFFILE="$1"
12 TEXT="$2"
13 MODE="$3"
8 [ -e "$CONFFILE" ] || return 0 14 [ -e "$CONFFILE" ] || return 0
9 15
10 md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')" 16 md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')"
11 old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)" 17 old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)"
12 if [ "$md5sum" = "$old_md5sum" ]; then 18 if [ "$md5sum" = "$old_md5sum" ]; then
13 echo >&2 "Transferring ownership of conffile $CONFFILE ..." 19 echo >&2 "Transferring ownership of conffile $CONFFILE ..."
20 # We have to write out the desired new text of the conffile,
21 # which is tricky in the preinst, hence the nasty way we
22 # have to hardcode the text here. Fortunately, this is only
23 # necessary with sarge's dpkg and older.
24 if echo "$TEXT" | head -n1 | grep -q '^@.*@$'; then
25 echo >&2 'Unsubstituted conffile text! Please report this bug.'
26 exit 1
27 fi
28 printf '%s' "$TEXT" >"$CONFFILE.dpkg-new"
29 chmod "$MODE" "$CONFFILE.dpkg-new"
14 mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst" 30 mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst"
31 mv -f "$CONFFILE.dpkg-new" "$CONFFILE"
15 return 0 32 return 0
16 fi 33 fi
17} 34}
@@ -19,8 +36,8 @@ prepare_transfer_conffile () {
19case $action in 36case $action in
20 install|upgrade) 37 install|upgrade)
21 if dpkg --compare-versions "$version" lt 0; then 38 if dpkg --compare-versions "$version" lt 0; then
22 prepare_transfer_conffile /etc/ssh/moduli 39 prepare_transfer_conffile /etc/ssh/moduli "$ETC_SSH_MODULI" 0644
23 prepare_transfer_conffile /etc/ssh/ssh_config 40 prepare_transfer_conffile /etc/ssh/ssh_config "$ETC_SSH_SSH_CONFIG" 0644
24 fi 41 fi
25 ;; 42 ;;
26esac 43esac