C pkg plugin to display orphaned packages

zirias@

Developer
From time to time, I need to check my machines for installed packages that aren't available in my repository any more, so I can remove them. This is possible with pkg query, pkg rquery and a little shell scripting, but each time I have to think again how to script this, and it really isn't efficient either.

So, having discovered pkg offers a plugin API, I quickly created a little and stupid plugin doing just this. Maybe someone finds it useful ;)
 
I need to check my machines for installed packages that aren't available in my repository any more, so I can remove them.
pkg version -vRl'?'

Code:
     ?       The installed package does not appear in the index.  This could
             be due to an out of date index or a package taken from a PR that
             has not yet been committed.
Code:
     -l limchar, --like limchar
                 Display only the packages which status flag matches the one
                 specified by limchar.
From pkg-version(8).

I usually check my machines with pkg version -vRL=. This will show everything that needs to be updated or has been orphaned, i.e. everything that's not up to date.
 
Ah yes, outputs a bit more than I need, but that's also easily fixed in shell script, so I could drop the plugin again.
Anyways, nice experience to test out the plugin API :)
 
Anyways, nice experience to test out the plugin API :)
I might have a look at your plugin too when I have the time for it. Until quite recently I wasn't even aware there was a plugin option for pkg(8) :eek:

With regards to query and rquery, I do know you can make aliases for those. That's also a nice feature to play with, there are some interesting ones already defined:
Code:
# pkg alias
ALIAS                ARGUMENTS
all-depends          'query %dn-%dv'
annotations          'info -A'
build-depends        'info -qd'
cinfo                'info -Cx'
comment              'query -i "%c"'
csearch              'search -Cx'
desc                 'query -i "%e"'
download             'fetch'
iinfo                'info -ix'
isearch              'search -ix'
prime-list           'query -e '%a = 0' '%n''
prime-origins        'query -e '%a = 0' '%o''
leaf                 'query -e '%#r == 0' '%n-%v''
list                 'info -ql'
noauto               'query -e '%a == 0' '%n-%v''
options              'query -i "%n - %Ok: %Ov"'
origin               'info -qo'
provided-depends     'info -qb'
rall-depends         'rquery %dn-%dv'
raw                  'info -R'
rcomment             'rquery -i "%c"'
rdesc                'rquery -i "%e"'
required-depends     'info -qr'
roptions             'rquery -i "%n - %Ok: %Ov"'
shared-depends       'info -qB'
show                 'info -f -k'
size                 'info -sq'
unmaintained         'query -e '%m = "ports@FreeBSD.org"' '%o (%w)''
runmaintained        'rquery -e '%m = "ports@FreeBSD.org"' '%o (%w)''
 
With regards to query and rquery, I do know you can make aliases for those. That's also a nice feature to play with, there are some interesting ones already defined:
Nice indeed! But to find orphans this way, you have to do something like this
Code:
for p in `pkg query %n`; do pkg rquery %n $p >/dev/null || echo $p; done
so aliases wouldn't help here and it's very inefficient, spawning a pkg process for every installed package ;)

Your approach with pkg version solves this nicely.
 
Back
Top