Comment 4 for bug 727738

Revision history for this message
Chaskiel Grundman (cg2v) wrote :

Since dpkg-divert takes a package name as an arg, you should not need the other binary package. I don't know what policy/lintian say about dpkg-divert invocations though.

First, remove this from the postinst:

# The target of the diversion somehow disappeared which will cause
# the divert removal to fail; we don't want that to happen
[ -e "/usr/bin/screen.real" ] && [ ! -e "/usr/bin/screen" ] && cp -a /usr/bin/screen.real /usr/bin/screen

I think the following script fragment (with an appropriate version test maybe?) will clean this situation up:

if [ -f /usr/bin/screen ] && [ -f /usr/bin/screen.real ]; then
  divertpkg=$(dpkg-divert --listpackage /usr/bin/screen)
  if [ "$divertpkg" = "screen-profiles" ]; then
     rm /usr/bin/screen
     dpkg-divert --package screen-profiles --rename --remove /usr/bin/screen
  fi
fi

This is how I re-created the situation to test. I don't know if it covers all the possible situations that machines can be in.

dpkg-divert --package screen-profiles --add --divert /usr/bin/screen.real --rename /usr/bin/screen
cp -a /usr/bin/screen.real /usr/bin/screen