Re: Deletion of just installed port-packages (excluding base): success

From: Mark Millard <marklmi_at_yahoo.com>
Date: Thu, 07 Aug 2025 15:57:32 UTC

On Aug 7, 2025, at 02:01, Graham Perrin <grahamperrin@gmail.com> wrote:

> On 07/08/2025 06:44, Jesús Daniel Colmenares Oviedo wrote:
> 
>> Perhaps something like this (with a few additions):
>> 
>> 
>> ```
>> pkg query %n | grep -vEe '^(FreeBSD-.+)' | xargs pkg remove -n && pkg autoremove -n && pkg clean -n
>> 
>> ```
>> 
> 
> This is good. Thank you, Mark and Jesús, for progressing this.
> 
> 
> xargs pkg delete -fqy.txt (attached)
> ====================================
> 
> Quiet, forced deletion -- without question -- of pkg, pkg-provides, and around 830 other non-base packages.
> 
> The subsequent bootstrap of pkg succeeded.
> 
> My first use of the bootstrapped pkg failed only because re: <https://www.freshports.org/ports-mgmt/pkg-provides/#message>, I had omitted to reconfigure /usr/local/etc/pkg.conf for pkg to work without the plugin.
> 
> 
> xargs dry run.txt (attached)
> ====================================
> 
> All normal, as far as I can tell, with the dry run.
> 
> 833 non-base packages. No base package will be deleted.

Actually the file indicates that /var/cache/pkg/FreeBSD-*.pkg
files would be deleted by the "pkg clean" (if -n had not been
provided):

QUOTE
The following package files will be deleted:
        /var/cache/pkg/FreeBSD-libexecinfo-dev-lib32-15.snap20250715051601~2b1b4b0e75.pkg
        /var/cache/pkg/FreeBSD-telnet-man-15.snap20241026125659.pkg
. . .
        /var/cache/pkg/FreeBSD-bsdinstall-dbg-15.snap20250720000631.pkg
        /var/cache/pkg/FreeBSD-libexecinfo-dbg-15.snap20250720000631.pkg
The cleanup will free 1 GiB
END QUOTE

I do not know if this would be desired vs. not.

> xargs pkg delete -y.txt (attached)
> ====================================
> 
> Assuming yes, without also applying force, naturally stops when pkg will not delete itself.

Well, that means a large number of packages were not
deleted:

[49/833] Deleting files for PackageKit-1.3.1: 100%
[50/833] Deinstalling discount-2.2.7d...
[50/833] Deleting files for discount-2.2.7d: 100%
pkg: Cannot delete pkg itself without force flag

This does not match the documented pkg delete -a
behavior (no -f):

     The following options are supported by pkg delete:

     -a, --all  Deletes all installed packages except for pkg(8) from the
                system and cleans the database of information related to
                removed packages.

I'll also note that the "except for pkg(8)" text
might mean that enough of FreeBSD-* should be left
in place for pkg (and pkg-static) to be fully
operational. Either that, or more about the result
needs to be documented.

> Making a command memorable
> ====================================
> 
> An alias is tempting, however from <https://github.com/freebsd/pkg/pull/2300> I learnt that a pipe can be problematic. I apologise for my lack of knowledge there; it was fixed <https://github.com/freebsd/pkg/commit/fe3031f54b580f54e58fb2c34b12276a947090f8> after users of a release suffered the effects of my mistake.
> 
> 
> ----
> 
> Belated thanks to Ed Maste and arrowd (<https://github.com/freebsd/pkg/issues/2485#issuecomment-3133273925> and <https://github.com/freebsd/pkg/issues/2485#issuecomment-3134915559> in particular).
> <xargs pkg delete -fqy.txt><xargs dry run.txt><xargs pkg delete -y.txt>

===
Mark Millard
marklmi at yahoo.com