✦ For everyone, free.

Practical knowledge for real and everyday life

Home

emerge

emerge is a package manager for Gentoo Linux, used to install, update, and manage software packages from the portage tree.

emerge is the primary command-line interface for the Portage package management system, used predominantly in Gentoo Linux and its derivatives. It automates the process of installing, updating, configuring, and removing software packages by compiling source code tailored to the user's system. emerge manages dependencies, retrieves source code from repositories, applies patches, and builds packages according to user-specified settings and system profiles.


Core Functionality

Package Installation and Removal

emerge installs software packages from source by resolving dependencies recursively. When a user requests to install a package, emerge fetches the necessary source files, merges configuration options, compiles the software, and installs it into the system. It can also uninstall packages cleanly, ensuring dependent packages are considered to maintain system integrity.

Dependency Resolution

One of emerge’s key features is its advanced dependency resolution algorithm. It analyzes the entire package dependency tree, including build-time and runtime dependencies, ensuring all required components are installed in the correct order. emerge can detect conflicts, circular dependencies, and missing packages, providing detailed feedback to the user.

Configuration via USE Flags

USE flags are a unique mechanism in Portage controlled through emerge. They allow fine-grained customization of package features before compilation, enabling or disabling optional functionality. emerge respects global, package-specific, and environment USE flags to build software optimized for the user's preferences and hardware.

Upgrading and Updating Packages

emerge can update individual packages or the entire system. When updating, it compares installed versions with available versions in the repository, calculating the best upgrade path while respecting dependency constraints and USE flags. emerge supports selective upgrades, system-wide world updates, and deep dependency rebuilds.


Operational Modes and Options

Interactive and Automated Modes

emerge can operate interactively, prompting users for confirmation during complex operations, or in automated mode for scripting and batch jobs. The --ask option causes emerge to display planned actions before execution, whereas --quiet suppresses output for minimal verbosity.

Dependency Graph Visualization

emerge provides options to visualize dependency trees, assisting in understanding package relationships and troubleshooting conflicts. Options like --tree display a hierarchical list of dependencies during operations.

Slotting and Multiple Versions

emerge supports slotting, allowing multiple versions of a package to coexist if designed to do so. This is useful for libraries or software requiring different ABI versions simultaneously. emerge handles slot dependencies and ensures correct version selection.


Configuration and Integration

Configuration Files

emerge’s behavior is controlled via configuration files such as /etc/portage/make.conf for global settings (including USE flags, compiler options, mirrors) and /etc/portage/package.use for per-package USE flag overrides. These configurations influence how emerge builds and installs software.

Integration with ebuild Scripts

emerge relies on ebuild scripts, which are specialized shell scripts describing how to download, configure, compile, and install each package. These scripts contain metadata such as dependencies, source URIs, and build instructions. emerge parses and executes ebuilds to manage software lifecycle.

Logging and History

emerge maintains logs of operations and package states, enabling rollback and system audit. Logs help diagnose build failures and track changes over time, supporting system maintenance and recovery.


Advanced Features

Dependency and Slot Conflict Resolution

emerge implements heuristics and user prompts to resolve conflicts arising from incompatible USE flags, slot overlaps, or masked packages. It can suggest solutions or require manual intervention for complex scenarios.

Binary Package Support

While emerge primarily builds from source, it supports binary package usage through the quickpkg and emerge --usepkg options. This allows faster deployments by installing precompiled packages when available and compatible.

Parallel Compilation and Optimization

emerge leverages parallel compilation by utilizing multiple CPU cores via the -j option, significantly reducing build times. It respects compiler optimization flags set in configuration to produce efficient binaries tailored to the hardware.


Usage Examples

# Install the latest version of vim with default USE flags
emerge vim

# Update all installed packages to the latest versions respecting USE flags
emerge --update --deep --with-bdeps=y @world

# Remove a package and its unused dependencies
emerge --depclean package-name

# Display dependency tree of a package before installation
emerge --tree package-name

# Install a package with a specific USE flag enabled
echo "app-editors/vim gtk" >> /etc/portage/package.use
emerge app-editors/vim

Summary

emerge is a powerful, flexible, and comprehensive package management tool that embodies Gentoo Linux’s philosophy of customization and control. It integrates source compilation, dependency management, and configuration customization through USE flags and ebuild scripts, enabling users to maintain a highly optimized and tailored Linux system. Its robust dependency resolution, flexible configuration, and advanced features make emerge a critical component for managing software in Gentoo and similar environments.