Bugfix: prevent deb packages explicitly requested to be downloaded from not being downloaded#76
Conversation
|
This is super weird, and I'd like to understand what is going on a bit more. This is just running on my install, so none of the chroot games but that shouldn't be making a difference: >>> from apt import Cache
>>> c = Cache()
>>> c['chrony'].mark_install()
>>> c['wine32:i386'].mark_install()
>>> print('chrony' in [c.name for c in c.get_changes()])
TrueDo you have a moment to do some similar playing around to see if you can reproduce more interactively? |
Hi @mwhudson I could not reproduce the issue using this python snippet, but I could reproduce deterministically using livefs-editor. Here is how I do it: I am using livefs-editor from master ( git cherry-pick 23f935a99f308eda76c3c2d2fa53452cd00bb223Then I use ubuntu 22.04 as base image: # Download ubuntu 22.04
wget https://www.releases.ubuntu.com/22.04/ubuntu-22.04.5-live-server-amd64.iso
# Run livefs-editor, but stop before generating image (to save time)
/usr/local/bin/livefs-edit \
ubuntu-22.04.5-live-server-amd64.iso /tmp/final.iso \
--add-arch i386 \
--add-packages-to-pool chrony wine32:i386 \
--shell /bin/falseBellow is the output of the command, and you'll notice that, although ... it is never actually downloaded. My host, where livefs-editor is running is a Debian 12 (I know, not Ubuntu), and those are the versions of the apt related packages: Output of livefs-editorChange from this PR appliedWhen I apply the changes from this PR, you can see that the chrony package is downloaded as expected (exactly livefs-editor command as before): |
On my setup, I am customizing ubuntu server 22.04.5 (yes, an old version) with some i386 packages (see !67) and I need to generate an ISO image with all the dependencies on it, so that it can used to install some servers offline, in an environment without internet connection.
I've noticed that when I run livefs-editor
--add-debs-to-pool chrony wine32:i386, whenwine32:i386is marked to install, it removeschronyfrom the list of packages to be installed (in our case, to be downloaded), and I really have no idea why it happens, as there seems to be no conflicts betweenwine32:i386andchronyif you install them viaapt.As a result, I end up with an ISO image without the chrony package, which fails to install offline, as on my autoinstall file explicitly asks chrony to be installed.
Regardless of chrony or wine, this shows that it's possible that a package removes another package from the list of packages to be downloaded.
To workaround it, this PR changes the way the changes are computed, by storing the packages to be downloaded in a set, which never shrinks, on which no elements can be removed from it, preventing explicitly requested downloads of being removed from the changeset.
This of course introduces some performance issue in case the list of packages to be download is large, but I really believe such performance hit is negligible, as operations on
set()are quite fast.As here we are handling only the downloads, it's up to the user to worry during the installation process whether there are conflicts or not.
I've been using this change in production for some time now and it seems to work well me, but I am not sure whether it'll break anyone else's setup.