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.


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.


Make sure dev-vcs/git is installed before proceeding!

Start by disabling the old Gentoo ebuild repository configuration:

root #eselect repository disable gentoo
Updating repos.conf ...
1 repositories disabled

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

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 with Portage (eselect repository will default to "git" sync-type for this):

root #eselect repository enable gentoo
Resolving qa-reports.gentoo.org...,,, ...
Connecting to qa-reports.gentoo.org||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 260904 (255K) [text/xml]
Saving to: '/root/.cache/eselect-repo/repositories.xml'

repositories.xml                        100%[=============================================================================>] 254.79K  1.25MB/s    in 0.2s    

2022-08-20 09:17:36 (1.25 MB/s) - '/root/.cache/eselect-repo/repositories.xml' saved [260904/260904]

Adding gentoo to /etc/portage/repos.conf/eselect-repo.conf ...
Repository gentoo added
Verify the repos.conf content, including in particular the location entry in the gentoo section:
user $portageq repos_config /
auto-sync = yes
main-repo = gentoo
strict-misc-digests = true
sync-allow-hardlinks = true
sync-openpgp-key-refresh = true
sync-rcu = false

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
The default location is a repository hosted on GitHub, which does not support cloning via IPv6 [1], so IPv6-only users should modify the /etc/portage/repos.conf/eselect-repo.conf file, replacing the GitHub link with https://anongit.gentoo.org/git/repo/gentoo.git.

Delete the old repository:

root #rm -r /var/db/repos/gentoo
If the old repository is in /usr/portage, remove that directory instead. Any existing distfiles (in /usr/portage/distfiles/) or binary packages (in /usr/portage/packages/) can be moved to the new locations under /var/cache/ if desired. Run eselect profile set <profile> to set the same profile noted earlier.

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.