I'm working on a Chromebook. Since Chrome OS is based on Gentoo, the package management system that is available in developer mode is Portage. emerge is the command to use to install packages, but it is a very complex and hard to understand command and I've no clear instructions on how to do what I want to do.

There two things that I want to be able to do:

  1. List the names of installed packages.
  2. List the names of packages that can be installed.

In both case, the "name" of a package is the exact string that replaces NAME in the command emerge NAME in order to install said package.

I have wrote what I think is a solution to the first one and what wasn't really a satisfactory solution for the second one.

This is my script for listing installed packages (lipkgs):


cat /usr/local/var/lib/portage/world | sed "s/^.*\\///" | sort

This is my script for listing available packages (lapkgs):


cat /usr/local/portage/packages/Packages | grep "^CPV: " | sed "s/^CPV: .*\\///g" | sort

When I first wrote lapkgs, I had thought that /usr/local/portage/packages/Packages was a sort of cached file that contains all packages available from whatever repositories are setup to be connected to with Portage. My first problem with it is that the output contains names like xxd-1.10-r3, which is NOT the name that I type to install xxd, but rather the current package revision name or something; this name is going to var from package to package, so there isn't any general-purpose procedure I can write to clean them up. My second problem, which I realized much later, is that the names in /usr/local/portage/packages/Packages may not be a list of available packages, but rather some kind of list of installed packages as well virtual packages.

How do I do what I want to achieve for certain?

  • Just a couple of considerations, there are over 19k packages in the portage tree, and as Chris' answer may be partially correct, you need to think that the "names" as you want to show them can create ambiguity in portage, and that's why they use a prefix. The second consideration is that, as you may notice, there are virtual packages, real packages, and SLOTS, SLOTS are the cause of the ability to have multiple versions from the same package living together in portage. Like Nodejs, PHP, the kernel etc. – Christopher Díaz Riveros Aug 18 '17 at 1:51

List all packages: equery list '*'

If its got an I next to it its installed.

From: https://wiki.gentoo.org/wiki/Equery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.