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

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

Start by removing the old Gentoo ebuild repository configuration:

root #eselect repository remove gentoo

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 with Portage, having a "git" sync-type:

root #eselect repository add gentoo git https://github.com/gentoo-mirror/gentoo.git
Resolving qa-reports.gentoo.org... 151.101.2.137, 151.101.66.137, 151.101.130.137, ...
Connecting to qa-reports.gentoo.org|151.101.2.137|: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 /
[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

Delete the old repository:

root #rm -r /var/db/repos/gentoo
Note
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.