View previous topic :: View next topic |
Author |
Message |
Ralphred l33t
Joined: 31 Dec 2013 Posts: 656
|
Posted: Sat Nov 02, 2024 5:34 pm Post subject: Local git mirror for Portage (Now a How To: Guide) |
|
|
[/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 |
|
|
Banana Moderator
Joined: 21 May 2004 Posts: 1746 Location: Germany
|
|
Back to top |
|
|
Ralphred l33t
Joined: 31 Dec 2013 Posts: 656
|
Posted: Sat Nov 02, 2024 7:06 pm Post subject: |
|
|
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 |
|
|
Banana Moderator
Joined: 21 May 2004 Posts: 1746 Location: Germany
|
|
Back to top |
|
|
Ralphred l33t
Joined: 31 Dec 2013 Posts: 656
|
Posted: Sun Nov 03, 2024 12:04 pm Post subject: |
|
|
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 |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5125 Location: Bavaria
|
|
Back to top |
|
|
|