Package candidate version override not working

Asked by Enmanuel Hernandez

Dear maintainers,

I am unable to install a specific version of a package with python-apt. For some reason package object lets me override the candidate version. However, once I try to install the selected version, cache.commit() just returns true instead of installing the package.

Here is my python and python-apt versions installed:

root@server1033:~# apt-cache policy python-apt
python-apt:
  Installed: 1.1.0~beta1ubuntu0.16.04.5
root@server1033:~# apt-cache policy python3.5
python3.5:
  Installed: 3.5.2-2ubuntu0~16.04.5

I have verified the package is not installed and still the cache.commit() doesnt install it. Here is the code that fails. Im showing you in an ipython3 terminal

root@server1033:~# ipython3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: import apt
In [2]: package_name = 'zfs'
In [3]: version = '0.7.8.datto.8-41.1ubuntu16.04'
In [4]: cache = apt.cache.Cache()
In [5]: package = cache[package_name]
In [6]: package.is_installed
Out[6]: False
In [7]: package.versions
Out[7]: <VersionList: ['0.7.8.datto.10-44.1ubuntu16.04', '0.7.8.datto.8-41.1ubuntu16.04', '0.7.8.datto.3-30.1ubuntu16.04', '0.6.5.9-1.1ubuntu16.04']>
In [8]: candidate = package.versions.get(version)
In [9]: package.candidate = candidate
In [10]: package.mark_install()
In [11]: package.marked_install
Out[11]: False
In [12]: cache.commit()
Out[12]: True

Im trying to install a specific version of a package with python-apt.
I tried this article I found in the internet https://stackoverflow.com/questions/34162051/python-apt-install-package-with-specific-version but it didnt work either.

Please advise.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu python-apt Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Enmanuel Hernandez (enmanuelh17) said :
#1

If I select the latest version of the package, everything works.
In [1]: import apt
In [2]: package_name = 'zfs'
In [3]: version = '0.7.8.datto.10-44.1ubuntu16.04'
In [4]: cache = apt.cache.Cache()
In [5]: package = cache[package_name]
In [6]: package.is_installed
Out[6]: False
In [7]: package.versions
Out[7]: <VersionList: ['0.7.8.datto.10-44.1ubuntu16.04', '0.7.8.datto.8-41.1ubuntu16.04', '0.7.8.datto.3-30.1ubuntu16.04', '0.6.5.9-1.1ubuntu16.04']>
In [8]: candidate = package.versions.get(version)
In [9]: package.candidate = candidate
In [10]: package.mark_install()
In [11]: package.marked_install
Out[11]: True
In [12]: cache.commit()
Selecting previously unselected package spl-dkms.
(Reading database ... 105569 files and directories currently installed.)
Preparing to unpack .../spl-dkms_0.7.8.datto.10-55.1ubuntu16.04_all.deb ...
Unpacking spl-dkms (0.7.8.datto.10-55.1ubuntu16.04) ...
Setting up spl-dkms (0.7.8.datto.10-55.1ubuntu16.04) ...
Loading new spl-0.7.8.datto.10 DKMS files...
First Installation: checking all kernels...
Building only for 4.4.0-135-generic
Building initial module for 4.4.0-135-generic

same if I leave the default candidate. which defaults to the latest version as well.

But I need to specify and different version other than the default/latest. Currently is is not doing anything when
candidate version is not the latest.

Revision history for this message
Enmanuel Hernandez (enmanuelh17) said :
#2

default candidate works fine. But I need to specify a different version
In [1]: import apt
In [2]: package_name = 'zfs'
In [3]: cache = apt.cache.Cache()
In [4]: package = cache[package_name]
In [5]: package.is_installed
Out[5]: False
In [6]: package.versions
Out[6]: <VersionList: ['0.7.8.datto.10-44.1ubuntu16.04', '0.7.8.datto.8-41.1ubuntu16.04', '0.7.8.datto.3-30.1ubuntu16.04', '0.6.5.9-1.1ubuntu16.04']>
In [7]: package.candidate
Out[7]: <Version: package:'zfs' version:'0.7.8.datto.10-44.1ubuntu16.04'>
In [8]: package.mark_install()
In [9]: package.marked_install
Out[9]: True
In [10]: cache.commit()
Selecting previously unselected package spl-dkms.
(Reading database ... 105569 files and directories currently installed.)
Preparing to unpack .../spl-dkms_0.7.8.datto.10-55.1ubuntu16.04_all.deb ...
Unpacking spl-dkms (0.7.8.datto.10-55.1ubuntu16.04) ...
Setting up spl-dkms (0.7.8.datto.10-55.1ubuntu16.04) ...
Loading new spl-0.7.8.datto.10 DKMS files...
First Installation: checking all kernels...

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

I do not have experience with python-apt, but I want to help diagnosing your problem.
My suspicion is that there is an inconsistent use of source package ('zfs') and binary package ('spl-dkms') names.

What is the full and unedited output of the commands

