Portage with Git

From Gentoo Wiki
Jump to:navigation Jump to:search

This article will explain how to use Git to synchronize the Gentoo ebuild repository.

Prerequisites

Tip
From version 14-r1 (available 2024-12-09), eselect-repository enables +git USE flag by default. If you want to use git synchronization, you must NOT disable this flag.

eselect-repository and Git must be installed; see their respective articles for installation instructions.

To reduce the risk of issues, it's recommended to sync the Gentoo repository before starting this process, and ensure that the system is using the latest profile.

Setup

Disable and remove the old Gentoo ebuild repository:

root #eselect repository remove -f gentoo
Removing /var/db/repos/gentoo ...
Updating repos.conf ...
1 repositories removed

If the obsolete variable PORTDIR is defined in make.conf (which may be the case on older Gentoo installations), remove that definition as well.

Note
If the system is old enough to have PORTDIR set to /usr/portage/, this is an excellent opportunity to migrate it to use more modern paths. Take note of the current profile by running eselect profile show, then delete the definition of PORTDIR and any other variables in make.conf which reference paths under /usr/portage/. The rest of these instructions assume that this has been done if necessary.

Configure a new repository:

root #eselect repository add gentoo git https://github.com/gentoo-mirror/gentoo.git
Adding gentoo to /etc/portage/repos.conf/eselect-repo.conf ...
Repository gentoo added
Tip
This example uses the GitHub mirror, which is almost universally available, however it does not support syncing via IPv6[1]. IPv6-only users should use https://anongit.gentoo.org/git/repo/sync/gentoo.git. instead, or investigate a NAT64 option.
Tip
You can view more git-related(sync-git*) options through man 5 portage.

Optionally, enable repository verification by adding sync-git-verify-commit-signature = yes to the repo configuration:

root #echo "sync-git-verify-commit-signature = yes" >> /etc/portage/repos.conf/eselect-repo.conf
Verification
Verify the repos.conf content, including in particular the location entry in the gentoo section:
user $portageq repos_config /
[DEFAULT]
auto-sync = yes
main-repo = gentoo
strict-misc-digests = true
sync-allow-hardlinks = true
sync-openpgp-key-refresh = true
sync-rcu = false

[gentoo]
auto-sync = yes
location = /var/db/repos/gentoo
masters = 
priority = -1000
strict-misc-digests = true
sync-allow-hardlinks = true
sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
sync-openpgp-key-refresh = true
sync-openpgp-key-refresh-retry-count = 40
sync-openpgp-key-refresh-retry-delay-exp-base = 2
sync-openpgp-key-refresh-retry-delay-max = 60
sync-openpgp-key-refresh-retry-delay-mult = 4
sync-openpgp-key-refresh-retry-overall-timeout = 1200
sync-openpgp-keyserver = hkps://keys.gentoo.org
sync-rcu = false
sync-type = git
sync-uri = https://github.com/gentoo-mirror/gentoo.git


Sync the repository with the new Git configuration:

root #emaint sync -r gentoo

Run again to test.

Later emerges may be lengthy without metadata cache during dependency resolution. The cache can be rebuilt using egencache. For further reading, refer to Portage and ebuild repository synchronization.

References