5

Let's say I have a debian package A-1.0.0.deb (which contains a library), and another package B-1.0.0.deb (which contains a service) which depends on the A library. Now let's say I want to upgrade to A-1.0.1.deb.

According to this document, dpkg goes through a pretty involved algorithm to figure which package maintainer scripts are called for each package as part of the upgrade process. If some of these steps fail, then A can be left in some sort of limbo state (for example, "Half-installed").

However, when you break A, then B is broken too since it depends on A. So my question is does dpkg have any built-in way to deal with this situation? Does B's install status change depending on A's status? Ideally dpkg would have some built-in functionality to move B from the installed state to another state (so that the B service can be stopped & restarted when A is healthy), but I can't find anything in the dpkg documentation that suggests this is done.

If dpkg doesn't handle this situation intelligently, does apt?

6
+25

From what I have experienced not what i have read.

  • However, when you break A, then B is broken too since A depends on it. So my question is does dpkg have any built-in way to deal with this situation?

    Yes, it will try to reinstall or reconfigure A on next run.

    1. If it was just interrupted, it will fix that and continue working as normal.

    2. But it's a problem with control scripts, it will fail again and again and it stay in this loop. Then it's a bug and report would be filled against that package and a manual fix is required.

  • Does B's install status change depending on A's status?

    No, the status stay as Installed no change, but it does keep track of broken dependency too, at least not in the same file /var/lib/dpkg/status.

  • If dpkg doesn't handle this situation intelligently, does apt?

    No, APT does not interfere in this case. apt uses dpkg, dpkg is the lower level tool and it is the only tool that actually install, build, remove Debian packages.


Let's try it, better it is done in a virtualbox.

  1. Prepare dummy packages

    ~$ sudo apt install equivs
    ~$ mkdir deleteme
    ~$ cd deleteme
    

    B 1.0.0 depends on A

    ~/deleteme$ equivs-control b0
    ~/deleteme$ nano b0
    ...
    Package: b
    Version: 1.0.0
    ...
    Depends: a
    ...
    ~/deleteme$ equivs-build b0
    

    A 1.0.0 clean install & remove

    ~/deleteme$ equivs-control a0
    ~/deleteme$ nano a0
    ...
    Package: a
    Version: 1.0.0
    ...
    ~/deleteme$ equivs-build a0
    

    A 1.0.1 dirty install, but clean remove

    ~/deleteme$ cp a0 a1
    ~/deleteme$ nano a1
    ...
    Package: a
    Version: 1.0.1
    ...
    Postinst: a1.postinst
    ...
    
    ~/deleteme$ nano a1.postinst
    
    #!/bin/sh    
    exit 1
    
    ~/deleteme$ equivs-build a1
    

    Now, you should have:

    ~/deleteme$ ls -1
    a0
    a1
    a_1.0.0_all.deb
    a_1.0.1_all.deb
    a1.postinst
    b0
    b_1.0.0_all.deb
    
  2. Try this scenario

    sudo su
    
    dpkg -i b_1.0.0_all.deb
    dpkg --audit
    dpkg -i a_1.0.0_all.deb
    dpkg --audit
    dpkg --configure -a
    dpkg --audit
    dpkg --remove a
    dpkg --remove b
    dpkg --remove a
    
    dpkg -i a_1.0.0_all.deb
    dpkg -i b_1.0.0_all.deb
    dpkg --audit
    dpkg -i a_1.0.1_all.deb
    dpkg --audit
    dpkg --remove a
    apt purge a
    
  3. To get in a loop where you can't complete installation neither remove it.

    Create clean A 1.0.1, B 1.0.0 but A 1.0.0 with a Prerm: script that contains exit 1. So when you try to install A 1.0.1, dpkg will fail to remove A 1.0.0 .

| improve this answer | |
0

If the dependencies A have changed on the installed package B you will see an error after performing apt-get update && apt-get upgrade the package will be marked as kept back:

The following packages have been kept back
B-1.0.0

dpkg will not help you , if an upgrade is available B-1.0.1only apt-get dist-upgrade will be helpful.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.