uname -a
lsb_release -crid
apt-cache policy python-apt zfs spl-dkms
apt --simulate install zfs=0.7.8.datto.8-41.1ubuntu16.04
apt --simulate install spl-dkms=0.7.8.datto.8-41.1ubuntu16.04

Revision history for this message
Enmanuel Hernandez (enmanuelh17) said :
#4

Manfred,

Thanks for helping me out. Here is the information requested:
root@testbox:~# lsb_release -crid
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
root@testbox:~# uname -r
4.4.0-157-generic
root@testbox:~# apt-cache policy python3-apt zfs spl-dkms
python3-apt:
  Installed: 1.1.0~beta1ubuntu0.16.04.5
  Candidate: 1.1.0~beta1ubuntu0.16.04.5
  Version table:
 *** 1.1.0~beta1ubuntu0.16.04.5 500
        500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1.1.0~beta1build1 500
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
zfs:
  Installed: (none)
  Candidate: 0.7.8.datto.10-44.1ubuntu16.04
  Version table:
     0.7.8.datto.10-44.1ubuntu16.04 500
        500 http://syseng-packages.datto.com/xenial-stable xenial/main amd64 Packages
     0.7.8.datto.8-41.1ubuntu16.04 500
        500 http://syseng-packages.datto.com/xenial-stable xenial/main amd64 Packages
     0.7.8.datto.3-30.1ubuntu16.04 500
        500 http://syseng-packages.datto.com/xenial-stable xenial/main amd64 Packages
     0.6.5.9-1.1ubuntu16.04 500
        500 http://syseng-packages.datto.com/xenial-stable xenial/main amd64 Packages
spl-dkms:
  Installed: (none)
  Candidate: 0.7.8.datto.10-55.1ubuntu16.04
  Version table:
     0.7.8.datto.10-55.1ubuntu16.04 500
        500 http://syseng-packages.datto.com/xenial-stable xenial/main amd64 Packages
     0.7.8.datto.8-53.1ubuntu16.04 500
        500 http://syseng-packages.datto.com/xenial-stable xenial/main amd64 Packages
     0.7.8.datto.3-48.1ubuntu16.04 500
        500 http://syseng-packages.datto.com/xenial-stable xenial/main amd64 Packages
     0.6.5.9-1.1ubuntu16.04 500
        500 http://syseng-packages.datto.com/xenial-stable xenial/main amd64 Packages
     0.6.5.6-0ubuntu4 500
        500 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages
     0.6.5.6-0ubuntu2 500
        500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
root@testbox:~#

root@testbox:~# apt --simulate install zfs=0.7.8.datto.8-41.1ubuntu16.04
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 zfs : Depends: libzpool2 (= 0.7.8.datto.8-41.1ubuntu16.04) but 0.7.8.datto.10-44.1ubuntu16.04 is to be installed
       Depends: libnvpair1 (= 0.7.8.datto.8-41.1ubuntu16.04) but 0.7.8.datto.10-44.1ubuntu16.04 is to be installed
       Depends: libuutil1 (= 0.7.8.datto.8-41.1ubuntu16.04) but 0.7.8.datto.10-44.1ubuntu16.04 is to be installed
       Depends: libzfs2 (= 0.7.8.datto.8-41.1ubuntu16.04) but 0.7.8.datto.10-44.1ubuntu16.04 is to be installed
       Depends: zfs-dkms (= 0.7.8.datto.8-41.1ubuntu16.04)
E: Unable to correct problems, you have held broken packages.
root@testbox:~# apt --simulate install zfs-dkms=0.7.8.datto.8-41.1ubuntu16.04
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  build-essential dpkg-dev g++ g++-5 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libdpkg-perl
  libelf-dev libfile-fcntllock-perl libstdc++-5-dev spl-dkms
Suggested packages:
  debian-keyring g++-multilib g++-5-multilib gcc-5-doc libstdc++6-5-dbg libstdc++-5-doc
