Title : Gentoo cheatsheet
Author: Solène
Date : 05 July 2021
Tags : linux gentoo cheatsheet
# Introduction
This is a simple cheatsheet to manage my Gentoo systems, a linux distribution source based, meaning everything installed on the computer must be compiled locally.
Gentoo project
# Upgrade system
I use the following command to update my system, it will downloaded latest portage version and then rebuild @world (the whole set of packages manually installed).
emerge-webrsync 2>&1 | grep "The current local"
if [ $? -eq 0 ]
emerge -auDv --with-bdeps=y --changed-use --newuse @world
# Use ccache
As you may rebuild the same program many times (especially on a new install), I highly recommend using ccache to reuse previous builded objects and will reduce build duration by 80% when you change an USE.
It's quite easy, install ccache package, add 'FEATURES="ccache"' in your make.conf and do "install -d -o root -g portage -p 775" /var/cache/ccache and it should be working (you should see files in the ccache directory).
Gentoo wiki about
# Use genlop to view / calculate build time from past builds
Genlop can tell you how much time will be needed or remains on a build based on previous builds information. I find it quite fun to see how long an upgrade will take.
Gentoo wiki about
## View compilation time
From the package genlop
```shell command
# genlop -c
Currently merging 1 out of 1
* app-editors/vim-8.2.0814-r100
current merge time: 4 seconds.
ETA: 1 minute and 5 seconds.
## Simulate compilation
Add -p to emerge command for "pretend" and pipe it to genlop -p like this
```shell command
# emerge -av -p kakoune | genlop -p
These are the pretended packages: (this may take a while; wait...)
[ebuild R ~] app-editors/kakoune-2020.01.16_p20200601::gentoo 0 KiB
Estimated update time: 1 minute.
# Using gentoolkit
The gentoolkit package provides a few commands to find informations about packages.
Gentoo wiki page about
## Find a package
You can use "equery" from the package gentoolkit like this "equery l -p '*package name*" globbing with * is mandatory if you are not looking for a perfect match.
Example of usage:
```shell command
# equery l -p '*firefox*'
* Searching for *firefox* ...
[-P-] [ ] www-client/firefox-78.11.0:0/esr78
[-P-] [ ~] www-client/firefox-89.0:0/89
[-P-] [ ~] www-client/firefox-89.0.1:0/89
[-P-] [ ~] www-client/firefox-89.0.2:0/89
[-P-] [ ] www-client/firefox-bin-78.11.0:0/esr78
[-P-] [ ] www-client/firefox-bin-89.0:0/89
[-P-] [ ] www-client/firefox-bin-89.0.1:0/89
[IP-] [ ] www-client/firefox-bin-89.0.2:0/89
## Get the package name providing a file
Use "equery b /path/to/file" like this
```shell command
# equery b /usr/bin/2to3
* Searching for /usr/bin/2to3 ...
dev-lang/python-exec-2.4.6-r4 (/usr/lib/python-exec/python-exec2)
dev-lang/python-exec-2.4.6-r4 (/usr/bin/2to3 -> ../lib/python-exec/python-exec2)