dpkg keeps diversions for removed packages

Bug #727738 reported by Malcolm Scott
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
byobu (Ubuntu)
Fix Released
High
Dustin Kirkland 

Bug Description

Binary package hint: dpkg

On a 10.10 system which has been upgraded several times through the ages, and presumably used to have the screen-profiles package installed when it existed:

mas90@callisto:~$ dpkg -S /usr/bin/screen
diversion by screen-profiles from: /usr/bin/screen
diversion by screen-profiles to: /usr/bin/screen.real
screen: /usr/bin/screen
mas90@callisto:~$ dpkg -L screen-profiles
Package `screen-profiles' is not installed.
mas90@callisto:~$ dpkg --get-selections | grep -c screen-profiles
0
mas90@callisto:~$ ls -l /usr/bin/screen /usr/bin/screen.real
-rwxr-sr-x 1 root utmp 376032 2009-07-06 06:37 /usr/bin/screen
-rwxr-sr-x 1 root utmp 376112 2010-06-18 22:13 /usr/bin/screen.real

i.e. I'm stuck with an old (and buggy: bug #375625) /usr/bin/screen supplied by a screen-profiles package, despite screen-profiles being long gone.

I can work around the situation, but dpkg should never have got into this state. When screen-profiles was removed, any diversions it put in place should have been undone.

Related branches

Revision history for this message
Steve Langasek (vorlon) wrote :

sorry, but dpkg-divert only does what it's told here. This screen-profiles package was responsible for removing /usr/bin/screen on package removal; nothing dpkg can do when a package decides to leave one around. Reassigning to byobu which provided screen-profiles.

affects: dpkg (Ubuntu) → byobu (Ubuntu)
Revision history for this message
Chaskiel Grundman (cg2v) wrote :

So, it seems that this was caused by an incorrect fix for 390808 in byobu:

  * debian/postinst, debian/screen-profiles.postinst: ensure that
    /usr/bin/screen doesn't disappear, which causes the dpkg-divert
    removal to fail; LP: #390808

But just the opposite is true. dpkg-divert fails *if* /usr/bin/screen exists, not if it doesn't.

root@sphinx:~# dpkg-divert --package screen-profiles --rename --remove /usr/bin/screen
Removing `diversion of /usr/bin/screen to /usr/bin/screen.real by screen-profiles'
dpkg-divert: rename involves overwriting `/usr/bin/screen' with
  different file `/usr/bin/screen.real', not allowed

It seems to me that the real cause of 390808 is that the wrong package name was used to remove the diversion:

> dpkg-divert: mismatch on package when removing `diversion of /usr/bin/screen by byobu'
> found `diversion of /usr/bin/screen to /usr/bin/screen.real by screen-profiles'

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Okay, I thought I had fixed this correctly before, with the sunsetting of the screen-profiles package.

Evidently that was wrong.

Can someone clearly explain to me what needs to be done in byobu at this point to fix this? Do I need to resurrect a screen-profiles binary package to force the dpkg-divert update?

Changed in byobu (Ubuntu):
importance: Undecided → High
status: New → Incomplete
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

Revision history for this message
Steve Langasek (vorlon) wrote :

> I don't know what policy/lintian say about dpkg-divert invocations though.

Policy has no problem; lintian stands no more chance of grokking dpkg-divert invocations than developers do. :P

> 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.

There may be other cases not handled, but I can confirm that your proposed fix for this issue is logically correct (including the rm /usr/bin/screen).

Changed in byobu (Ubuntu):
status: Incomplete → Triaged
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Thank you very much Chaskiel! And you, Steve for the review.

I'll try to squeeze this into Natty, as I think this is an important fix for an annoying issue that creeps up from time to time.

Changed in byobu (Ubuntu):
status: Triaged → In Progress
assignee: nobody → Dustin Kirkland (kirkland)
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package byobu - 3.30-0ubuntu1

---------------
byobu (3.30-0ubuntu1) natty; urgency=low

  [ Dustin Kirkland ]
  * usr/share/applications/byobu.desktop: fix description
  * usr/bin/byobu-status-detail: make a couple of minor modifications
    noticed while investigating the already-fixed LP: #750887
  * usr/lib/byobu/raid: fix grep that changed recently in Linux's
    md driver's printing to /proc/mdstat, LP: #760693
  * usr/share/byobu/profiles/common: preserve splits across detach/reattach,
    LP: #760696
  * usr/bin/byobu-launcher: don't disrupt work flow, but rather inform
    user about launching byobu in a nested screen session, LP: #747649
  * usr/bin/byobu-launch, usr/bin/byobu-launcher-install: fix handling
    of logout behavior, when dpkg-configured globally by the sysadmin,
    LP: #741281
  * usr/share/byobu/profiles/common: fix bold color intensity, LP: #727466
  * usr/bin/byobu-janitor, usr/bin/byobu-launch, usr/bin/byobu-launcher-
    install, usr/bin/byobu-launcher-uninstall,
    usr/share/byobu/keybindings/f-keys,
    usr/share/byobu/keybindings/screen-escape-keys,
    usr/share/man/man1/byobu.1:
    - add a more permanent fix for LP: #604931
    - update documentation
  * usr/share/byobu/keybindings/f-keys,
    usr/share/byobu/keybindings/screen-escape-keys:
    - fix ctrl-f5
  * debian/source/format, === removed directory debian/source: remove these
    until bzr builddeb bug gets fixed
  * usr/bin/byobu, usr/share/byobu/profiles/byoburc,
    usr/share/byobu/profiles/Makefile.am,
    usr/share/byobu/profiles/screenrc: support using ~/.byoburc, instead of
    ~/.screenrc, if present; some users seem to want to use byobu and screen
    separately, and keep their profiles separate, LP: #731529
  * usr/bin/byobu-janitor: use greadlink on Mac OSX, LP: #740370
  * usr/bin/byobu-select-session: fix broken path to screen, affects users
    who build/install byobu locally only, LP: #758177

  [ Chaskiel Grundman ]
  * debian/postinst: correctly fix old-school screen-profiles era diversions
    of /usr/bin/screen, LP: #727738
 -- Dustin Kirkland <email address hidden> Sun, 27 Feb 2011 10:29:53 -0600

Changed in byobu (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.