Linux backports project
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: backports@vger.kernel.org
Subject: [PATCH v2] git-tracker: read INPUT_HTTP[S]_PROXY environment variable
Date: Wed, 19 Aug 2015 11:44:50 +0200	[thread overview]
Message-ID: <1439977490.2089.5.camel@sipsolutions.net> (raw)
In-Reply-To: <1439976363.2089.2.camel@sipsolutions.net> (sfid-20150819_112609_092507_D1F11647)

From: Johannes Berg <johannes.berg@intel.com>

This allows using a different HTTP[S] proxy for input and output
trees, if necessary.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 devel/git-tracker.py | 22 ++++++++++++++++------
 lib/bpgit.py         | 14 ++++++++------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/devel/git-tracker.py b/devel/git-tracker.py
index 9ce6ce455f95..7962cf03ce88 100755
--- a/devel/git-tracker.py
+++ b/devel/git-tracker.py
@@ -37,13 +37,22 @@ FAIL = 'failed'
 SCRIPT_GIT_NAME = 'backports git tracker'
 SCRIPT_GIT_EMAIL = ''
 
+def make_proxy_env(input):
+    env = os.environ.copy()
+    if input:
+        if 'INPUT_HTTP_PROXY' in env:
+            env['http_proxy'] = env['INPUT_HTTP_PROXY']
+        if 'INPUT_HTTPS_PROXY' in env:
+            env['https_proxy'] = env['INPUT_HTTPS_PROXY']
+    return env
 
-def update_cache_objects(gittree, objdir):
+def update_cache_objects(gittree, objdir, input):
+    env = make_proxy_env(input)
     if not os.path.isdir(objdir):
-        git.clone(gittree, objdir, options=['--bare'])
+        git.clone(gittree, objdir, options=['--bare'], env=env)
     else:
         git.set_origin(gittree, objdir)
-        git.remote_update(objdir)
+        git.remote_update(objdir, env=env)
 
 def handle_commit(args, msg, branch, treename, kernelobjdir, tmpdir, wgitdir, backport_rev, kernel_rev,
                   prev_kernel_rev=None, defconfig=None, env={}, commit_failure=True,
@@ -175,11 +184,11 @@ if __name__ == '__main__':
                 defconfig = config.get(tree, 'defconfig')
             branches = [r.strip() for r in config.get(tree, 'branches').split(',')]
 
-            update_cache_objects(input, kernelobjdir)
+            update_cache_objects(input, kernelobjdir, input=True)
 
             wgitref = os.path.join(cachedir, 'backport-' + tree)
 
-            update_cache_objects(output, wgitref)
+            update_cache_objects(output, wgitref, input=False)
 
             for branch in branches:
                 with tempdir.tempdir() as branch_tmpdir:
@@ -189,7 +198,8 @@ if __name__ == '__main__':
                     git.remove_config('core.bare', tree=wgitdir)
                     git.set_origin(output, wgitdir)
 
-                    kernel_head = git.ls_remote(branch, tree=kernelobjdir)
+                    env = make_proxy_env(True)
+                    kernel_head = git.ls_remote(branch, tree=kernelobjdir, env=env)
 
                     backport_author_env = {
                         'GIT_AUTHOR_NAME': SCRIPT_GIT_NAME,
diff --git a/lib/bpgit.py b/lib/bpgit.py
index dc7d689550b1..35bb80702fbe 100644
--- a/lib/bpgit.py
+++ b/lib/bpgit.py
@@ -165,8 +165,9 @@ def get_blob(blob, outf, tree=None):
         process.wait()
         _check(process)
 
-def clone(gittree, outputdir, options=[]):
-    process = subprocess.Popen(['git', 'clone'] + options + [gittree, outputdir])
+def clone(gittree, outputdir, options=[], env=None):
+    process = subprocess.Popen(['git', 'clone'] + options + [gittree, outputdir],
+                               env=env)
     process.wait()
     _check(process)
 
@@ -180,9 +181,10 @@ def set_origin(giturl, gitdir):
     process.wait()
     _check(process)
 
-def remote_update(gitdir):
+def remote_update(gitdir, env=None):
     process = subprocess.Popen(['git', 'remote', 'update'],
-                               close_fds=True, universal_newlines=True, cwd=gitdir)
+                               close_fds=True, universal_newlines=True, cwd=gitdir,
+                               env=env)
     process.wait()
     _check(process)
 
@@ -234,9 +236,9 @@ def remove_config(cfg, tree=None):
     process.wait()
     _check(process)
 
-def ls_remote(branch, tree=None, remote='origin'):
+def ls_remote(branch, tree=None, remote='origin', env=None):
     process = subprocess.Popen(['git', 'ls-remote', remote, 'refs/heads/' + branch],
-                               stdout=subprocess.PIPE,
+                               stdout=subprocess.PIPE, env=env,
                                close_fds=True, universal_newlines=True, cwd=tree)
     stdout = process.communicate()[0]
     process.wait()


--
To unsubscribe from this list: send the line "unsubscribe backports" in

  parent reply	other threads:[~2015-08-19  9:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19  9:26 [PATCH] git-tracker: read INPUT_HTTP[S]_PROXY environment variable Johannes Berg
2015-08-19  9:40 ` Johannes Berg
2015-08-19  9:44 ` Johannes Berg [this message]
2015-09-14 21:25   ` [PATCH v2] " Hauke Mehrtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439977490.2089.5.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=backports@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox