blob: f459eebf22eeacb7f9f228ad33362dd0ecf83a2d [file] [log] [blame]
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Creating and using a git mirror &mdash; BuildStream 2.2.0+3.gc7274d41d documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=19f00094" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=f96d84dc"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Reference" href="../main_core.html" />
<link rel="prev" title="Creating and using a tar mirror" href="tar-mirror.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home">
BuildStream
</a>
<div class="version">
2.2.0+3.gc7274d41d
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../main_about.html">About</a></li>
<li class="toctree-l1"><a class="reference internal" href="../main_install.html">Installing from Source</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../main_using.html">Using</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../using_tutorial.html">Getting started</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using_developing.html">Developing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using_handling_files.html">Handling files</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using_junctions.html">Combining projects</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using_config.html">User configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using_commands.html">Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using_configuring_cache_server.html">Configuring Cache Servers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../using_configuring_remote_execution.html">Remote Execution Servers</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../using_examples.html">Examples</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="tar-mirror.html">Creating and using a tar mirror</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">Creating and using a git mirror</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#prerequisites">Prerequisites</a></li>
<li class="toctree-l4"><a class="reference internal" href="#starting-a-git-http-server">Starting a git http server</a></li>
<li class="toctree-l4"><a class="reference internal" href="#bonus-lighttpd-conf-for-git-and-tar">Bonus: lighttpd conf for git and tar</a></li>
<li class="toctree-l4"><a class="reference internal" href="#further-reading">Further reading</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../main_core.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../main_porting.html">Porting guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../CONTRIBUTING.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../main_architecture.html">Architecture</a></li>
<li class="toctree-l1"><a class="reference internal" href="../main_glossary.html">Glossary</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">BuildStream</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../main_using.html">Using</a></li>
<li class="breadcrumb-item"><a href="../using_examples.html">Examples</a></li>
<li class="breadcrumb-item active">Creating and using a git mirror</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/examples/git-mirror.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="creating-and-using-a-git-mirror">
<h1>Creating and using a git mirror<a class="headerlink" href="#creating-and-using-a-git-mirror" title="Link to this heading"></a></h1>
<p>This is an example of how to create a git mirror using git’s
<a class="reference external" href="https://git-scm.com/docs/git-http-backend">git-http-backend</a> and
<a class="reference external" href="https://redmine.lighttpd.net/projects/1/wiki/TutorialConfiguration">lighttpd</a>.</p>
<section id="prerequisites">
<h2>Prerequisites<a class="headerlink" href="#prerequisites" title="Link to this heading"></a></h2>
<p>You will need git installed, and git-http-backend must be present. It is assumed
that the git-http-backend binary exists at <cite>/usr/lib/git-core/git-http-backend</cite>.</p>
<p>You will need <cite>lighttpd</cite> installed, and at the bare minimum has the modules
<cite>mod_alias</cite>, <cite>mod_cgi</cite>, and <cite>mod_setenv</cite>.</p>
<p>I will be using gnome-modulesets as an example, which can be cloned from
<cite>http://gnome7.codethink.co.uk/gnome-modulesets.git</cite>.</p>
</section>
<section id="starting-a-git-http-server">
<h2>Starting a git http server<a class="headerlink" href="#starting-a-git-http-server" title="Link to this heading"></a></h2>
<section id="set-up-a-directory-containing-mirrors">
<h3>1. Set up a directory containing mirrors<a class="headerlink" href="#set-up-a-directory-containing-mirrors" title="Link to this heading"></a></h3>
<p>Choose a suitable directory to hold your mirrors, e.g. <cite>/var/www/git</cite>.</p>
<p>Place the git repositories you want to use as mirrors in the mirror dir, e.g.
<code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">--mirror</span> <span class="pre">http://git.gnome.org/browse/yelp-xsl</span> <span class="pre">/var/www/git/yelp-xsl.git</span></code>.</p>
</section>
<section id="configure-lighttpd">
<h3>2. Configure lighttpd<a class="headerlink" href="#configure-lighttpd" title="Link to this heading"></a></h3>
<p>Write out a lighttpd.conf as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>server.document-root = &quot;/var/www/git/&quot;
server.port = 3000
server.modules = (
&quot;mod_alias&quot;,
&quot;mod_cgi&quot;,
&quot;mod_setenv&quot;,
)
alias.url += ( &quot;/git&quot; =&gt; &quot;/usr/lib/git-core/git-http-backend&quot; )
$HTTP[&quot;url&quot;] =~ &quot;^/git&quot; {
cgi.assign = (&quot;&quot; =&gt; &quot;&quot;)
setenv.add-environment = (
&quot;GIT_PROJECT_ROOT&quot; =&gt; &quot;/var/www/git&quot;,
&quot;GIT_HTTP_EXPORT_ALL&quot; =&gt; &quot;&quot;
)
}
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you have your mirrors in another directory, replace /var/www/git/ with that directory.</p>
</div>
</section>
<section id="start-lighttpd">
<h3>3. Start lighttpd<a class="headerlink" href="#start-lighttpd" title="Link to this heading"></a></h3>
<p>lighttpd can be invoked with the command-line <code class="docutils literal notranslate"><span class="pre">lighttpd</span> <span class="pre">-D</span> <span class="pre">-f</span> <span class="pre">lighttpd.conf</span></code>.</p>
</section>
<section id="test-that-you-can-fetch-from-it">
<h3>4. Test that you can fetch from it<a class="headerlink" href="#test-that-you-can-fetch-from-it" title="Link to this heading"></a></h3>
<p>We can then clone the mirrored repo using git via http with
<code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">http://127.0.0.1:3000/git/yelp-xsl</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you have set server.port to something other than the default, you will
need to replace the ‘3000’ in the command-line.</p>
</div>
</section>
<section id="configure-the-project-to-use-the-mirror">
<h3>5. Configure the project to use the mirror<a class="headerlink" href="#configure-the-project-to-use-the-mirror" title="Link to this heading"></a></h3>
<p>To add this local http server as a mirror, add the following to the project.conf:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="nt">mirrors</span><span class="p">:</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">local-mirror</span>
<span class="w"> </span><span class="nt">aliases</span><span class="p">:</span>
<span class="w"> </span><span class="nt">git_gnome_org</span><span class="p">:</span>
<span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">http://127.0.0.1:3000/git/</span>
</pre></div>
</div>
</section>
<section id="test-that-the-mirror-works">
<h3>6. Test that the mirror works<a class="headerlink" href="#test-that-the-mirror-works" title="Link to this heading"></a></h3>
<p>We can make buildstream use the mirror by setting the alias to an invalid URL, e.g.</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="nt">aliases</span><span class="p">:</span>
<span class="w"> </span><span class="nt">git_gnome_org</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://www.example.com/invalid/url/</span>
</pre></div>
</div>
<p>Now, if you build an element that uses the source you placed in the mirror
(e.g. <code class="docutils literal notranslate"><span class="pre">bst</span> <span class="pre">build</span> <span class="pre">core-deps/yelp-xsl.bst</span></code>), you will see that it uses your mirror.</p>
</section>
</section>
<section id="bonus-lighttpd-conf-for-git-and-tar">
<span id="lighttpd-git-tar-conf"></span><h2>Bonus: lighttpd conf for git and tar<a class="headerlink" href="#bonus-lighttpd-conf-for-git-and-tar" title="Link to this heading"></a></h2>
<p>For those who have also used the <a class="reference internal" href="tar-mirror.html#using-tar-mirror"><span class="std std-ref">tar-mirror tutorial</span></a>,
a combined lighttpd.conf is below:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>server.document-root = &quot;/var/www/&quot;
server.port = 3000
server.modules = (
&quot;mod_alias&quot;,
&quot;mod_cgi&quot;,
&quot;mod_setenv&quot;,
)
alias.url += ( &quot;/git&quot; =&gt; &quot;/usr/lib/git-core/git-http-backend&quot; )
$HTTP[&quot;url&quot;] =~ &quot;^/git&quot; {
cgi.assign = (&quot;&quot; =&gt; &quot;&quot;)
setenv.add-environment = (
&quot;GIT_PROJECT_ROOT&quot; =&gt; &quot;/var/www/git&quot;,
&quot;GIT_HTTP_EXPORT_ALL&quot; =&gt; &quot;&quot;
)
} else $HTTP[&quot;url&quot;] =~ &quot;^/tar&quot; {
dir-listing.activate = &quot;enable&quot;
}
</pre></div>
</div>
</section>
<section id="further-reading">
<h2>Further reading<a class="headerlink" href="#further-reading" title="Link to this heading"></a></h2>
<p>If this mirror isn’t being used exclusively in a secure network, it is strongly
recommended you <a class="reference external" href="https://redmine.lighttpd.net/projects/1/wiki/HowToSimpleSSL">use SSL</a>.</p>
<p>This is the bare minimum required to set up a git mirror. A large, public project
would prefer to set it up using the
<a class="reference external" href="https://git-scm.com/book/en/v1/Git-on-the-Server-Git-Daemon">git protocol</a>,
and a security-conscious project would be configured to use
<a class="reference external" href="https://git-scm.com/book/en/v1/Git-on-the-Server-Getting-Git-on-a-Server#Small-Setups">git over SSH</a>.</p>
<p>Lighttpd is documented on <a class="reference external" href="https://redmine.lighttpd.net/projects/lighttpd/wiki">its wiki</a>.</p>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="tar-mirror.html" class="btn btn-neutral float-left" title="Creating and using a tar mirror" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="../main_core.html" class="btn btn-neutral float-right" title="Reference" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2017-2022, The Apache Software Foundation.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>