44

I'm using pacman 5.0.1 on Arch Linux and I'd like to get information about packages installed on my machine as well as packages in the remote repositories.

Information should include a description of the package, its size, and its build date.

4
  • 1
    I don't get it, you asked this question not even one minute before you answered it yourself. You seem to do that a lot, is that just to increase your reputation artificially? Commented Feb 1, 2020 at 12:21
  • 4
    @RedGlyph: This site also encourages answering one's own questions, see this checkbox from the "Answer Question" form. You're right, I've made a habit out of publishing the solutions I found to the questions I had. I do this in order for others to profit from my endeavors and for myself since this documents my solutions. It doesn't increase my reputation artificially, instead, other people vote on my Q&As if they found them useful, that's how reputation is increased. Commented Feb 1, 2020 at 13:04
  • 1
    That's interesting. That looked a little weird on a question-based site, but why not? Thanks for the info! Commented Feb 2, 2020 at 10:31
  • I'm happy to have cleared things up! :-) There's actually a common school of thought behind my way of using Stack Exchange, from the SO Tour: ... we're working together to build a library of detailed answers to every question about programming Commented Feb 2, 2020 at 11:36

1 Answer 1

68

Using --info

Taking vi as an example, to get information about its locally installed package use

pacman -Q --info vi 

This produces

Name : vi Version : 1:070224-2 Description : The original ex/vi text editor Architecture : x86_64 URL : http://ex-vi.sourceforge.net/ Licenses : custom:ex Groups : base Provides : None Depends On : ncurses Optional Deps : s-nail: used by the preserve command for notification [installed] Required By : None Optional For : None Conflicts With : None Replaces : None Installed Size : 290.00 KiB Packager : Evangelos Foutras <[email protected]> Build Date : Sun 06 Sep 2015 09:34:15 PM CEST Install Date : Mon 03 Oct 2016 07:18:13 PM CEST Install Reason : Explicitly installed Install Script : No Validated By : Signature 

Alternatively use the shorter -i option:

pacman -Qi vi 

To only get the value of a specific package property, let's say the description, there's good old grep to filter the output:

pacman -Qi vi | grep -Po '^Description\s*: \K.+' 

Which prints

The original ex/vi text editor

A short explanation of the grep command above:

  • -P activates Perl-compatible regular expressions
  • -o print only the matched parts of a matching line, not the whole line
  • ^Description\s*: \K.+ is the regex: The line must start with "Description" followed by any number of whitespace characters, followed by ": ". Then:
    • \K resets the starting point of the match. The matched characters starting with "Description" are not included in the final match
    • Finally, .+ matches everything afterwards, which is the package description

Here's a general answer on how to remove known prefixes from lines.


Getting information from the remote repository works similar:

pacman -Si vi 

When you only know parts of the package's name, use the -s option:

pacman -Ss jdk 

To find out which packages depend on a certain package — for example if you're wondering why a package exists on your system — you can use pactree:

pactree -r intel-media-driver 

which produces a nice dependency tree:

intel-media-driver └─intel-media-sdk └─ffmpeg ├─electron6 │ └─code ├─firefox ├─freerdp │ └─wlroots │ └─sway ├─qt5-webengine │ └─python2-pyqtwebengine │ └─calibre ├─unpaper │ └─ocrmypdf ├─vlc └─wf-recorder-git 

Minimal package browser

Combining the previous commands with fzf allows for a minimal textual package browser.

For local packages:

cmd='(pacman -Qi {}; pactree -r {})'; pacman -Q --quiet | fzf --preview "$cmd" 

For remote packages:

cmd='pacman -Si {2}'; pacman -S --list | fzf --preview "$cmd" 

You can scroll the preview with Shift+ and Shift+.

To open the preview in your editor with Enter, change the command to:

fzf --preview "$cmd" --bind "enter:execute($EDITOR <($cmd))" 

Here the contents of the preview are passed to your editor using process substitution.

You might also add this to install a remote package with Alt+Enter:

--bind "alt-enter:execute(sudo pacman -S {2})" 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.