]> code.ossystems Code Review - openembedded-core.git/commitdiff
Adds username support to the git fetcher, and exports SSH_AGENT_PID + SSH_AUTH_SOCK
authorRobert Bragg <robert@linux.intel.com>
Wed, 3 Dec 2008 16:01:39 +0000 (16:01 +0000)
committerRobert Bragg <robert@linux.intel.com>
Wed, 3 Dec 2008 16:21:45 +0000 (16:21 +0000)
The SSH_AGENT_PID + SSH_AUTH_SOCK environment variables are needed if you
are using ssh-agent to hold passwords for your ssh keys.

bitbake-dev/lib/bb/fetch/__init__.py
bitbake-dev/lib/bb/fetch/git.py
bitbake/lib/bb/fetch/__init__.py
bitbake/lib/bb/fetch/git.py

index 9ca55560893194ff57db30c11bf39542cb04b0f9..c9efe6beaeaaad9a2c9ded062aea836b52f1513a 100644 (file)
@@ -274,7 +274,7 @@ def runfetchcmd(cmd, d, quiet = False):
     # rather than host provided
     # Also include some other variables.
     # FIXME: Should really include all export varaiables?
-    exportvars = ['PATH', 'GIT_PROXY_HOST', 'GIT_PROXY_PORT', 'GIT_CONFIG', 'http_proxy', 'ftp_proxy']
+    exportvars = ['PATH', 'GIT_PROXY_HOST', 'GIT_PROXY_PORT', 'GIT_CONFIG', 'http_proxy', 'ftp_proxy', 'SSH_AUTH_SOCK', 'SSH_AGENT_PID']
 
     for var in exportvars:
         val = data.getVar(var, d, True)
index aa26a500c7e38c125d8a0025ce6dbfd67de3b111..26f2b47f2a5a603d6e4d85106a4c496910d6ee06 100644 (file)
@@ -66,6 +66,11 @@ class Git(Fetch):
             bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists (or was stashed). Skipping git checkout." % ud.localpath)
             return
 
+        if ud.user:
+            username = ud.user + '@'
+        else:
+            username = ""
+
         gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
 
         repofilename = 'git_%s.tar.gz' % (gitsrcname)
@@ -81,13 +86,13 @@ class Git(Fetch):
                 os.chdir(repodir)
                 runfetchcmd("tar -xzf %s" % (repofile), d)
             else:
-                runfetchcmd("git clone -n %s://%s%s %s" % (ud.proto, ud.host, ud.path, repodir), d)
+                runfetchcmd("git clone -n %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, repodir), d)
 
         os.chdir(repodir)
         # Remove all but the .git directory
         runfetchcmd("rm * -Rf", d)
-        runfetchcmd("git fetch %s://%s%s %s" % (ud.proto, ud.host, ud.path, ud.branch), d)
-        runfetchcmd("git fetch --tags %s://%s%s" % (ud.proto, ud.host, ud.path), d)
+        runfetchcmd("git fetch %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d)
+        runfetchcmd("git fetch --tags %s://%s%s%s" % (ud.proto, username, ud.host, ud.path), d)
         runfetchcmd("git prune-packed", d)
         runfetchcmd("git pack-redundant --all | xargs -r rm", d)
 
index 9ca55560893194ff57db30c11bf39542cb04b0f9..c9efe6beaeaaad9a2c9ded062aea836b52f1513a 100644 (file)
@@ -274,7 +274,7 @@ def runfetchcmd(cmd, d, quiet = False):
     # rather than host provided
     # Also include some other variables.
     # FIXME: Should really include all export varaiables?
-    exportvars = ['PATH', 'GIT_PROXY_HOST', 'GIT_PROXY_PORT', 'GIT_CONFIG', 'http_proxy', 'ftp_proxy']
+    exportvars = ['PATH', 'GIT_PROXY_HOST', 'GIT_PROXY_PORT', 'GIT_CONFIG', 'http_proxy', 'ftp_proxy', 'SSH_AUTH_SOCK', 'SSH_AGENT_PID']
 
     for var in exportvars:
         val = data.getVar(var, d, True)
index aa26a500c7e38c125d8a0025ce6dbfd67de3b111..26f2b47f2a5a603d6e4d85106a4c496910d6ee06 100644 (file)
@@ -66,6 +66,11 @@ class Git(Fetch):
             bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists (or was stashed). Skipping git checkout." % ud.localpath)
             return
 
+        if ud.user:
+            username = ud.user + '@'
+        else:
+            username = ""
+
         gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
 
         repofilename = 'git_%s.tar.gz' % (gitsrcname)
@@ -81,13 +86,13 @@ class Git(Fetch):
                 os.chdir(repodir)
                 runfetchcmd("tar -xzf %s" % (repofile), d)
             else:
-                runfetchcmd("git clone -n %s://%s%s %s" % (ud.proto, ud.host, ud.path, repodir), d)
+                runfetchcmd("git clone -n %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, repodir), d)
 
         os.chdir(repodir)
         # Remove all but the .git directory
         runfetchcmd("rm * -Rf", d)
-        runfetchcmd("git fetch %s://%s%s %s" % (ud.proto, ud.host, ud.path, ud.branch), d)
-        runfetchcmd("git fetch --tags %s://%s%s" % (ud.proto, ud.host, ud.path), d)
+        runfetchcmd("git fetch %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d)
+        runfetchcmd("git fetch --tags %s://%s%s%s" % (ud.proto, username, ud.host, ud.path), d)
         runfetchcmd("git prune-packed", d)
         runfetchcmd("git pack-redundant --all | xargs -r rm", d)