You are not logged in.

#1 2018-12-22 04:26:44

jamespharvey20
Member
Registered: 2015-06-09
Posts: 129

[SOLVED] List packages installed from custom repo

I have a local custom package repository.  It's shared, so I use "CleanMethod = Keep Current" to prevent packages from being removed that are installed on some but not all machines using the shared repo.

On a specific machine, how can I easily get a list what packages are installed on it from this custom repo?


"pacman -Qm" lists foreign packages, which are usually files manually installed using "--upgrade" or deleted from repositories, but that doesn't show what I'm looking for since they're from a recognized repo.

Diff'ing its output with and without the custom repo temporarily commented out in "/etc/pacman.conf" does the trick, but I'm looking for something that can do it without having to modify the file.


I do use "VerbosePkgLists" which shows the repo name, but that only shows during an upgrade, sync, or remove operation, not things like "pacman -Q"


EDIT: Awesome, thanks Trilby!

Last edited by jamespharvey20 (2018-12-22 05:01:33)

Offline

#2 2018-12-22 04:45:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,522
Website

Re: [SOLVED] List packages installed from custom repo

pacman -Sl $repo_name | awk '/installed.$/{print $2;}'

Last edited by Trilby (2018-12-22 04:48:58)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-12-22 10:27:38

arisinfenix
Member
From: Germany
Registered: 2018-06-20
Posts: 37

Re: [SOLVED] List packages installed from custom repo

Or paclist from the pacman-contrib package.

paclist $repo_name

It basically does the same thing, piping pacman -Sl output to awk and print installed packges.

Offline

#4 2018-12-22 14:38:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,522
Website

Re: [SOLVED] List packages installed from custom repo

Except paclist doesn't have a quiet option, so you'd have to pipe the output of paclist to yet another process.  So it's four subshells and two pipes for paclist, or one subshell and one pipe for my command.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2018-12-23 02:37:15

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] List packages installed from custom repo

Why does paclist require subshells or pipes to take the same repository argument as pacman but provide "installed" filtering in-process? It should be none of either if you are okay with printing the same fields $2 and $3 which pacman would print, or the same one subshell and one pipe if you wish to provide a filter that emulates a --quiet option to drop field $3 (which is field $2 in paclist).


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#6 2018-12-23 03:57:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,522
Website

Re: [SOLVED] List packages installed from custom repo

Why does it require them?  You've got me, ask the authors.  But as currently written, it does.

As for the rest of your post, I can't really parse it.  Paclist internally has something very much like my command, but it doesn't have code to not print the version number, so using paclist would require one additional pipe and subshell in order to add another filtering step to chop of the version number.  My command was pacman piped to awk, using paclist internally pipes pacman to awk, but then the output of this would need to be piped again to awk (or a similar tool) adding one more pipe and one more subshell.  Then internally, paclist adds another subshell for gettext, and there is yet another for running the paclist script itself.

As far as --quiet flag(s), there is no such thing in paclist, nor would it pass the unrecognized flag on to pacman.  It would simply either fail to do anything if you passed the --quiet flag first as it'd only run `pacman -Sl --quiet` with no repo (thus failing to acheive the actual intent) but then since this was quiet, it would not list what is installed in the output and so the second step of paclist's pipe would filter out *everything* resulting in empty output.  Alternatively, if '--quiet' is passed after a repo name, it is simply ignored completely.

EDIT: you do realize paclist is just a shell script, right?

Last edited by Trilby (2018-12-23 03:59:27)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2018-12-23 04:34:35

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] List packages installed from custom repo

Actually I did not look at what kind of executable paclist was, and was looking at this purely from the perspective of things exposed on the command line.

I'm slightly disappointed that it's implemented as a pretty trivial shellscript when the thing that it is doing is so simple the script only ends up serving as an alias, but I seemed to recall that several of the utilities which pacman-contrib provided were written in C linking to libalpm -- which has a real excuse to exist regardless of how trivial.

Last edited by eschwartz (2018-12-23 04:35:38)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#8 2018-12-23 05:52:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,522
Website

Re: [SOLVED] List packages installed from custom repo

eschwartz wrote:

I seemed to recall that several of the utilities which pacman-contrib provided were written in C linking to libalpm -- which has a real excuse to exist regardless of how trivial.

Well ... if 2 out of 11 is several:

$ file $(pac -Qlq pacman-contrib | grep '^/usr/bin/')
/usr/bin/:               directory
/usr/bin/checkupdates:   Bourne-Again shell script, ASCII text executable
/usr/bin/paccache:       Bourne-Again shell script, ASCII text executable
/usr/bin/pacdiff:        Bourne-Again shell script, ASCII text executable
/usr/bin/paclist:        Bourne-Again shell script, ASCII text executable
/usr/bin/paclog-pkglist: Bourne-Again shell script, ASCII text executable
/usr/bin/pacscripts:     Bourne-Again shell script, ASCII text executable
/usr/bin/pacsearch:      Perl script text executable
/usr/bin/pacsort:        ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=6cf9f9b97ea2b0b2d28616ae319c0b1001a74136, stripped
/usr/bin/pactree:        ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=0970562bab9c5228f7b28a1dbdb97483c74c3f34, stripped
/usr/bin/rankmirrors:    Bourne-Again shell script, ASCII text executable
/usr/bin/updpkgsums:     Bourne-Again shell script, ASCII text executable

Last edited by Trilby (2018-12-23 05:56:32)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB