Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Local git mirror for Portage (Now a How To: Guide)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 661

PostPosted: Sat Nov 02, 2024 5:34 pm    Post subject: Local git mirror for Portage (Now a How To: Guide) Reply with quote

[/b]I have one, no idea how to replicate it, and have loads of other stuff running on that server (including other git repos) so it just kind of "slipped in" with the other apache configs and works.

I have a friend who is currently upping their gentoo game and should be running a local rsync/git mirror of their own: Anyone seen any how to guides for a local git mirror?
I know the rsync guides are good from when I last used them years ago, but can't find anything for git.

If push comes to shove and there isn't one, I can't decide whether to just "make one in a container" or find the simplest webserver and write the guide, thoughts?


Last edited by Ralphred on Sun Nov 03, 2024 12:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 1770
Location: Germany

PostPosted: Sat Nov 02, 2024 5:50 pm    Post subject: Reply with quote

I do think you need to clarify it more what the need and the problems are.

If you are looking into a git mirror, read here:
https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository
https://stackoverflow.com/questions/3959924/whats-the-difference-between-git-clone-mirror-and-git-clone-bare
_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 661

PostPosted: Sat Nov 02, 2024 7:06 pm    Post subject: Reply with quote

Banana wrote:
If you are looking into a git mirror, read here:
A local mirror mate, not just a mirror of another repo still hosted at github et al.
The git* version of this guide is what I'm looking for, to send someone else to go and follow.

*because it's considerably quicker than rsync
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 1770
Location: Germany

PostPosted: Sun Nov 03, 2024 12:38 am    Post subject: Reply with quote

Well than this could help you.

https://wiki.gentoo.org/wiki/Project:Portage/Sync#Migration
https://www.jamescherti.com/gentoo-speed-up-emerge-sync-with-git
_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 661

PostPosted: Sun Nov 03, 2024 12:04 pm    Post subject: Reply with quote

Banana wrote:
Well than this could help you.
No.
But testing proved an httpd is not necessary for portage to work, so this cuts down on a LOT of config.

This post now contains information on how to run a private, local Gentoo git mirror (an alternative to a local Gentoo rsync mirror)
Pre-requisites
  • The repo you want to act as a mirror for has to be synced via git already on the server machine (see https://wiki.gentoo.org/wiki/Portage_with_Git if you need to)
  • dev-vcs/git needs to be installed without the safe-directories use flag (see addendum below if you need it on for some reason)

Server Config
Update the git-daemon config to suit our needs
/etc/conf.d/git-daemon:
GITDAEMON_OPTS="--syslog --export-all --listen=10.0.0.2 --base-path=/var/db/repos"
If you are having issues and need to troubleshoot add --reuseaddr (to aid with quick daemon restarts) and --verbose for extra context in /var/log/syslog.

Running
To start serving the contents of /var/db/repos run rc-service git-daemon start
To start it automatically at boot run rc-update add git-daemon default

Testing
To test the server without having to run emaint/eix/emerge every time use:
Code:
git ls-remote git://10.0.0.2/gentoo


Configuring Clients
Rather like the wiki entry above, it's as simple as updating the sync_uri(s) in your /etc/portage/repos.conf/<reop name>.conf, e.g.
Code:
[gentoo]
location = /var/db/repos/gentoo
sync-type = git
#sync-uri = https://github.com/gentoo-mirror/gentoo.git
sync-uri = git://10.0.0.2/gentoo
#other Gentoo repo stuff here, probably.

[guru]
location = /var/db/repos/guru
sync-type = git
#sync-uri = https://github.com/gentoo-mirror/guru.git
sync-uri = git://10.0.0.2/guru

[nest]
location = /var/db/repos/nest
sync-type = git
#sync-uri = https://github.com/gentoo-mirror/nest.git
sync-uri = git://10.0.0.2/nest

Caveats and Addendum
Obviously your local mirror will only be as up to date as the last time you synced it, personally I run eix-sync >/dev/null 2>&1 as a daily cron job.

If you need dev-vcs/git to be installed with the safe-directories use flag, you can either run it as root (not good IMHO) or pick <another_user> to run it as, but that user will need access to their $HOME/.gitconfig so the nobody user doesn't work. The openrc script is a bit lacking in this department so some alteration to that is needed:
Code:
cp /etc/init.d/git-daemon /etc/init.d/git-daemon.local
cp /etc/conf.d/git-daemon /etc/conf.d/git-daemon.local
echo "#Added alteration to catch portage updates to this file, re:git-daemon.local" >> /etc/init.d/git-daemon

Update the new .local service
/etc/init.d/git-daemon.local snippet and context:
command_user="${GIT_USER:-nobody}:${GIT_GROUP:-nobody}"
start_stop_daemon_args="-e HOME=$(awk -v user=\"${GIT_USER}\" -F: '$1==user{print $6}' /etc/passwd) -e XDG_CONFIG_HOME="
command_background="yes"
and obviously update /etc/conf.d/git-daemon.local to reflect your <another_user>.
To add the safe directories to the <another_user>'s config either add them directly to said users ~/.gitconfig e.g.
Code:
[safe]
        directory = .
        directory = /var/db/repos/gentoo/.git
or use su -s /bin/bash <another_user> -c "git config --global --add safe.directory \"<whatever path git-daemon is complaining about in syslog>\""
After that just rc-update/rc-service as needed to get git-daemon.local running (--port=<port> is a valid for GITDAEMON_OPTS if you need to alter it).
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5167
Location: Bavaria

PostPosted: Sun Nov 03, 2024 2:50 pm    Post subject: Reply with quote

Moved from Networking & Security to Documentation, Tips & Tricks.
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum