summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2010-11-17 14:44:40 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:41 +0000
commit87b6f7d27ace9d6465414c28bbba003f368a49dd (patch)
tree8c53d7327b7dc8eec439cae5c69de5b36ba42ed3
parentd0d67a9fe279d26423494946666a5ca0acc5d66f (diff)
downloadpoky-87b6f7d27ace9d6465414c28bbba003f368a49dd.tar.gz
fetch: add common helper _strip_leading_slashes()
Several fetcher need a way to strip leading slashes off a local path. This helper-function consolidates all such occurances. (Bitbake rev: 823a02185ed109054c6c1ae366221aaed0353f24) Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
-rw-r--r--bitbake/lib/bb/fetch/__init__.py7
-rw-r--r--bitbake/lib/bb/fetch/bzr.py5
-rw-r--r--bitbake/lib/bb/fetch/hg.py5
-rw-r--r--bitbake/lib/bb/fetch/osc.py10
-rw-r--r--bitbake/lib/bb/fetch/perforce.py3
-rw-r--r--bitbake/lib/bb/fetch/svn.py5
6 files changed, 13 insertions, 22 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py
index faf7fc489f..c9c8bdb893 100644
--- a/bitbake/lib/bb/fetch/__init__.py
+++ b/bitbake/lib/bb/fetch/__init__.py
@@ -607,6 +607,13 @@ class Fetch(object):
607 and duplicate code execution) 607 and duplicate code execution)
608 """ 608 """
609 return url 609 return url
610 def _strip_leading_slashes(self, relpath):
611 """
612 Remove leading slash as os.path.join can't cope
613 """
614 while os.path.isabs(relpath):
615 relpath = relpath[1:]
616 return relpath
610 617
611 def setUrls(self, urls): 618 def setUrls(self, urls):
612 self.__urls = urls 619 self.__urls = urls
diff --git a/bitbake/lib/bb/fetch/bzr.py b/bitbake/lib/bb/fetch/bzr.py
index 4cd51cb337..92fff741ac 100644
--- a/bitbake/lib/bb/fetch/bzr.py
+++ b/bitbake/lib/bb/fetch/bzr.py
@@ -37,10 +37,7 @@ class Bzr(Fetch):
37 def localpath (self, url, ud, d): 37 def localpath (self, url, ud, d):
38 38
39 # Create paths to bzr checkouts 39 # Create paths to bzr checkouts
40 relpath = ud.path 40 relpath = self._strip_leading_slashes(ud.path)
41 if relpath.startswith('/'):
42 # Remove leading slash as os.path.join can't cope
43 relpath = relpath[1:]
44 ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath) 41 ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath)
45 42
46 revision = Fetch.srcrev_internal_helper(ud, d) 43 revision = Fetch.srcrev_internal_helper(ud, d)
diff --git a/bitbake/lib/bb/fetch/hg.py b/bitbake/lib/bb/fetch/hg.py
index 264a52da9f..0f8d9b8324 100644
--- a/bitbake/lib/bb/fetch/hg.py
+++ b/bitbake/lib/bb/fetch/hg.py
@@ -57,10 +57,7 @@ class Hg(Fetch):
57 ud.module = ud.parm["module"] 57 ud.module = ud.parm["module"]
58 58
59 # Create paths to mercurial checkouts 59 # Create paths to mercurial checkouts
60 relpath = ud.path 60 relpath = self._strip_leading_slashes(ud.path)
61 if relpath.startswith('/'):
62 # Remove leading slash as os.path.join can't cope
63 relpath = relpath[1:]
64 ud.pkgdir = os.path.join(data.expand('${HGDIR}', d), ud.host, relpath) 61 ud.pkgdir = os.path.join(data.expand('${HGDIR}', d), ud.host, relpath)
65 ud.moddir = os.path.join(ud.pkgdir, ud.module) 62 ud.moddir = os.path.join(ud.pkgdir, ud.module)
66 63
diff --git a/bitbake/lib/bb/fetch/osc.py b/bitbake/lib/bb/fetch/osc.py
index 6fcb344ce0..a32d0b0a29 100644
--- a/bitbake/lib/bb/fetch/osc.py
+++ b/bitbake/lib/bb/fetch/osc.py
@@ -33,10 +33,7 @@ class Osc(Fetch):
33 ud.module = ud.parm["module"] 33 ud.module = ud.parm["module"]
34 34
35 # Create paths to osc checkouts 35 # Create paths to osc checkouts
36 relpath = ud.path 36 relpath = self._strip_leading_slashes(ud.path)
37 if relpath.startswith('/'):
38 # Remove leading slash as os.path.join can't cope
39 relpath = relpath[1:]
40 ud.pkgdir = os.path.join(data.expand('${OSCDIR}', d), ud.host) 37 ud.pkgdir = os.path.join(data.expand('${OSCDIR}', d), ud.host)
41 ud.moddir = os.path.join(ud.pkgdir, relpath, ud.module) 38 ud.moddir = os.path.join(ud.pkgdir, relpath, ud.module)
42 39
@@ -73,10 +70,7 @@ class Osc(Fetch):
73 if ud.revision: 70 if ud.revision:
74 options.append("-r %s" % ud.revision) 71 options.append("-r %s" % ud.revision)
75 72
76 coroot = ud.path 73 coroot = self._strip_leading_slashes(ud.path)
77 if coroot.startswith('/'):
78 # Remove leading slash as os.path.join can't cope
79 coroot= coroot[1:]
80 74
81 if command is "fetch": 75 if command is "fetch":
82 osccmd = "%s %s co %s/%s %s" % (basecmd, config, coroot, ud.module, " ".join(options)) 76 osccmd = "%s %s co %s/%s %s" % (basecmd, config, coroot, ud.module, " ".join(options))
diff --git a/bitbake/lib/bb/fetch/perforce.py b/bitbake/lib/bb/fetch/perforce.py
index 6f68d85614..bdd23deef5 100644
--- a/bitbake/lib/bb/fetch/perforce.py
+++ b/bitbake/lib/bb/fetch/perforce.py
@@ -113,8 +113,7 @@ class Perforce(Fetch):
113 if which != -1: 113 if which != -1:
114 base = path[:which] 114 base = path[:which]
115 115
116 if base[0] == "/": 116 base = self._strip_leading_slashes(base)
117 base = base[1:]
118 117
119 cset = Perforce.getcset(d, path, host, user, pswd, parm) 118 cset = Perforce.getcset(d, path, host, user, pswd, parm)
120 119
diff --git a/bitbake/lib/bb/fetch/svn.py b/bitbake/lib/bb/fetch/svn.py
index 538b4c2a2d..c46ace423d 100644
--- a/bitbake/lib/bb/fetch/svn.py
+++ b/bitbake/lib/bb/fetch/svn.py
@@ -49,10 +49,7 @@ class Svn(Fetch):
49 ud.module = ud.parm["module"] 49 ud.module = ud.parm["module"]
50 50
51 # Create paths to svn checkouts 51 # Create paths to svn checkouts
52 relpath = ud.path 52 relpath = self._strip_leading_slashes(ud.path)
53 if relpath.startswith('/'):
54 # Remove leading slash as os.path.join can't cope
55 relpath = relpath[1:]
56 ud.pkgdir = os.path.join(data.expand('${SVNDIR}', d), ud.host, relpath) 53 ud.pkgdir = os.path.join(data.expand('${SVNDIR}', d), ud.host, relpath)
57 ud.moddir = os.path.join(ud.pkgdir, ud.module) 54 ud.moddir = os.path.join(ud.pkgdir, ud.module)
58 55