Browse Source

bitbake/fetch2: Move ud.localfile setup into urldata_init

(From Poky rev: 972eb5fababb33b5537fcfbbaf8e33ea820f0fee)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Richard Purdie 13 years ago
parent
commit
fdab13939b

+ 2 - 2
lib/bb/fetch2/bzr.py

@@ -42,12 +42,12 @@ class Bzr(Fetch):
         relpath = self._strip_leading_slashes(ud.path)
         ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath)
 
-    def localpath (self, url, ud, d):
         if not ud.revision:
-            ud.revision = self.latest_revision(url, ud, d)
+            ud.revision = self.latest_revision(ud.url, ud, d)
 
         ud.localfile = data.expand('bzr_%s_%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.revision), d)
 
+    def localpath (self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def _buildbzrcommand(self, ud, d, command):

+ 2 - 1
lib/bb/fetch2/cvs.py

@@ -42,7 +42,7 @@ class Cvs(Fetch):
         """
         return ud.type in ['cvs']
 
-    def localpath(self, url, ud, d):
+    def urldata_init(self, ud, d):
         if not "module" in ud.parm:
             raise MissingParameterError("cvs method needs a 'module' parameter")
         ud.module = ud.parm["module"]
@@ -65,6 +65,7 @@ class Cvs(Fetch):
 
         ud.localfile = data.expand('%s_%s_%s_%s%s%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.tag, ud.date, norecurse, fullpath), d)
 
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def forcefetch(self, url, ud, d):

+ 1 - 1
lib/bb/fetch2/git.py

@@ -71,13 +71,13 @@ class Git(Fetch):
 
         ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
 
-    def localpath(self, url, ud, d):
         for name in ud.names:
             if not ud.revisions[name] or ud.revisions[name] == "master":
                 ud.revisions[name] = self.latest_revision(url, ud, d, name)
 
         ud.localfile = ud.mirrortarball
 
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def forcefetch(self, url, ud, d):

+ 6 - 6
lib/bb/fetch2/hg.py

@@ -57,18 +57,18 @@ class Hg(Fetch):
         ud.pkgdir = os.path.join(data.expand('${HGDIR}', d), ud.host, relpath)
         ud.moddir = os.path.join(ud.pkgdir, ud.module)
 
-    def forcefetch(self, url, ud, d):
-        revTag = ud.parm.get('rev', 'tip')
-        return revTag == "tip"
-
-    def localpath(self, url, ud, d):
         if 'rev' in ud.parm:
             ud.revision = ud.parm['rev']
         elif not ud.revision:
-            ud.revision = self.latest_revision(url, ud, d)
+            ud.revision = self.latest_revision(ud.url, ud, d)
 
         ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision), d)
 
+    def forcefetch(self, url, ud, d):
+        revTag = ud.parm.get('rev', 'tip')
+        return revTag == "tip"
+
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def _buildhgcommand(self, ud, d, command):

+ 4 - 1
lib/bb/fetch2/local.py

@@ -38,6 +38,10 @@ class Local(Fetch):
         """
         return urldata.type in ['file']
 
+    def urldata_init(self, ud, d):
+        # We don't set localfile as for this fetcher the file is already local!
+        return
+
     def localpath(self, url, urldata, d):
         """
         Return the local filename of a given url assuming a successful fetch.
@@ -53,7 +57,6 @@ class Local(Fetch):
                 filesdir = data.getVar('FILESDIR', d, 1)
                 if filesdir:
                     newpath = os.path.join(filesdir, path)
-        # We don't set localfile as for this fetcher the file is already local!
         return newpath
 
     def download(self, url, urldata, d):

+ 2 - 1
lib/bb/fetch2/osc.py

@@ -26,7 +26,7 @@ class Osc(Fetch):
         """
         return ud.type in ['osc']
 
-    def localpath(self, url, ud, d):
+    def urldata_init(self, ud, d):
         if not "module" in ud.parm:
             raise MissingParameterError("osc method needs a 'module' parameter.")
 
@@ -49,6 +49,7 @@ class Osc(Fetch):
 
         ud.localfile = data.expand('%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.path.replace('/', '.'), ud.revision), d)
 
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def _buildosccommand(self, ud, d, command):

+ 3 - 3
lib/bb/fetch2/perforce.py

@@ -98,9 +98,8 @@ class Perforce(Fetch):
         return cset.split(' ')[1]
     getcset = staticmethod(getcset)
 
-    def localpath(self, url, ud, d):
-
-        (host, path, user, pswd, parm) = Perforce.doparse(url, d)
+    def urldata_init(self, ud, d):
+        (host, path, user, pswd, parm) = Perforce.doparse(ud.url, d)
 
         # If a label is specified, we use that as our filename
 
@@ -119,6 +118,7 @@ class Perforce(Fetch):
 
         ud.localfile = data.expand('%s+%s+%s.tar.gz' % (host, base.replace('/', '.'), cset), d)
 
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile)
 
     def download(self, loc, ud, d):

+ 2 - 1
lib/bb/fetch2/repo.py

@@ -37,7 +37,7 @@ class Repo(Fetch):
         """
         return ud.type in ["repo"]
 
-    def localpath(self, url, ud, d):
+    def urldata_init(self, ud, d):
         """
         We don"t care about the git rev of the manifests repository, but
         we do care about the manifest to use.  The default is "default".
@@ -53,6 +53,7 @@ class Repo(Fetch):
 
         ud.localfile = data.expand("repo_%s%s_%s_%s.tar.gz" % (ud.host, ud.path.replace("/", "."), ud.manifest, ud.branch), d)
 
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def download(self, loc, ud, d):

+ 1 - 1
lib/bb/fetch2/ssh.py

@@ -68,7 +68,7 @@ class SSH(Fetch):
         return __pattern__.match(url) != None
 
     def localpath(self, url, urldata, d):
-        m = __pattern__.match(url)
+        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))

+ 3 - 1
lib/bb/fetch2/svk.py

@@ -42,7 +42,8 @@ class Svk(Fetch):
         """
         return ud.type in ['svk']
 
-    def localpath(self, url, ud, d):
+    def urldata_init(self, ud, d):
+
         if not "module" in ud.parm:
             raise MissingParameterError("svk method needs a 'module' parameter")
         else:
@@ -52,6 +53,7 @@ class Svk(Fetch):
 
         ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
 
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def forcefetch(self, url, ud, d):

+ 1 - 1
lib/bb/fetch2/svn.py

@@ -56,7 +56,6 @@ class Svn(Fetch):
         ud.pkgdir = os.path.join(data.expand('${SVNDIR}', d), ud.host, relpath)
         ud.moddir = os.path.join(ud.pkgdir, ud.module)
 
-    def localpath(self, url, ud, d):
         if 'rev' in ud.parm:
             ud.date = ""
             ud.revision = ud.parm['rev']
@@ -79,6 +78,7 @@ class Svn(Fetch):
 
         ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
 
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def _buildsvncommand(self, ud, d, command):

+ 2 - 2
lib/bb/fetch2/wget.py

@@ -40,12 +40,12 @@ class Wget(Fetch):
         """
         return ud.type in ['http', 'https', 'ftp']
 
-    def localpath(self, url, ud, d):
+    def urldata_init(self, ud, d):
 
-        url = encodeurl([ud.type, ud.host, ud.path, ud.user, ud.pswd, {}])
         ud.basename = os.path.basename(ud.path)
         ud.localfile = data.expand(urllib.unquote(ud.basename), d)
 
+    def localpath(self, url, ud, d):
         return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
 
     def download(self, uri, ud, d, checkonly = False):