✦ For everyone, free.

Practical knowledge for real and everyday life

Home

World Set and Selected Packages

World Set and Selected Packages define the core software components in Linux systems, guiding package selection and system behavior through predefined configurations.

World Set and Selected Packages represent two fundamental concepts in Gentoo Linux's Portage package management system, defining how software packages are managed, installed, and maintained across the system.

The World Set is a special collection of packages explicitly chosen by the user to be installed and maintained. This set serves as the primary reference for Portage's operations such as updates, upgrades, or removals. It effectively defines the system's desired state by listing all the packages that the user wants present on their system. Packages in the World Set are considered "top-level" packages, meaning they are installed because the user requested them directly, not just as dependencies.

Selected Packages refers to all packages that are currently installed on the system, whether they are explicitly installed by the user or automatically installed as dependencies of World Set packages. This includes all packages required to satisfy dependencies and any packages the user has manually added. The set of selected packages is a superset of the World Set.


World Set

Definition and Purpose

The World Set is a file-driven list that records the packages explicitly installed by the user. This list is maintained in a special file, typically located at /var/lib/portage/world or /var/lib/portage/world_sets for multiple sets. Each entry in this file corresponds to a package that the user has requested to be installed on the system, specifying the package category, name, and optionally a version or slot.

The purpose of the World Set is to provide a stable and user-defined baseline. When users run commands like emerge --update --deep @world, Portage uses the World Set to determine which packages should be updated or reinstalled. This ensures that the system reflects the user's explicit choices rather than installing or removing packages solely based on dependency changes.

Format and Management

Entries in the World Set are written in the format:

category/package-version

For example:

app-editors/vim-8.2.3456
sys-kernel/gentoo-sources

Version numbers may be omitted to track the latest version of a package automatically. Users can modify the World Set manually by editing the file or indirectly through Portage commands such as:

  • emerge --noreplace package — adds a package to the World Set without reinstalling it.
  • emerge --unmerge package — removes a package from the World Set and uninstalls it.
  • emerge --ask package — installs a package and adds it to the World Set.

Role in System Maintenance

The World Set underpins major system maintenance tasks:

  • Updates: When updating the system, Portage compares installed package versions with the latest available versions for World Set packages and their dependencies.
  • Dependency Resolution: Packages not in the World Set are installed only to satisfy dependencies. If a package is removed from the World Set and is no longer required by any other package, Portage can automatically remove it as an orphan.
  • System Consistency: Maintaining an accurate World Set helps avoid unintended package removals or installations during system maintenance.

Selected Packages

Definition and Scope

Selected Packages are all packages currently installed on the system, encompassing both user-requested (World Set) packages and their dependencies. This broader set includes every package Portage has installed to fulfill the requirements of the World Set.

Relationship to the World Set

The Selected Packages set contains the World Set as a subset. While the World Set lists packages explicitly chosen by the user, Selected Packages include those plus any additional packages automatically installed as dependencies. For example, if a user installs a web browser from the World Set, all required libraries and utilities for that browser become part of Selected Packages.

Management and Usage

Portage internally tracks Selected Packages to manage the system's package graph. This tracking ensures that:

  • Dependencies are resolved correctly.
  • Orphaned packages (those not required by any World Set package) can be identified and optionally removed.
  • The system maintains a consistent package state during upgrades or removals.

Commands like emerge --depclean operate by comparing Selected Packages with the World Set and their dependencies to clean up unnecessary packages.


Interaction Between World Set and Selected Packages

Dependency Handling

When a package is added to the World Set, Portage calculates its dependencies and installs all required packages, expanding the Selected Packages set. Conversely, removing a package from the World Set triggers a dependency check, potentially allowing Portage to remove dependencies no longer needed.

System Updates and Upgrades

The World Set drives the system update process. Portage uses it to:

  • Identify packages to upgrade.
  • Ensure dependencies remain satisfied.
  • Prevent accidental removal of user-requested packages.

During an update, all Selected Packages are evaluated, but only World Set packages and their dependencies are explicitly targeted.

Orphaned Packages and Cleanup

Selected Packages can include orphaned packages—those installed as dependencies but no longer required by any World Set package. Tools and Portage commands allow users to detect and remove orphaned packages, keeping the system lean and preventing accumulation of unnecessary software.


Practical Examples

Viewing the World Set

To list all packages in the World Set:

cat /var/lib/portage/world

or use:

equery list -I --world

Adding a Package to the World Set

Installing a package and adding it to the World Set:

emerge --ask package-name

This installs the package and records it in the World Set.

Removing a Package from the World Set

To uninstall a package and remove it from the World Set:

emerge --ask --unmerge package-name

Cleaning Orphaned Packages

To remove packages not needed by the World Set:

emerge --depclean

This command scans Selected Packages against the World Set and removes any unnecessary dependencies.


Summary of Key Points

ConceptDefinitionContentRole
World SetUser-defined list of explicitly installed packagesPackages explicitly chosen by userDefines system's desired package state
Selected PackagesAll installed packages, including dependenciesWorld Set + dependenciesRepresents actual installed software

The World Set and Selected Packages together provide a structured approach to package management in Gentoo, allowing users to control which software is installed while ensuring dependencies are correctly handled and system integrity is maintained.