I agree with cavsfan that /etc/kernel/postinst.d/apt-auto-removal should
not be triggered when you delete a kernel.  What is happening is that
/etc/apt/apt.conf.d/01autoremove-kernels  is being set to prevent
kernel[0] and kernel[-2] from being autoremoved, instead of kernel[0]
and kernel[-1].

Take a recent situation.  After the installation of kernel 3.19.0-28,
the kernels 3.19.0-25, 3.19.0-26, and 3.19.0-28 are installed, and
/etc/apt/apt.conf.d/01autoremove-kernels is set to prevent 3.19.0-26 and
3.19.0-28 from being removed.

When you run the autoremove in this situation, 3.19.0-25 is removed.  If
/etc/kernel/postinst.d/apt-auto-removal is triggered during this
removal, it will mark as not-for-autoremoval (according to the comments
at the top of apt-auto-removal):

* the currently booted version - this will be 3.19.0-28
* the kernel version we've been called for - this will be 3.19.0-25 (which is 
the kernel we've just removed - why are we marking for non-auto-removal a 
kernel which has already been removed?)
* the latest kernel version - this will be 3.19.0-28
* the second-latest kernel version, if the booted kernel version is  already 
the latest and this script is called for that same version - this doesn't 
apply, as this script isn't being called for the latest version, it's being 
called for the version we're deleting.

The result is that /etc/apt/apt.conf.d/01autoremove-kernels is set to
prevent 3.19.0-25 and 3.19.0-28 from being autoremoved, while the system
actually contains 3.19.0-26 and 3.19.0-28.  Autoremove will, in this
case, want to remove 3.19.0-26, leaving only 3.19.0-28.

I think the fact that having a kernel removal trigger
/etc/kernel/postinst.d/apt-auto-removal will result in marking for non-
auto-removal a kernel that is already removed alone indicates that
something is not being done correctly.  Either don't trigger
/etc/kernel/postinst.d/apt-auto-removal on a kernel remove, or tweak
/etc/kernel/postinst.d/apt-auto-removal to handle the fact that the
kernel it's being called for is being deleted, not added (perhaps don't
do criteria 2 (the kernel version we've been called for) and do criteria
4 (tweak criteria 4's conditions to have it apply on a deletion).

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to apt in Ubuntu.
https://bugs.launchpad.net/bugs/1440608

Title:
  /etc/kernel/postinst.d/apt-auto-removal wants to remove all kernels
  except the latest one

Status in apt package in Ubuntu:
  Confirmed

Bug description:
  After installing a 3rd kernel currently 3.19.0-12-generic, the
  /etc/apt/apt.conf.d/01autoremove-kernels file looks normal listing the
  3.19.0-11-generic and 3.19.0-12-generic with 3.19.0-10-generic listed
  to be autoremoved. But once autoremove is completed the machine
  requests to be rebooted and at that time the /etc/apt/apt.conf.d
  /01autoremove-kernels file lists the 3.19.0-12-generic and
  3.19.0-10-generic kernels. So upon rebooting the 3.19.0-11-generic is
  requested to be autoremoved leaving only one kernel the latest one
  3.19.0-12-generic.

  ProblemType: Bug
  DistroRelease: Ubuntu 15.04
  Package: apt 1.0.9.7ubuntu3
  ProcVersionSignature: Ubuntu 3.19.0-12.12-generic 3.19.3
  Uname: Linux 3.19.0-12-generic x86_64
  NonfreeKernelModules: nvidia
  ApportVersion: 2.17-0ubuntu1
  Architecture: amd64
  CurrentDesktop: MATE
  Date: Sun Apr  5 17:03:01 2015
  InstallationDate: Installed on 2015-04-02 (3 days ago)
  InstallationMedia: Ubuntu-MATE 15.04 "Vivid Vervet" - Beta amd64 (20150401)
  SourcePackage: apt
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1440608/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to