Gentoo, list installed packages with USE flags

November 15, 2009
Gentoo

Saving of operating system state could be very important sometimes. If you ever faced with a problem that you needed to find out which updated component caused a strange behaviour of some program then you know what I mean. Over the last few years I've been using my own backup program that creates reserve copies from different data sources. It also stores the system state as a set of config files and reports. History of changes is tracked by a version control system so each change is described by a system administrator. My program is not ready for publication yet since it should be improved in order to be used by other people. But I will share some of its components periodically. Today I'll tell you about report that contains list of all packages installed on Gentoo GNU/Linux including their USE flags.

Many of Gentoo users probably know the command for listing all installed packages. It could be done with equery utility from gentoolkit package.

# equery list

...
[I--] [  ] x11-libs/Xaw3d-1.5-r1 (0)
[I--] [  ] x11-libs/cairo-1.8.8 (0)
[I--] [  ] x11-libs/gtk+-2.16.6 (2)
[I--] [  ] x11-libs/libICE-1.0.5 (0)
[I--] [  ] x11-libs/libSM-1.1.1 (0)
[I--] [  ] x11-libs/libX11-1.2.2 (0)
[I--] [  ] x11-libs/libXScrnSaver-1.1.3 (0)
...

Its output is pretty useful but isn't often sufficient for our needs since a package state depends on USE flags. To list them all for each package you can use my script.

# list-gentoo-packages.sh

...
x11-libs/Xaw3d-1.5-r1
x11-libs/cairo-1.8.8 +X +opengl +svg -cleartype -debug -directfb -doc -glitz -xcb
x11-libs/gtk+-2.16.6 +cups +jpeg +tiff -debug -doc -jpeg2k -test -vim-syntax -xinerama
x11-libs/libICE-1.0.5 +ipv6 -debug
x11-libs/libSM-1.1.1 +ipv6 +uuid -debug -elibc_FreeBSD
x11-libs/libX11-1.2.2 +ipv6 +xcb -debug
x11-libs/libXScrnSaver-1.1.3 -debug
...

This is done by direct analysis of Portage database, that is located at /var/db/pkg/, and IUSE files for each package. It could be useful to compare reports generated before and after system update. This helps to reveal trivial mistakes. I hope it will be helpful for you.

Download list-gentoo-packages.sh, version 0.2.

Nikita Melnichenko.

Comments

Piotr
10.02.2010, 15:55

Thanks, I looked for something like that.

20.06.2010, 22:47

Thanks, that will really help!

20.06.2010, 22:53

Thanks, great job!

22.11.2011, 18:40

Hi,

How can I use this list to install the same software (same USE flags and same version) on a other server?
Thanks in advance for any answer.

Nikita Melnichenko
30.11.2011, 22:05

Hi plop,

Consider the following:
# list-gentoo-packages.sh > installed-packages
# cat installed-packages | sed 's/^/=/' > use
# cat use
...
=x11-libs/cairo-1.10.2-r1 +X +glib +opengl +qt4 +svg -aqua -debug -directfb -doc -drm -gallium -openvg -static-libs -xcb
=x11-libs/gdk-pixbuf-2.24.0-r1 +X +introspection +jpeg +tiff -debug -doc -jpeg2k -test
=x11-libs/gtk+-2.24.5-r1 +cups +introspection -aqua -debug -doc -examples -test -vim-syntax -xinerama
=x11-libs/gtksourceview-2.10.5-r1 -doc -glade -test
=x11-libs/libICE-1.0.7 +ipv6 -doc -static-libs
...
# cat installed-packages | awk '{ print $1; }' | sed 's/^/=/' > atoms
# cat atoms
...
=x11-libs/cairo-1.10.2-r1
=x11-libs/gdk-pixbuf-2.24.0-r1
=x11-libs/gtk+-2.24.5-r1
=x11-libs/gtksourceview-2.10.5-r1
=x11-libs/libICE-1.0.7
...

Copy 'use', 'atoms', /etc/portage/, /usr/portage/ as well as /etc/make.conf, /var/lib/portage/world and overlays to another machine and then do:
# cat use >> /etc/portage/package.use
# emerge -pv1 $(cat atoms)

13.02.2017, 05:42

Add comment

Text will be published as is. No HTML allowed. key