Solved pkg autoremove problem

# pkg autoremove
nothing to change
# pkg remove xterm
# pkg autoremove
a lot of packages to be removed, include xorg
# pkg install xterm
# pkg autoremove
nothing to change

Question 1: Why is it going to remove xorg?

# pkg remove kf5-breeze-icons-5.53.0
# pkg autoremove
a lot of package to be removed
# pkg install kf5-breeze-icons-5.53.0
# pkg autoremove
a lot of packages to be removed

Question 2: Why there are still packages to be removed? How to make # pkg autoremove show nohting to change?
 
It's not uncontrollable or unexpected. It does exactly what I expected. You just need to keep a closer watch on dependencies being removed when you delete a package (everything that depends on that package will also get removed).
 
It's not uncontrollable or unexpected. It does exactly what I expected. You just need to keep a closer watch on dependencies being removed when you delete a package (everything that depends on that package will also get removed).

As in the image below, there are 5 packages, A depends on C & D, B depends on D & E.
remove C -> remove A -> remove D -> remove B -> remove E
so remove C -> remove all the 5, right?

pkg.png
 
so remove C -> remove all the 5, right?
As was mentioned above: this behavior is controlled by what dependencies a package has, as well as the dependencies of those other packages. Your diagram makes little sense in that respect.

For example:
Code:
root@psi:/ # pkg search -dx xterm-342
xterm-342
Comment        : Terminal emulator for the X Window System
Depends on     :
        libXpm-3.5.12_2
        libX11-1.6.7,1
        libICE-1.0.9_3,1
        libXt-1.1.5_2,1
        libXmu-1.1.2_5,1
        libXaw-1.0.13_2,2
        libXft-2.3.2_3
        fontconfig-2.12.6,1
        freetype2-2.9.1
Ergo: if you install x11/xterm then it will also automatically pull in these dependencies. Each of these packages can have dependencies of their own which will also be pulled in:
Code:
root@psi:/ # pkg install -n xterm-342
--<CUT
New packages to be INSTALLED:
        xterm: 342
        libXpm: 3.5.12_2
        libXext: 1.3.3_3,1
        libXau: 1.0.8_5
        libX11: 1.6.7,1
        libxcb: 1.13.1
        libXdmcp: 1.1.2_2
        xorgproto: 2018.4
So the very moment that you uninstall x11/xterm followed by running # pkg autoremove then it will automatically uninstall all the above packages because they're no longer required by any other packages.

That's all there is to it: when pkg detects a package which was automatically installed and is no longer required by anything else then the autoremove command will remove it.

If you get strange or unexpected behavior then my first guess would be that you somehow mixed ports and packages. So: used both # pkg install ... as well as # make install (or a utility such as portmaster or such...) to install software. That is a very bad practice in general.
 
when pkg detects a package which was automatically installed and is no longer required by anything else then the autoremove command will remove it.

So, after pkg remove C and pkg autoremove, B D E will not be removed, right?

If you get strange or unexpected behavior then my first guess would be that you somehow mixed ports and packages. So: used both # pkg install ... as well as # make install (or a utility such as portmaster or such...) to install software. That is a very bad practice in general.

Is it true:
  1. pkg keeps integrity
  2. make install doesn't keep integrity, no automove function, and make deinstall only removes itself, i.e. not remove what it depends on and what depends on it
 
You think to complicated.

A single package (or port) can only be removed if you installed it yourself.
You can not delete xterm, because it wasn't you who installed it. It was the the xorg meta package that pulled it in, as a dependency.
If you are unsure what packges you actually installed yourself, run pkg prime-origins. This is what you installed yourself, and this is what you can uninstall. Compare that to pkg info, which shows you all packages/ports installed on your system.

so remove C -> remove all the 5, right?
No, it will not.
For your example: pkg delete C would attempt to remove C and A, as A would no longer function, if C was missing.
D will not be removed, not even by pkg autoremove because B still has it as a dependency.
 
You think to complicated.

A single package (or port) can only be removed if you installed it yourself.
You can not delete xterm, because it wasn't you who installed it. It was the the xorg meta package that pulled it in, as a dependency.
If you are unsure what packges you actually installed yourself, run pkg prime-origins. This is what you installed yourself, and this is what you can uninstall. Compare that to pkg info, which shows you all packages/ports installed on your system.


No, it will not.
For your example: pkg delete C would attempt to remove C and A, as A would no longer function, if C was missing.
D will not be removed, not even by pkg autoremove because B still has it as a dependency.

Thank you, it's clear. I'll check the document, and see if the document is clear enough :)
 
.., but why prime-origins can't be found in man pkg or pkg help,
It's an alias, set in pkg.conf(5).
where to find it?
Look inside /usr/local/etc/pkg.conf, # Sample alias settings.

If I may make a suggestion - FreeBSD has a very good documentation. Before applying a procedure in general, first to look should be in the handbook, after that man pages, articles,etc.. For example installing packages has an entire chapter in the handbook about that topic. After reading that chapter you may notice the prime-origins alias is mentioned there and where to find it. Also reading the Handbook beforhand, not only when you want to know a particular procedure, gives you a better understanding about the insides of FreeBSD and it makes more fun to work with.

Edit: All FreeBSD documentation for local installation: misc/freebsd-doc-all
Edit2: Bookmark the handbook, faq and articles in your favourite browser.
 
Back
Top