Package: debhelper
Version: 5.0.32
Severity: normal

The postinst fragments installed by dh_python compile everything under
/usr/lib/pythonX.Y/site-packages, so if you're installing several
python-using packages at once it's entirely possible for a package to be
only unpacked yet still have .pyc and .pyo files created for it by a
postinst of one of the other packages being installed in the same run.

Now imagine that the above package fails to configure (e.g. due to
dependencies). If you then dpkg --purge this package, dpkg does not run
the prerm script, only the postrm. I checked with Scott James Remnant,
who believes that this is intentional:

  <Kamion> Keybuk: do you happen to know if it's intentional that dpkg doesn't 
call the prerm when removing a package that's only unpacked?
  <Keybuk> Kamion: what state was the package in?
  <Keybuk> Kamion: valid unpacked but not configured state?
  <Kamion> Keybuk: 'install ok unpacked'; failed to configure due to 
dependencies
  <Keybuk> Kamion: I think it's intentional that it doesn't yeah
  <Keybuk> prerm remove "undoes" postinst configure
  <Keybuk> postrm remove "undoes" preinst install
  <Keybuk> etc.
  <Kamion> the real problem I'm having is that dh_python's prerm script is 
responsible for removing .pyc and .pyo files on package removal
  <Keybuk> Kamion: what are those generated by?
  <Keybuk> Kamion: postinst, no?
  <Kamion> and dh_python's postinst fragment compiles everything in 
/usr/lib/python2.4/site-packages, not just the .py files for this package
  <Kamion> so it's generated by some other package's postinst
  <Keybuk> yeah, those should probably be removed in postrm not prerm
  <Keybuk> as I understand the intended operation
  <Kamion> ok, I'll file a debhelper bug
  <Keybuk> ah
  <Keybuk> yes, definitely intentional
  <Keybuk> prerm was called
  <Keybuk> "prerm upgrade" is called before ver 2 is unpacked
  <Keybuk> so ver 1 prerm has been called, and told it was being called due to 
upgrade
  <Keybuk> so there's no reason for ver 2 prerm to be called until it's been 
configured
  <Keybuk> as I follow this logic
  <Kamion> Keybuk: (in this case it's a newly installed package so the prerm 
wasn't in fact called)
  <Keybuk> Kamion: yeah, the logic still stands from the upgrade case though
  <Keybuk> it implies prerm matches postinst
  <Keybuk> which is how I've always understood it, anyway

Since dh_python's logic to remove stale .pyc and .pyo files lives in the
prerm script, this means that purging an unpacked package leaves
orphaned .pyc and .pyo files around. Due to the way python's module
importing works, this means that you can end up importing modules that
you thought you'd removed from the system.

I haven't tested this, but I believe that the easiest fix is to move
dh_python's prerm fragment to postrm, and guard it with a check that $1
is remove.

Thanks,

-- 
Colin Watson                                       [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to