diff mbox

[OSSTEST] ts-xen-build-prep: Use .gitconfig so _everything_ uses git cache

Message ID 1470239242-5302-1-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Aug. 3, 2016, 3:47 p.m. UTC
In particular, when xen.git clones a subtrees, whose url we didn't
specify in the runvars, we end up using the url from xen.git's
Config.mk.

Arrange to use the git cache for all git urls, via the insteadOf
feature.

Note that the git config url insteadOf feature is backwards: one
configures the config variable "url.NEW-URL.insteadOf.OLD-URL".  So
the key is the value, and the value is the key.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ts-xen-build-prep | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Ian Jackson Aug. 3, 2016, 4:04 p.m. UTC | #1
Andrew Cooper writes ("Re: [OSSTEST PATCH] ts-xen-build-prep: Use .gitconfig so _everything_ uses git cache"):
> On 03/08/16 16:47, Ian Jackson wrote:
>     Note that the git config url insteadOf feature is backwards: one
>     configures the config variable "url.NEW-URL.insteadOf.OLD-URL".  So
>     the key is the value, and the value is the key.
...
> FWIW, LGTM.

Thanks.  It passed my adhoc test.  I have pushed it to osstest
pretest.

I expected that without more, this job would still fail because the
new firewall would prevent the upload talking to the Coverity server.

I have added a firewall rule to the colo which permits the controller
(`osstest' VM) to talk to port 443 on what is currently the apparent
IP address of scan.coverity.com.

If this IP address changes in future, this will break.  But this
approach will do if that doesn't happen too often.

Let's see if the whole thing works again now.

Thanks,
Ian.
diff mbox

Patch

diff --git a/ts-xen-build-prep b/ts-xen-build-prep
index 0450811..4dd10c4 100755
--- a/ts-xen-build-prep
+++ b/ts-xen-build-prep
@@ -243,6 +243,25 @@  sub ccache_setup () {
     }
 }
 
+sub gitcache_setup () {
+    my $proxy = $c{GitCacheProxy};
+    return unless $proxy;
+
+    logm("setting up git cacheing proxy $proxy");
+
+    my $gitcfg = '';
+    foreach my $urlprefix (qw(git:// http:// https://)) {
+	$gitcfg .= <<END
+[url "${proxy}$urlprefix"]
+        insteadOf = $urlprefix
+[url "${proxy}$urlprefix"]
+        insteadOf = ${proxy}$urlprefix
+END
+    }
+    target_putfilecontents_stash($ho,30,$gitcfg,"/home/osstest/.gitconfig",
+				 'home-osstest-gitconfig');
+}
+
 if (!$ho->{Flags}{'no-reinstall'}) {
     determine_vg_lv();
     lvcreate();
@@ -251,6 +270,7 @@  if (!$ho->{Flags}{'no-reinstall'}) {
     lvextend_stage2();
     replace_home();
     ccache_setup();
+    gitcache_setup();
 }
 $mjobdb->jobdb_resource_shared_mark_ready
    ($ho->{Ident}, $ho->{Name}, "build-".$ho->{Suite}."-".$r{arch});