The following NEW packages will be installed:
  build-essential dpkg-dev g++ g++-5 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libdpkg-perl
  libelf-dev libfile-fcntllock-perl libstdc++-5-dev spl-dkms zfs-dkms
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Inst libdpkg-perl (1.18.4ubuntu1.5 Ubuntu:16.04/xenial-updates [all])
Inst dpkg-dev (1.18.4ubuntu1.5 Ubuntu:16.04/xenial-updates [all])
Inst libelf-dev (0.165-3ubuntu1.2 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Inst spl-dkms (0.7.8.datto.10-55.1ubuntu16.04 xenial-stable xenial:xenial [all])
Conf libdpkg-perl (1.18.4ubuntu1.5 Ubuntu:16.04/xenial-updates [all])
Conf dpkg-dev (1.18.4ubuntu1.5 Ubuntu:16.04/xenial-updates [all])
Conf libelf-dev (0.165-3ubuntu1.2 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf spl-dkms (0.7.8.datto.10-55.1ubuntu16.04 xenial-stable xenial:xenial [all])
Inst zfs-dkms (0.7.8.datto.8-41.1ubuntu16.04 xenial-stable xenial:xenial [all])
Inst libstdc++-5-dev (5.4.0-6ubuntu1~16.04.11 Ubuntu:16.04/xenial-updates [amd64])
Inst g++-5 (5.4.0-6ubuntu1~16.04.11 Ubuntu:16.04/xenial-updates [amd64])
Inst g++ (4:5.3.1-1ubuntu1 Ubuntu:16.04/xenial [amd64])
Inst build-essential (12.1ubuntu2 Ubuntu:16.04/xenial [amd64])
Inst libalgorithm-diff-perl (1.19.03-1 Ubuntu:16.04/xenial [all])
Inst libalgorithm-diff-xs-perl (0.04-4build1 Ubuntu:16.04/xenial [amd64])
Inst libalgorithm-merge-perl (0.08-3 Ubuntu:16.04/xenial [all])
Inst libfile-fcntllock-perl (0.22-3 Ubuntu:16.04/xenial [amd64])
Conf zfs-dkms (0.7.8.datto.8-41.1ubuntu16.04 xenial-stable xenial:xenial [all])
Conf libstdc++-5-dev (5.4.0-6ubuntu1~16.04.11 Ubuntu:16.04/xenial-updates [amd64])
Conf g++-5 (5.4.0-6ubuntu1~16.04.11 Ubuntu:16.04/xenial-updates [amd64])
Conf g++ (4:5.3.1-1ubuntu1 Ubuntu:16.04/xenial [amd64])
Conf build-essential (12.1ubuntu2 Ubuntu:16.04/xenial [amd64])
Conf libalgorithm-diff-perl (1.19.03-1 Ubuntu:16.04/xenial [all])
Conf libalgorithm-diff-xs-perl (0.04-4build1 Ubuntu:16.04/xenial [amd64])
Conf libalgorithm-merge-perl (0.08-3 Ubuntu:16.04/xenial [all])
Conf libfile-fcntllock-perl (0.22-3 Ubuntu:16.04/xenial [amd64])
root@testbox:~#

Revision history for this message
Enmanuel Hernandez (enmanuelh17) said :
#5

even with different packages it doesnt let me override the candidate version. Marking for install only works with the latest version of any package only. Here is another example:

In [1]: import apt
In [2]: package_name = 'chromium-browser'
In [3]: version = '49.0.2623.108-0ubuntu1.1233'
In [4]: cache = apt.cache.Cache()
In [5]: package = cache[package_name]
In [6]: package.is_installed
Out[6]: True
In [7]: package.versions
Out[7]: <VersionList: ['76.0.3809.87-0ubuntu0.16.04.1', '49.0.2623.108-0ubuntu1.1233']>
In [8]: package.candidate
Out[8]: <Version: package:'chromium-browser' version:'76.0.3809.87-0ubuntu0.16.04.1'>
In [9]: candidate = package.versions.get(version)
In [10]: package.candidate = candidate
In [11]: package.candidate
Out[11]: <Version: package:'chromium-browser' version:'49.0.2623.108-0ubuntu1.1233'>
In [12]: package.mark_install()
In [13]: package.marked_install
Out[13]: False
In [14]: cache.commit()
Out[14]: True

Revision history for this message
Manfred Hampl (m-hampl) said :
#6

1. My assumption about a confusion between source and binary packages was wrong, since there is a binary package 'zfs' in the external repository that you are using.

2. As you can see from the command "apt --simulate install zfs=0.7.8.datto.8-41.1ubuntu16.04", there are unmet dependencies if you try installing zfs version 0.7.8.datto.8-41.1ubuntu16.04

The output of the command "apt --simulate install zfs-dkms=0.7.8.datto.8-41.1ubuntu16.04" does not show a dependency problem, and so I assume that installing zfs-dkms version 0.7.8.datto.8-41.1ubuntu16.04 would also work in python.

I suggest that you try the python-apt install of
zfs-dkms version 0.7.8.datto.8-41.1ubuntu16.04
libzpool2 version 0.7.8.datto.8-41.1ubuntu16.04
libnvpair1 version 0.7.8.datto.8-41.1ubuntu16.04
libuutil1 version 0.7.8.datto.8-41.1ubuntu16.04
libzfs2 version 0.7.8.datto.8-41.1ubuntu16.04
and only if they are installed then try
zfs version 0.7.8.datto.8-41.1ubuntu16.04

Remarks:

I assume that there is a similar dependency problem with chromium-browser, probably requiring the same version in chromium-codecs-ffmpeg (the command "apt --simulate install chromium-browser=49.0.2623.108-0ubuntu1.1233" should tell details)

I do not have any knowledge how to see that dependency problem in python-apt. Eventually cache.broken_count or apt.cache.ProblemResolver can help with that.

Can you help with this problem?

Provide an answer of your own, or ask Enmanuel Hernandez for more information if necessary.

To post a message you must log in.