Difference between revisions of "Portage Git Mirror"

 
(10 intermediate revisions by 2 users not shown)
Line 37: Line 37:
  
 
Prepare directories and clone portage-mini from github::
 
Prepare directories and clone portage-mini from github::
<pre>
+
<console>
    root@git.lan # mkdir /home/git-mirrors
+
###i## mkdir /home/git-mirrors
    root@git.lan # chown nobody /home/git-mirrors
+
###i## chown nobody /home/git-mirrors
    root@git.lan # su -s /bin/sh nobody
+
###i## su -s /bin/sh nobody
    nobody $ cd /home/git-mirrors
+
$##bl## cd /home/git-mirrors
    nobody $ git clone --mirror --bare git://github.com/funtoo/portage-mini-2011.git portage.git
+
$##bl## git clone --mirror --bare git://github.com/funtoo/ports-2012.git portage.git
</pre>
+
</console>
  
Configure git-daemon in ''/etc/conf.d/git-daemon''::
+
Configure git-daemon in <code>/etc/conf.d/git-daemon</code>:
<pre>
+
    GITDAEMON_OPTS=&quot;--syslog --verbose --enable=receive-pack --export-all&quot;
+
    GITDAEMON_OPTS=&quot;${GITDAEMON_OPTS} --base-path=/home/git-mirrors /home/git-mirrors&quot;
+
    GIT_USER=&quot;nobody&quot;
+
    GIT_GROUP=&quot;nobody&quot;
+
</pre>
+
  
Start Daemon::
 
 
<pre>
 
<pre>
    root@git.lan # /etc/init.d/git-daemon start
+
GITDAEMON_OPTS=&quot;--syslog --verbose --enable=receive-pack --export-all&quot;
    root@git.lan # rc-update add git-daemon default
+
GITDAEMON_OPTS=&quot;${GITDAEMON_OPTS} --base-path=/home/git-mirrors /home/git-mirrors&quot;
 +
GIT_USER=&quot;nobody&quot;
 +
GIT_GROUP=&quot;nobody&quot;
 
</pre>
 
</pre>
 +
 +
Start the daemon:
 +
<console>
 +
###i## /etc/init.d/git-daemon start
 +
###i## rc-update add git-daemon default
 +
</console>
  
 
=== Pull from remote ===
 
=== Pull from remote ===
  
Add to /etc/cron.daily/funtoo-sync.sh::
+
Add the following to <code>/etc/cron.daily/funtoo-sync.sh</code>:
  
<pre>   #!/bin/sh
+
<pre>
 
+
#!/bin/sh
    cd /home/git-mirrors/portage.git
+
cd /home/git-mirrors/portage.git
    su nobody -s &quot;/bin/sh&quot; -c &quot;git fetch --all&quot;</pre>
+
su nobody -s "/bin/sh" -c "git fetch --all"
 +
</pre>
  
 
== Cloning from local git-daemon ==
 
== Cloning from local git-daemon ==
  
Local clone from git.lan::
+
Local clone from <code>git.lan</code>:
 +
<console>
 +
###i## mv /usr/portage /usr/portage.old
 +
###i## git clone git://git.lan/portage.git /usr/portage
 +
###i## cd /usr/portage
 +
###i## git checkout funtoo.org
 +
</console>
  
<pre>    root@localhost # mv /usr/portage /usr/portage.old
 
    root@localhost # git clone git://git.lan/portage.git /usr/portage
 
    root@localhost # cd /usr/portage
 
    root@localhost # git checkout funtoo.org</pre>
 
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]

Revision as of 00:07, February 19, 2014

Setting up local git mirror

This tutorial explains how to save bandwidth when several local computers need to pull updates from a single remote git repository.

Use case

This tutorial will be about hosting a local mirror of funtoo git based portage tree.

Following terms should be adapted

Terms Definition
git.lan The git-daemon local mirror host
localhost Any local host
nobody Owner user of .git files
/home/git-mirrors Base path of git-daemon

Local mirror

Git-daemon configuration

Prepare directories and clone portage-mini from github::

# mkdir /home/git-mirrors
# chown nobody /home/git-mirrors
# su -s /bin/sh nobody
$ cd /home/git-mirrors
$ git clone --mirror --bare git://github.com/funtoo/ports-2012.git portage.git

Configure git-daemon in /etc/conf.d/git-daemon:

GITDAEMON_OPTS="--syslog --verbose --enable=receive-pack --export-all"
GITDAEMON_OPTS="${GITDAEMON_OPTS} --base-path=/home/git-mirrors /home/git-mirrors"
GIT_USER="nobody"
GIT_GROUP="nobody"

Start the daemon:

# /etc/init.d/git-daemon start
# rc-update add git-daemon default

Pull from remote

Add the following to /etc/cron.daily/funtoo-sync.sh:

#!/bin/sh
cd /home/git-mirrors/portage.git
su nobody -s "/bin/sh" -c "git fetch --all"

Cloning from local git-daemon

Local clone from git.lan:

# mv /usr/portage /usr/portage.old
# git clone git://git.lan/portage.git /usr/portage
# cd /usr/portage
# git checkout funtoo.org