Portage Advanced Usage: Difference between revisions

From Elvanör's Technical Wiki
Jump to navigation Jump to search
No edit summary
Line 45: Line 45:


* Collision protection cannot apparently be disabled, even with -collision-protect and -protect-owned. The only way to partly disable it is to use the environment variable COLLISION_IGNORE with a list of directories (those are not recursively ignored).
* Collision protection cannot apparently be disabled, even with -collision-protect and -protect-owned. The only way to partly disable it is to use the environment variable COLLISION_IGNORE with a list of directories (those are not recursively ignored).
== Binary Packages ==
* Portage can build a binary package if a package was already emerged (installed) on a given system. This will just create an archive of all files and can be used to later install this binary package on another machine (without compiling as usual). This is very useful if you want to fix broken systems. For instance, let's say you have a broken system with a non-working gcc package, or missing critical shared libraries. You cannot reinstall gcc normally, but you could install a standard stage 3 tarball, chroot into it, create a gcc binary package (and other binary packages if needed), then take those binary packages and install them on main system to fix it.
* Creating the binary package is done via quickpkg:
quickpkg sys-devel/gcc
* Then the resulting package is (by default) installed in /var/cache/binpkgs. If needed, copy it to the target system. You can then install from a binary tarball with emerge -K:
emerge -K --oneshot sys-devel/gcc


=== Disabling test feature ===
=== Disabling test feature ===

Revision as of 07:36, 13 April 2021

This article lists some neat things you can do with Portage/emerge.

File locations

/etc/portage directory

This directory contains important configuration files for Portage.

  • package.accept_keywords lets you add keywords for individual packages. To allow unkeyworded packages to be installed, write app-emulation/wine ** in this file. You do not need to write it in package.mask.
  • package.use lets you add local USE flags for certain packages. To add/remove certain languages, you can use expanded USE flags:
USE="linguas_en -linguas_fr"
  • Note that on these two files, each line must contain only the package name and the options. Don't add any comment (comments must use a whole line) after the package name and options.
  • You can use package.env and the env directory to have per package FEATURES. See this page for more information.

Portage world file

It is located in /var/lib/portage/world.

Portage cache

It is located in /var/cache/edb.

revdep-rebuild cache files

They are in /var/cache/revdep-rebuild (no longer in /root).

emerge options

  • --newuse will recompile packages that had their USE flags changed.
  • --depclean will attempt to remove packages that are no longer needed as dependencies.
  • --fetchonly will only fetch the distribution files.
  • -t will display a tree view. It can be very useful to know which package pulls in another one.
  • -O will disable any dependency check (both on the dependencies of the emerged packages, and on already installed packages to see if an upgrade would not satisfy them). It can be a very useful options when there are bugs in the Gentoo tree and you really need to upgrade a package without checking dependencies.
  • To emerge a particular version of a package: emerge =mypackage-0.6.3-r2

Variables

  • CONFIG_PROTECT and CONFIG_PROTECT_MASK can be set in /etc/make.conf and control the behavior of the configuration protection feature. Note that turn it off in /etc, you must set CONFIG_PROTECT_MASK="/etc", it is not enough to set CONFIG_PROTECT="".

Features

  • Collision protection cannot apparently be disabled, even with -collision-protect and -protect-owned. The only way to partly disable it is to use the environment variable COLLISION_IGNORE with a list of directories (those are not recursively ignored).

Binary Packages

  • Portage can build a binary package if a package was already emerged (installed) on a given system. This will just create an archive of all files and can be used to later install this binary package on another machine (without compiling as usual). This is very useful if you want to fix broken systems. For instance, let's say you have a broken system with a non-working gcc package, or missing critical shared libraries. You cannot reinstall gcc normally, but you could install a standard stage 3 tarball, chroot into it, create a gcc binary package (and other binary packages if needed), then take those binary packages and install them on main system to fix it.
  • Creating the binary package is done via quickpkg:
quickpkg sys-devel/gcc
  • Then the resulting package is (by default) installed in /var/cache/binpkgs. If needed, copy it to the target system. You can then install from a binary tarball with emerge -K:
emerge -K --oneshot sys-devel/gcc

Disabling test feature

  • You can add a file in /etc/portage/env/dev-python/pygtk (for instance) with the following content:
FEATURES=${FEATURES/test/}

Gentoolkit

  • equery files ebuild_name will list all the files installed by the specified ebuild.
  • qfile /path/to/file will display which package provides that particular file. It can sometimes be useful (it searches in all packages in repository, not only in installed ones).

Profiles

  • Profiles contain default configuration values and settings.
  • For a server machine, don't use the server profile. It is not yet production-ready. Use the generic profile, eg default/linux/x86/2008.0 (for a desktop box, use default/linux/x86/2008.0/desktop).

Updating operations

  • If you update a major Python version (eg, 2.5 to 2.6), you must run python-updater to ensure a smooth transition. Be careful to run python-updater before emerge --depclean, as the remerge is much more difficult if the old python version is not there anymore.

Troubleshooting

  • If an ebuild fails to emerge because of memory issues (not enough RAM), you should change MAKEOPTS="-j9" to MAKEOPTS="-j1" temporarily. This will allow only a single compiling thread to run, thus reducing overall memory usage and solving the issue.

Useful Links