Pkg Cleanup After Uninstall

Hello! I recently completed a little experiment. I wanted to see what files are left over after installing a package via pkg, removing package, then autoremove to clear dependencies. This is my results from install sqlite3, remove the package, and autoremove (taking zfs snapshots of / before sqlite3 was installed and after autoremove, then executing zfs diff)

This one is surprising, this was before I installed pkg sqlite3 or even searched for it.
M /var/db/pkg/local.sqlite


M /var/run
M /root
M /var/db/pkg
M /var/db/entropy
M /var/db/pkg/local.sqlite
M /usr/local/share/licenses
M /usr/local/include
M /usr/local/lib
M /usr/local/libdata/pkgconfig
M /usr/local/share/man
M /usr/local/share/man/man3
M /usr/local/share/man/man5
M /var/db/pkg/repos/FreeBSD/lock
- /root/.lesshst
M /var/cache/pkg
M /usr/local/bin
M /usr/local/share/man/man1
M /usr/local/lib/python3.11/lib-dynload
M /usr/local/lib/python3.11/site-packages
+ /var/cache/pkg/py311-sqlite3-3.11.11_7~f56588625c.pkg
+ /var/cache/pkg/py311-sqlite3-3.11.11_7.pkg
+ /var/cache/pkg/libedit-3.1.20240808,1~897ceb5872.pkg
+ /var/cache/pkg/libedit-3.1.20240808,1.pkg
+ /var/cache/pkg/sqlite3-3.46.1,1~8c6c056553.pkg
+ /var/cache/pkg/sqlite3-3.46.1,1.pkg
+ /var/cache/pkg/py311-setuptools-63.1.0_1~9eb31eaf32.pkg
+ /var/cache/pkg/py311-setuptools-63.1.0_1.pkg
+ /root/.lesshst
+ /var/run/ld-elf.so.hints
- /var/run/ld-elf.so.hints
- /var/run/ld-elf32.so.hints
+ /root/zroot_root_default_diff
+ /var/db/entropy/saved-entropy.2
+ /var/run/ld-elf32.so.hints
 
I have experienced that lots of config files are left behind.
Configuration files are never deleted, as this would cause problems when a package is updated (which is essentially a delete followed by an install). It will tell you to remove the configuration file yourself, if you really want to remove everything.

Code:
# pkg delete nginx
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        nginx: 1.24.0_17,3

Number of packages to be removed: 1

The operation will free 1 MiB.

Proceed with deinstalling packages? [y/N]: y
[ports] [1/1] Deinstalling nginx-1.24.0_17,3...
[ports] [1/1] Deleting files for nginx-1.24.0_17,3: 100%
You may need to manually remove /usr/local/etc/nginx/nginx.conf if it is no longer needed.

Notice that last line?
 
Didn't know pkg used sqlite, interesting. I tried pkg clean however nothing to do. I will just manually clean up the pkgs left over.
 
I tried pkg clean however nothing to do.
pkg clean will only remove old package caches, if the package is installed it will leave them in the cache. A pkg clean -a will remove all cached packages.

Code:
     pkg clean is used to cleanup the local cache of packages downloaded from
     remote repositories.  It removes packages that have been superseded by
     newer versions, and any packages that are no longer provided.
Code:
     -a, --all
         Delete all cached packages including those, which have not been
         superseded by newer versions yet and are still in use.
pkg-clean(8)
 
  • Like
Reactions: drr
Back
Top