tags 618708 + patch quit Marc Haber wrote:
> git uses dpkg-maintscript-helper, which isn't present in lenny's dpkg. > it should therefore have a versioned dpkg dependency. Sorry for the lack of sanity. How about this? -- 8< -- Subject: debian: stop using dpkg-maintscript-helper git doesn't demand much from dpkg-maintscript-helper. Replace invocations with simple shell snippets. This avoids adding Pre-Depends: dpkg (>= 1.15.7.2) in backports to squeeze and depending on a backport of dpkg in backports to lenny (and avoids similar increases in complexity in downstreams with different release schedules). Thanks to Marc and Anders for their persistence in explaining the relevant issues (and others on debian-devel for some related discussion). Reported-by: Anders Kaseorg <[email protected]> Reported-by: Marc Haber <[email protected]> Fixes: http://bugs.debian.org/618708 Signed-off-by: Jonathan Nieder <[email protected]> --- debian/changelog | 7 ++++++- debian/git.postinst | 27 +++++++++++++++++++++++---- debian/git.postrm | 28 ++++++++++++++++++++++++---- debian/git.preinst | 27 ++++++++++++++++++++++++--- 4 files changed, 77 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index 114062d..431295f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,8 +18,13 @@ git (1:1.7.4.1-5) unstable; urgency=low * patch-id: do not trip over "no newline" marker * various documentation, usage string, and code clarity improvements + * package git: remove unpack-time and configuration-time + dependencies on dpkg (>= 1.15.7.2) (thx Anders Kaseorg and + Marc Haber, closes: #618708). + - git.preinst, git.postinst, git.postrm: reimplement the + functionality from dpkg-maintscript-helper that we need. - -- Jonathan Nieder <[email protected]> Wed, 16 Mar 2011 21:01:53 -0500 + -- Jonathan Nieder <[email protected]> Mon, 21 Mar 2011 10:57:48 -0500 git (1:1.7.4.1-4) experimental; urgency=low diff --git a/debian/git.postinst b/debian/git.postinst index 7e327f0..dc47560 100644 --- a/debian/git.postinst +++ b/debian/git.postinst @@ -2,11 +2,30 @@ set -e test "$1" = configure || exit 0 +# Snippet based on dpkg-maintscript-helper from dpkg 1.15.8. Using a +# home-grown snippet instead of using Pre-Depends: dpkg (>= 1.15.7) +# makes the package easier to try out on old systems without requiring +# new dpkg in these early times. +# +# Kind reader of the future: it's about time to rip this out and use a +# call to dpkg-maintscript-helper, don't you think? +rm_conffile () { + CONFFILE=$1; shift + if dpkg --compare-versions "$2" lt-nl '1:1.7.4.1-2~'; then + if test -e "$CONFFILE.dpkg-backup"; then + mv -f "$CONFFILE.dpkg-backup" "$CONFFILE.dpkg-bak" + fi + if test -e "$CONFFILE.dpkg-remove"; then + echo "Removing $CONFFILE ..." + rm -f "$CONFFILE.dpkg-remove" + fi + fi +} + removed_conffile=/etc/emacs/site-start.d/50git-core.el -dpkg-maintscript-helper rm_conffile \ - "$removed_conffile" \ - 1:1.7.4.1-2~~ -- "$@" -# HACK: carry over modifications so git-el can use them. +rm_conffile "$removed_conffile" "$1" "$2" + +# Carry over modifications so git-el can use them. if dpkg --compare-versions "$2" lt '1:1.7.4.1-2~' && ! test -e "$removed_conffile" && test -r "$removed_conffile".dpkg-bak; then diff --git a/debian/git.postrm b/debian/git.postrm index e31cc5d..78b0f9c 100644 --- a/debian/git.postrm +++ b/debian/git.postrm @@ -1,6 +1,29 @@ #!/bin/sh set -e +# Snippet based on dpkg-maintscript-helper from dpkg 1.15.8. +# Postinst explains why. +rm_conffile () { + CONFFILE=$1; shift + if test "$1" = purge; then + rm -f "$CONFFILE.dpkg-bak" "$CONFFILE.dpkg-remove" \ + "$CONFFILE.dpkg-backup" + return + fi + + test "$1" = abort-install || test "$1" = abort-upgrade || return 0 + dpkg --compare-versions "$2" lt-nl '1:1.7.4.1-2~' || return 0 + if test -e "$CONFFILE.dpkg-remove"; then + echo "Reinstalling $CONFFILE that was moved away" + mv "$CONFFILE.dpkg-remove" "$CONFFILE" + fi + if test -e "$CONFFILE.dpkg-backup"; then + echo "Reinstalling $CONFFILE that was backed up" + mv "$CONFFILE.dpkg-backup" "$CONFFILE" + fi +} + + # Now /etc/emacs/site-start.d/50git-core.el belongs to the # git-el package. # @@ -8,7 +31,4 @@ set -e # file if it was modified while the broken 1.7.4.1-1 package # was installed. Installing and purging git-el works around # that. - -dpkg-maintscript-helper rm_conffile \ - /etc/emacs/site-start.d/50git-core.el \ - 1:1.7.4.1-2~~ -- "$@" +rm_conffile /etc/emacs/site-start.d/50git-core.el "$1" "$2" diff --git a/debian/git.preinst b/debian/git.preinst index 6edf5af..d3502b4 100644 --- a/debian/git.preinst +++ b/debian/git.preinst @@ -1,12 +1,33 @@ #!/bin/sh set -e +# Snippet based on dpkg-maintscript-helper from dpkg 1.15.8. +# Postinst explains why. +rm_conffile () { + CONFFILE=$1; shift + test "$1" = install || test "$1" = upgrade || return 0 + dpkg --compare-version "$2" lt-nl '1:1.7.4.1-2~' || return 0 + test -e "$CONFFILE" || return 0 + + md5sum=$(md5sum $CONFFILE | sed -e 's/ .*//') + old_md5sum=$( + dpkg-query -W -f='${Conffiles}' git | + sed -n -e "\' $CONFFILE ' { s/ obsolete\$//; s/.* //; p }" + ) + if test "$md5sum" != "$old_md5sum"; then + echo "$CONFFILE has been modified by you." + echo "Saving as $CONFFILE.dpkg-bak ..." + mv -f "$CONFFILE" "$CONFFILE.dpkg-backup" + else + echo "Moving $CONFFILE out of the way..." + mv -f "$CONFFILE" "$CONFFILE.dpkg-remove" + fi +} + # Now /etc/emacs/site-start.d/50git-core.el belongs to the # git-el package. If we are upgrading from a pre- 1.7.4.1-2~ # version then git-el is at most unpacked (so its version # is 50git-core.el.dpkg-new if present), and we can remove # an unchanged 50git-core.el file without danger. # -dpkg-maintscript-helper rm_conffile \ - /etc/emacs/site-start.d/50git-core.el \ - 1:1.7.4.1-2~~ -- "$@" +rm_conffile /etc/emacs/site-start.d/50git-core.el "$1" "$2" -- 1.7.4.1 -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

