User:Hololeap/Emerge Obscura

From Gentoo Wiki
Jump to:navigation Jump to:search

Obscure arguments/usage for emerge

Skip upgrades with no binary available

Important
This method seems to work well with simple cases such as a "leaf" package (in @world, for instance. Aka. a "terminal node" in the graph-theory definition of a tree.)


However, with dependencies that tend to get upgraded as a group (such as llvm-core/*, and potentially even dev-qt/*) this method tends to be too lenient and simply fails to prevent the upgrade. Further testing is needed.

Also note that this method will likely not work correctly if FEATURES="buildpkg" is enabled, as it would always prefer the older binary on the system, especially if the package is not built on an upstream binhost.

Many people like using Gentoo's binary host for www-client/firefox because it can take a long time to compile. However, there is a window of time between when a new version gets released on ::gentoo, but before a binary is built on the binhost. Normally, if you run a world update in this window of time, it would build www-client/firefox from source since portage would prefer the later version that currently has no binary. What can be done to avoid this? This gets asked about a lot, so it might surprise people that there is an old command-line option for emerge that lets you do this:

CODE man emerge
--useoldpkg-atoms ATOMS
    A space separated list of package names or slot atoms. Emerge will prefer matching binary packages over newer unbuilt packages.

With this option, we can choose packages that we want portage to prefer binaries for, even if there are newer versions available.

FILE /etc/portage/make.conf
# Note that we need to escape the inner quotes surrounding the atom list
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --useoldpkg-atoms=\"www-client/firefox www-client/chromium\""

This works regardless of if a package is currently installed or not. The one caveat is that if there is no binary for the package (or there isn't one for the required version range or that satisfies the user-specified USE flags), portage will silently build from source instead. However, in practice, this option will reliably work for the most common scenario of wanting to hold off an upgrade until a binary is available.

Fine-grained --emptytree

Imagine you want to run a world update but you have some package that specifically needs to be rebuilt. It may not have an upgrade, so manually specifying it will do nothing since --update is being used. There is another obscure command-line argument for emerge that can help here:

CODE man emerge
--reinstall-atoms ATOMS
    A space separated list of package names or slot atoms. Emerge will treat matching packages as if they are not installed, and reinstall them if necessary.

Like the man page says, this option causes portage to pretend the specified packages are not currently installed. Therefore, it will rebuild these packages as long as they are part of the dependency tree. This is similar to --emptytree, except that you can specify exactly which packages need to be rebuilt, which could be very useful in some situations.

This option is central to the new mode of app-admin/haskell-updater, which is better at handling masked packages and other tricky scenarios compared to the "classic" mode.

Automatically populating emerge config files

This will analyze the entire dependency graph of @world and automatically populate emerge config files such as package.accept_keywords, package.unmask, and package.use. Since the entire dependency graph is analyzed, this can also spot problems that a normal world update may miss.

  1. Make files for autounmask to populate
    root #touch /etc/portage/package.accept_keywords/zzz-autounmask
    root #touch /etc/portage/package.unmask/zzz-autounmask
    root #touch /etc/portage/package.use/zzz-autounmask
  2. Add some default options for emerge (these options will do nothing until activated with --autounmask-write=y or similar).
    FILE /etc/portage/make.conf
    EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --autounmask-unrestricted-atoms=y --autounmask-keep-keywords=n --autounmask-keep-masks=n"
    
  3. Run the emerge command. You can add other targets besides @world if you plan on later installing other packages/sets.
    NOTE: This will not emerge anything; it will only update your configuration files
    root #FEATURES=-getbinpkg emerge --deep --complete-graph --with-bdeps=y --emptytree --usepkg-exclude='*/*' --autounmask-write=y --autounmask-only=y --autounmask-backtrack=y --backtrack=9999 --ask @world
  4. Run etc-update. (You may choose -5 to automatically merge if you are certain that there are no other pending changes.)
  5. Repeat steps 3 and 4 until no more configuration is written. (It should say "Calculating dependencies... done!" with no mention of "Autounmask changes successfully written.".)
  6. You may organize your configuration files by moving the recent changes from .../zzz-autounmask to other fiiles in the same directory. (For instance, I like to organize mine by grouping them into files that correspond to portage sets I have defined.)
  7. Run a world update as you normally would
    root #emerge --ask -DUu @world