[Guide] Migrate Gentoo Portage to Git

Migrate Gentoo Portage to Git

  1. Install Git
    • emerge -av dev-vcs/git
  2. Update your gentoo repos.conf file
    • vi /etc/portage/repos.conf/gentoo.conf
    • add the following lines, comment the other equivalent lines:
      • sync-type = git
      • sync-uri = git://git.gentoo.org/repo/gentoo.git
  3. Create the following script which will run after updating
    • vi /etc/portage/postsync.d/eix-update
    • #!/bin/bash
      if [ -e /etc/portage/make.conf ]; then
          . /etc/portage/make.conf
          if [ ! -d $PORTDIR/metadata/md5-cache -o -d $PORTDIR/.git ]; then
              echo "updating metadata cache ..."
              egencache --repo=gentoo --update
  4. Move your distfiles folder and update make.conf to point to the new location
    • mkdir -p /var/portage && mv /usr/portage/distfiles /var/portage/distfiles/
  5. Rename/move your existing portage folder
    • mv /usr/portage /usr/portage-old/
  6. Run sync again
    • eix-sync



[Optional] Create your own portage repository server running git (so you can sync your other machines from it)


  1. Create git user and group
    1. groupadd git
    2. useradd -m git -g git
  2. Install Git (if not already installed)
    • emerge -av dev-vcs/git
  3. Update your git-daemon file
    • vi /etc/conf.d/git-daemon 
      • GITDAEMON_OPTS="--syslog --base-path=/usr/portage/ portage"
      • GIT_USER="git"
      • GIT_GROUP="git"
  4. Start git-daemon service and add it to ’default’ runlevel
    • service git-daemon start
    • rc-update add git-daemon default
  5. Configure your other gentoo machines to use this git repo instead of official gentoo repo (assuming the steps in the previous paragraph have been applied)
  6. You may want to be able to sync without entering username and password, so do this on your other machines (run as root)
    • Create private and public ssh keys (as root) - only if they aren’t created already
      • ssh-keygen
    • Copy your public key to your central repository machine
  7. Disable normal login for git user (do this on your repository server)
    • usermod -s /bin/false git
    • alternatively, you can run 'vipw' then edit the 'git' user, changing the default login from '/bin/bash' to '/bin/false'
  8. Disable password login for git user- (allow only ssh key authentication (do this on your repository server)
    • edit /etc/ssh/sshd_config and add these two lines at the end of the file:
      • Match User git
            PasswordAuthentication no




Attached Files
There are no attachments for this article.
There are no comments for this article. Be the first to post a comment.
Security Code Security Code
Related Articles RSS Feed
[Info] Useful Gentoo packages
Viewed 1351 times since Sun, Nov 9, 2014
[Info] Gentoo linux - useful commands
Viewed 1393 times since Mon, Oct 13, 2014