skip to Main Content

A debian package I made overwrote files belonging to other packages (using –force-overwrite option). I realized this was bad, but after deleting these files from the package, building and reinstalling, it’ll delete those files since it think’s my package owns those files and no longer needs them.

I need dpkg to forget my package ever knew about those files, such that I can remove/purge/install and without it ever thinking about those files again.

Note that this package is only meant to be deployed on systems I control, not distributed to clients, so tinkering with already installed packages is acceptable, so long as I can get this back to a non-messed up state.

Couldn’t find an answer on stackoverflow or here, appreciate any help or links to similar questions I missed.

2

Answers


  1. Chosen as BEST ANSWER

    Found that dpkg stores a list of each installed package's files here:

    /var/lib/dpkg/info/mydpkg.list
    

    Appears to be a list of every directory and file installed by the package, eg

    /etc/udev
    /etc/udev/rules.d
    /etc/udev/rules.d/95-serial485-pi3.rules
    /etc/udev/rules.d/97-serial485-pi4.rules
    

    Fix: sudo vim /var/lib/dpkg/info/mydpkg.list and delete lines of files I want my package to forget about, therefore not trying to delete when uninstalling (or when installing a new version of the package that doesn't have those files anymore.) Unclear on if it's necessary to delete the lines referencing parent directories (eg /etc/udev and /etc/udev/rules.d above).

    Bonus: I found this by using strace on the command that lists these files, finding out where it gets its info from:

    strace dpkg-query -L mydpkg
    

    Taken from here: https://unix.stackexchange.com/questions/200171/where-does-dpkg-l-gather-its-information


  2. We can use some commands that help us to keep the package dependency and remove the package.

    1. Remove the package without removing the dependency.

      sudo dpkg -r –force-depends <package_name>

    2. Remove the package including the configuration file and without removing the dependency.

      sudo dpkg -P –force-depends <package_name>

    I highly don’t recommend this thing because sometimes dependency may create an issue in the future.

    I always prefer to uninstall all the dependency when I uninstall the package.

    If your package is broken then you can use the following command to resolve an issue.

    To fix the broken packages

    sudo apt install -f
    

    I have answered this question based on this article.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search