✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Ebuild Repositories and Overlays

Ebuild repositories and overlays manage Linux packages, allowing customization and extending system functionality through layered package management.

Ebuild Repositories and Overlays are critical components of Gentoo Linux's Portage package management system. An Ebuild Repository is a structured collection of ebuild scripts, which are specialized bash scripts that define how software packages are fetched, configured, compiled, and installed on a Gentoo system. These repositories contain the entire package metadata and instructions, organized hierarchically by category and package name, enabling Portage to manage software installation and maintenance efficiently.

An Overlay is an additional, user- or community-maintained ebuild repository that exists alongside the main Gentoo repository tree. Overlays allow users to add new packages, maintain customized versions of existing packages, or test experimental ebuilds without modifying the official Gentoo repository. This flexibility supports Gentoo's philosophy of user control and customization.


Structure of Ebuild Repositories

Repository Layout

Ebuild repositories follow a standardized directory structure:

  • metadata/: Contains repository metadata files which control repository behavior and features.
  • categories/: Each directory under this represents a category (e.g., app-editors, net-misc).
  • ebuild files: Inside each category directory reside .ebuild files named after the package and version (e.g., vim-8.2.3456.ebuild).

This structure enables Portage to index and locate packages efficiently.

Metadata Files

Key metadata files include:

  • metadata.xml: Describes the repository, including its description, maintainers, and keywords.
  • layout.conf: Defines repository layout specifics, such as whether it uses ebuilds or binary packages.
  • profiles/*: Contains profiles that define global settings for packages in the repository.

These files help Portage understand repository characteristics and manage packages accordingly.


Ebuild Scripts

Purpose and Content

An ebuild is a bash script containing variables and functions that describe how to:

  • Download source code (SRC_URI)
  • Verify integrity (checksums)
  • Apply patches
  • Configure build parameters
  • Compile and install the package
  • Clean up build artifacts

It also specifies dependencies, slotting (allowing multiple versions), and USE flags to enable optional features.

Ebuild Phases

Ebuilds implement distinct phases in the build process, such as:

  • src_unpack: Unpack source archives
  • src_compile: Compile the source code
  • src_install: Install binaries and files into a temporary directory
  • pkg_postinst: Actions after installation (e.g., updating caches)

Developers customize these phases by overriding or appending shell functions in the ebuild.


Overlays

Definition and Purpose

Overlays extend the main Gentoo repository with additional ebuilds or customized package versions. They are especially useful for:

  • Packaging new software not yet in the official tree
  • Testing development or unstable versions
  • Providing specialized packages for niche use cases
  • Allowing user-specific customizations without affecting the global repository

Managing Overlays

Overlays can be managed using tools like layman or eselect repository. Users can add, remove, and update overlays easily, enabling flexible package management.

Each overlay maintains its own repository structure, metadata, and ebuilds. Portage recognizes overlays transparently alongside the main repository, merging their package lists.


Integration with Portage

Repository Configuration

Repositories and overlays are configured in /etc/portage/repos.conf/ or /etc/portage/make.conf by specifying repository locations, priority, and synchronization methods.

Synchronization

Repositories are typically synchronized via rsync or git, ensuring that users receive the latest ebuild updates. Overlays often use git repositories, facilitating decentralized management.

Package Masking and Keywords

Overlays can provide unkeyworded or masked packages, allowing users to selectively enable potentially unstable or testing packages by adjusting keywords and masks in /etc/portage/package.accept_keywords or /etc/portage/package.mask.


Best Practices for Maintaining Ebuild Repositories and Overlays

  • Consistent metadata: Maintain accurate metadata.xml and profiles for clarity and smooth integration.
  • Versioning and slotting: Use appropriate version numbers and slots to allow coexistence of multiple package versions.
  • Testing ebuilds: Ensure ebuilds build correctly on supported architectures and handle dependencies properly.
  • Documentation: Provide clear maintainers and description information in metadata.
  • Synchronization: Keep overlays updated and synchronized with upstream sources when applicable.
  • Security: Verify source integrity with checksums and use secure protocols for source retrieval.

Summary of Key Elements

ElementDescription
EbuildBash script defining package build and install instructions
RepositoryCollection of ebuilds organized by category and package
OverlayAdditional repository layered over the main tree for customization and extra packages
metadata.xmlFile describing repository metadata and maintainers
layout.confConfiguration controlling repository behavior
ProfilesGlobal settings and package defaults for repository
PortageGentoo's package manager that interacts with repositories and overlays
SynchronizationMethod (rsync/git) used to keep repositories and overlays up to date
USE flagsOptional features enabled or disabled for packages
SlottingMechanism to allow multiple versions of the same package to coexist

Ebuild Repositories and Overlays form the backbone of Gentoo's flexible and powerful package management system, enabling highly customizable software installation and maintenance tailored to user needs.