Running 'aptitude update' clears hold flags on packages

Bug #1817350 reported by Mike Nguyen
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
aptitude (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

When running an 'aptitude update' for the very first time, it seems to clear up any hold flags that were previous put in place via 'apt-mark hold <package>'.

1:
root@cb-qa-lb-1:~# lsb_release -rd
Description: Ubuntu 18.04.2 LTS
Release: 18.04

2:
root@cb-qa-lb-1:~# apt-cache policy aptitude
aptitude:
  Installed: 0.8.10-6ubuntu1
  Candidate: 0.8.10-6ubuntu1
  Version table:
 *** 0.8.10-6ubuntu1 500
        500 http://ca.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

3:
When a 'hold' flag is set on a package, it should be kept. Doing an 'aptitude update' should not be clearing these package flags. This is not the case as the hold flag is getting removed.

4:
All 'hold' flags on packages that were previously set get cleared.

Upon running 'aptitude update', it seems to create /var/lib/aptitude/pkgstates, and also update /var/lib/dpkg/status, which seems to remove any flags on packages that were present.

Pastebin here with some output: https://paste.ubuntu.com/p/VF6kQRbSmf/

This only seems to happen when running 'aptitude update' on an initial run. Doing an 'apt update' does not cause any issue.

Note that running subsequent 'aptitude update' with /var/lib/aptitude/pkgstates already existing does not seem to cause any issue anymore and any hold flags that get set are kept.

Revision history for this message
Mike Nguyen (moozoo) wrote :

I should note that I've also tested this on 16.04.6 and am getting the same unexpected behaviour.

root@ansible:/var/lib/aptitude# lsb_release -rd
Description: Ubuntu 16.04.6 LTS
Release: 16.04

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in aptitude (Ubuntu):
status: New → Confirmed
Revision history for this message
Mike Nguyen (moozoo) wrote :

Another detail that might be worth mentioning...

Running "aptitude update" to create the /var/lib/aptitude/pkgstates file seems to ONLY work from a tty. From a connection with no tty (such as one initiated via ansible), it does not seem to create the file.

I had to work around things by making aptitude actually run a command that will do an action without any doubt (such as... aptitude install -y sudo).

Revision history for this message
Carlos Miguel Bustillo Rdguez (charlesm1888) wrote :

I can confirm the problem is present in Debian GNU/Linux 9.11 (stretch) and Ubuntu 18.04.3 LTS. I noted the issue after run by the second time an Ansible playbook with the apt module. As a workaround, I set `force_apt_get: yes` in the apt module.

It's very odd this behavior because in my case the file `/var/lib/aptitude/pkgstates` already existed. The first time I ran `aptitude update`, the command cleared all hold flag in packages that had set before; also 'hold' was removed from the status field here `/var/lib/dpkg/status`. Then I marked again the packages with the hold flag and I run `aptitude update`, `aptitude safe-upgrade`, `apt-get update`, `apt-get upgrade`, `apt update` and `apt upgrade` without issues.

Any hints are welcome!

Thanks in advance!!

Revision history for this message
Anna Ermolaeva (aermolaeva) wrote :

I can confirm that with aptitude 0.7.4-2ubuntu2 in Ubuntu 16.04 LTS (Xenial).

Revision history for this message
Jason Pell (jason-pellcorp) wrote :

This affects 20.04 as well, as it actually happens every time aptitude update is executed. This effectively makes apt-mark hold pointless for me!

ops@d-vgt-006:~$ sudo apt-mark hold unattended-upgrades
unattended-upgrades set on hold.
ops@d-vgt-006:~$ sudo apt-mark showhold
unattended-upgrades
ops@d-vgt-006:~$ sudo aptitude update
Hit http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit http://security.ubuntu.com/ubuntu focal-security InRelease

ops@d-vgt-006:~$ sudo apt-mark showhold
ops@d-vgt-006:~$

ops@d-vgt-006:~$ sudo apt-mark showhold
ops@d-vgt-006:~$ sudo apt-mark hold unattended-upgrades
unattended-upgrades set on hold.
ops@d-vgt-006:~$ sudo apt-mark showhold
unattended-upgrades

ops@d-vgt-006:~$ sudo aptitude update
Hit http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit http://security.ubuntu.com/ubuntu focal-security InRelease

ops@d-vgt-006:~$ sudo apt-mark showhold
ops@d-vgt-006:~$

Revision history for this message
Jason Pell (jason-pellcorp) wrote :

Every time I run aptitude update, the /var/lib/aptitude/pkgstates is updated again, so I guess a change in behavior from 18.04 perhaps!

Revision history for this message
Francois Scheurer (scheuref) wrote :

same issue here on ubuntu jammy with all holds being cleared after initial 'aptitude update', subsequent 'aptitude update' are not clearing the holds, as described in comment #4 above.

(BTW, I thought that "apt update" was doing the same as "aptitude update" but this issue showed me that this is not the case.)

#lsb_release -id
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS

# dpkg -l | egrep apt
ii apt 2.4.8 amd64 commandline package manager
ii apt-transport-https 2.4.8 all transitional package for https support
ii apt-utils 2.4.8 amd64 package management related utility programs
ii aptitude 0.8.13-3ubuntu1 amd64 terminal-based package manager
ii aptitude-common 0.8.13-3ubuntu1 all architecture independent files for the aptitude package manager
ii libapt-pkg6.0:amd64 2.4.8 amd64 package management runtime library
ii libpcap0.8:amd64 1.10.1-4build1 amd64 system interface for user-level packet capture
ii python-apt-common 2.3.0ubuntu2.1 all Python interface to libapt-pkg (locales)
ii python3-apt 2.3.0ubuntu2.1 amd64 Python 3 interface to libapt-pkg
ii tuned 2.15.0-1 all daemon for monitoring and adaptive tuning of system devices

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.