Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH][for-1.16 1/3] ssh: fix fetcher
@ 2013-01-31 18:12 Martin Jansa
  2013-01-31 18:12 ` [PATCH][for-1.16 2/3] ssh.py: throw ParameterError when someone tries ssh://foo; protocol=git Martin Jansa
  2013-01-31 18:12 ` [PATCH][for-1.16 3/3] ssh.py: add example SRC_URI Martin Jansa
  0 siblings, 2 replies; 3+ messages in thread
From: Martin Jansa @ 2013-01-31 18:12 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Martin Jansa

From: Martin Jansa <martin.jansa@gmail.com>

* set localpath in urldata_init
  otherwise localpath and basename were None, when fetcher was trying to
  define .lock and .done paths
  basepath = d.expand("${DL_DIR}/%s" % os.path.basename(self.localpath or self.basename))
* remove "host" from localpath
  .done and .lock files are always using just basename, so if someone
  has 2 recipes with:
  SRC_URI = "ssh://foo/file.txt"
  SRC_URI = "ssh://bar/file.txt"
  then there will be only one file.txt.done in downloads anyway (and
  only first file.txt from first server will be returned on do_fetch

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/fetch2/ssh.py | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/bb/fetch2/ssh.py b/lib/bb/fetch2/ssh.py
index 8d6434a..61db435 100644
--- a/lib/bb/fetch2/ssh.py
+++ b/lib/bb/fetch2/ssh.py
@@ -72,15 +72,14 @@ class SSH(FetchMethod):
     def supports_checksum(self, urldata):
         return False
 
-    def localpath(self, url, urldata, d):
+    def urldata_init(self, urldata, d):
         m = __pattern__.match(urldata.url)
         path = m.group('path')
         host = m.group('host')
-        lpath = os.path.join(data.getVar('DL_DIR', d, True), host, os.path.basename(path))
-        return lpath
+        urldata.localpath = os.path.join(d.getVar('DL_DIR', True), os.path.basename(path))
 
     def download(self, url, urldata, d):
-        dldir = data.getVar('DL_DIR', d, True)
+        dldir = d.getVar('DL_DIR', True)
 
         m = __pattern__.match(url)
         path = m.group('path')
@@ -89,16 +88,10 @@ class SSH(FetchMethod):
         user = m.group('user')
         password = m.group('pass')
 
-        ldir = os.path.join(dldir, host)
-        lpath = os.path.join(ldir, os.path.basename(path))
-
-        if not os.path.exists(ldir):
-            os.makedirs(ldir)
-
         if port:
-            port = '-P %s' % port
+            portarg = '-P %s' % port
         else:
-            port = ''
+            portarg = ''
 
         if user:
             fr = user
@@ -112,9 +105,9 @@ class SSH(FetchMethod):
 
         import commands
         cmd = 'scp -B -r %s %s %s/' % (
-            port,
+            portarg,
             commands.mkarg(fr),
-            commands.mkarg(ldir)
+            commands.mkarg(dldir)
         )
 
         bb.fetch2.check_network_access(d, cmd, urldata.url)
-- 
1.8.1.2




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH][for-1.16 2/3] ssh.py: throw ParameterError when someone tries ssh://foo; protocol=git
  2013-01-31 18:12 [PATCH][for-1.16 1/3] ssh: fix fetcher Martin Jansa
@ 2013-01-31 18:12 ` Martin Jansa
  2013-01-31 18:12 ` [PATCH][for-1.16 3/3] ssh.py: add example SRC_URI Martin Jansa
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Jansa @ 2013-01-31 18:12 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Martin Jansa

From: Martin Jansa <martin.jansa@gmail.com>

* taken from SFTP fetcher:
  http://patchwork.openembedded.org/patch/43027/

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/fetch2/ssh.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/bb/fetch2/ssh.py b/lib/bb/fetch2/ssh.py
index 61db435..721fb35 100644
--- a/lib/bb/fetch2/ssh.py
+++ b/lib/bb/fetch2/ssh.py
@@ -73,6 +73,11 @@ class SSH(FetchMethod):
         return False
 
     def urldata_init(self, urldata, d):
+        if 'protocol' in urldata.parm and urldata.parm['protocol'] == 'git':
+            raise bb.fetch2.ParameterError(
+                "Invalid protocol - if you wish to fetch from a git " +
+                "repository using ssh, you need to use " +
+                "git:// prefix with protocol=ssh", urldata.url)
         m = __pattern__.match(urldata.url)
         path = m.group('path')
         host = m.group('host')
-- 
1.8.1.2




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH][for-1.16 3/3] ssh.py: add example SRC_URI
  2013-01-31 18:12 [PATCH][for-1.16 1/3] ssh: fix fetcher Martin Jansa
  2013-01-31 18:12 ` [PATCH][for-1.16 2/3] ssh.py: throw ParameterError when someone tries ssh://foo; protocol=git Martin Jansa
@ 2013-01-31 18:12 ` Martin Jansa
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Jansa @ 2013-01-31 18:12 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Martin Jansa

From: Martin Jansa <martin.jansa@gmail.com>

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/fetch2/ssh.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/bb/fetch2/ssh.py b/lib/bb/fetch2/ssh.py
index 721fb35..8b5acbf 100644
--- a/lib/bb/fetch2/ssh.py
+++ b/lib/bb/fetch2/ssh.py
@@ -10,6 +10,12 @@ IETF secsh internet draft:
     Currently does not support the sftp parameters, as this uses scp
     Also does not support the 'fingerprint' connection parameter.
 
+    Please note that '/' is used as host, path separator not ':' as you may 
+    be used to, also '~' can be used to specify user HOME, but again after '/'
+    
+    Example SRC_URI:
+    SRC_URI = "ssh://user@host.example.com/dir/path/file.txt"
+    SRC_URI = "ssh://user@host.example.com/~/file.txt"
 '''
 
 # Copyright (C) 2006  OpenedHand Ltd.
-- 
1.8.1.2




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-31 18:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-31 18:12 [PATCH][for-1.16 1/3] ssh: fix fetcher Martin Jansa
2013-01-31 18:12 ` [PATCH][for-1.16 2/3] ssh.py: throw ParameterError when someone tries ssh://foo; protocol=git Martin Jansa
2013-01-31 18:12 ` [PATCH][for-1.16 3/3] ssh.py: add example SRC_URI Martin Jansa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox