[oe-commits] org.nslu2-linux.bitbake bitbake: release 330

jbowler commit openembedded-commits at lists.openembedded.org
Mon Oct 23 17:44:44 UTC 2006


bitbake: release 330

Author: jbowler at nslu2-linux.org
Branch: org.nslu2-linux.bitbake
Revision: 9f7b9c181426ea832a65d37361521ce31c0494a7
ViewMTN: http://monotone.openembedded.org/revision.psp?id=9f7b9c181426ea832a65d37361521ce31c0494a7
Files:
1
lib/bb/fetch.py
lib/bb/fetch
lib/bb/fetch/__init__.py
lib/bb/fetch/bk.py
lib/bb/fetch/cvs.py
lib/bb/fetch/git.py
lib/bb/fetch/local.py
lib/bb/fetch/svn.py
lib/bb/fetch/wget.py
ChangeLog
MANIFEST
bin/bitbake
doc/manual/usermanual.xml
lib/bb/parse/parse_py/ConfHandler.py
setup.py
Diffs:

#
# mt diff -re1a190844a7c21f1afc1231126cc17030470391e -r9f7b9c181426ea832a65d37361521ce31c0494a7
#
# 
# 
# delete "lib/bb/fetch.py"
# 
# add_dir "lib/bb/fetch"
# 
# add_file "lib/bb/fetch/__init__.py"
#  content [1df17977cfc35619bb7d9908afbd23af3b999e7b]
# 
# add_file "lib/bb/fetch/bk.py"
#  content [1af36f0872807670877e2d2e921e1f97e4a91cb2]
# 
# add_file "lib/bb/fetch/cvs.py"
#  content [a8cfa4227d4ec20871cdcded9b9986c024472835]
# 
# add_file "lib/bb/fetch/git.py"
#  content [181e93d38d9bec2c7c655b41d5c4350cd1d2b007]
# 
# add_file "lib/bb/fetch/local.py"
#  content [47edf92ba8f20543eb69584fe8de40f2fc31418b]
# 
# add_file "lib/bb/fetch/svn.py"
#  content [35d2d57a22c465e89cd89cec35181c2213a6988b]
# 
# add_file "lib/bb/fetch/wget.py"
#  content [d729800113b929cee09614debe670a9643e0e09c]
# 
# patch "ChangeLog"
#  from [5321e8a235f6bb178f8b2f028df60c39b97be8d5]
#    to [8077ed6b8124a15ce987ea2f5baca137a64b9dfa]
# 
# patch "MANIFEST"
#  from [ad73c4ae53a1781d255401193515cc16225292ba]
#    to [68870a9dc1741fada24cc117e1d3566fc70d3878]
# 
# patch "bin/bitbake"
#  from [ffb1a3669f82555a2af65184d1ec54a9bbfb12df]
#    to [f8ebcc69ac6b2003210621cc312debea7c8c4474]
# 
# patch "doc/manual/usermanual.xml"
#  from [46cb85aa51c7bc92fdbaa60dd6506a0aeeb94150]
#    to [cef5cd45405882b6cfb024beeab6c158d75999dc]
# 
# patch "lib/bb/parse/parse_py/ConfHandler.py"
#  from [ad2abbaf8c6e1570b17bece77bffdee1f12d6785]
#    to [2e824b475c7acef303baacc02d2ed6d7b683dbb0]
# 
# patch "setup.py"
#  from [bf4feb9f8ea8ecb2ae9bbaed1eaa1b76a364c380]
#    to [f43fc8a5a2369eac6534afb328f07352f5b9a923]
# 
============================================================
--- lib/bb/fetch/__init__.py	1df17977cfc35619bb7d9908afbd23af3b999e7b
+++ lib/bb/fetch/__init__.py	1df17977cfc35619bb7d9908afbd23af3b999e7b
@@ -0,0 +1,175 @@
+#!/usr/bin/env python
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+"""
+BitBake 'Fetch' implementations
+
+Classes for obtaining upstream sources for the
+BitBake build tools.
+
+Copyright (C) 2003, 2004  Chris Larson
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA. 
+
+Based on functions from the base bb module, Copyright 2003 Holger Schurig
+"""
+
+import os, re
+import bb
+from   bb import data
+
+class FetchError(Exception):
+    """Exception raised when a download fails"""
+
+class NoMethodError(Exception):
+    """Exception raised when there is no method to obtain a supplied url or set of urls"""
+
+class MissingParameterError(Exception):
+    """Exception raised when a fetch method is missing a critical parameter in the url"""
+
+class MD5SumError(Exception):
+    """Exception raised when a MD5SUM of a file does not match the expected one"""
+
+def uri_replace(uri, uri_find, uri_replace, d):
+#   bb.note("uri_replace: operating on %s" % uri)
+    if not uri or not uri_find or not uri_replace:
+        bb.debug(1, "uri_replace: passed an undefined value, not replacing")
+    uri_decoded = list(bb.decodeurl(uri))
+    uri_find_decoded = list(bb.decodeurl(uri_find))
+    uri_replace_decoded = list(bb.decodeurl(uri_replace))
+    result_decoded = ['','','','','',{}]
+    for i in uri_find_decoded:
+        loc = uri_find_decoded.index(i)
+        result_decoded[loc] = uri_decoded[loc]
+        import types
+        if type(i) == types.StringType:
+            import re
+            if (re.match(i, uri_decoded[loc])):
+                result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc])
+                if uri_find_decoded.index(i) == 2:
+                    if d:
+                        localfn = bb.fetch.localpath(uri, d)
+                        if localfn:
+                            result_decoded[loc] = os.path.dirname(result_decoded[loc]) + "/" + os.path.basename(bb.fetch.localpath(uri, d))
+#                       bb.note("uri_replace: matching %s against %s and replacing with %s" % (i, uri_decoded[loc], uri_replace_decoded[loc]))
+            else:
+#               bb.note("uri_replace: no match")
+                return uri
+#           else:
+#               for j in i.keys():
+#                   FIXME: apply replacements against options
+    return bb.encodeurl(result_decoded)
+
+methods = []
+
+def init(urls = [], d = None):
+    if d == None:
+        bb.debug(2,"BUG init called with None as data object!!!")
+        return
+
+    for m in methods:
+        m.urls = []
+
+    for u in urls:
+        for m in methods:
+            m.data = d
+            if m.supports(u, d):
+                m.urls.append(u)
+
+def go(d):
+    """Fetch all urls"""
+    for m in methods:
+        if m.urls:
+            m.go(d)
+
+def localpaths(d):
+    """Return a list of the local filenames, assuming successful fetch"""
+    local = []
+    for m in methods:
+        for u in m.urls:
+            local.append(m.localpath(u, d))
+    return local
+
+def localpath(url, d):
+    for m in methods:
+        if m.supports(url, d):
+            return m.localpath(url, d)
+    return url
+
+class Fetch(object):
+    """Base class for 'fetch'ing data"""
+
+    def __init__(self, urls = []):
+        self.urls = []
+        for url in urls:
+            if self.supports(bb.decodeurl(url), d) is 1:
+                self.urls.append(url)
+
+    def supports(url, d):
+        """Check to see if this fetch class supports a given url.
+           Expects supplied url in list form, as outputted by bb.decodeurl().
+        """
+        return 0
+    supports = staticmethod(supports)
+
+    def localpath(url, d):
+        """Return the local filename of a given url assuming a successful fetch.
+        """
+        return url
+    localpath = staticmethod(localpath)
+
+    def setUrls(self, urls):
+        self.__urls = urls
+
+    def getUrls(self):
+        return self.__urls
+
+    urls = property(getUrls, setUrls, None, "Urls property")
+
+    def setData(self, data):
+        self.__data = data
+
+    def getData(self):
+        return self.__data
+
+    data = property(getData, setData, None, "Data property")
+
+    def go(self, urls = []):
+        """Fetch urls"""
+        raise NoMethodError("Missing implementation for url")
+
+    def getSRCDate(d):
+        """
+        Return the SRC Date for the component
+
+        d the bb.data module
+        """
+        return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1 )
+    getSRCDate = staticmethod(getSRCDate)
+
+#if __name__ == "__main__":
+
+import bk
+import cvs
+import git
+import local
+import svn
+import wget
+
+methods.append(bk.Bk())
+methods.append(cvs.Cvs())
+methods.append(git.Git())
+methods.append(local.Local())
+methods.append(svn.Svn())
+methods.append(wget.Wget())
============================================================
--- lib/bb/fetch/bk.py	1af36f0872807670877e2d2e921e1f97e4a91cb2
+++ lib/bb/fetch/bk.py	1af36f0872807670877e2d2e921e1f97e4a91cb2
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+"""
+BitBake 'Fetch' implementations
+
+Classes for obtaining upstream sources for the
+BitBake build tools.
+
+Copyright (C) 2003, 2004  Chris Larson
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA. 
+
+Based on functions from the base bb module, Copyright 2003 Holger Schurig
+"""
+
+import os, re
+import bb
+from   bb import data
+from   bb.fetch import Fetch
+
+class Bk(Fetch):
+    def supports(url, d):
+        """Check to see if a given url can be fetched via bitkeeper.
+           Expects supplied url in list form, as outputted by bb.decodeurl().
+        """
+        (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
+        return type in ['bk']
+    supports = staticmethod(supports)
============================================================
--- lib/bb/fetch/cvs.py	a8cfa4227d4ec20871cdcded9b9986c024472835
+++ lib/bb/fetch/cvs.py	a8cfa4227d4ec20871cdcded9b9986c024472835
@@ -0,0 +1,214 @@
+#!/usr/bin/env python
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+"""
+BitBake 'Fetch' implementations
+
+Classes for obtaining upstream sources for the
+BitBake build tools.
+
+Copyright (C) 2003, 2004  Chris Larson
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA. 
+
+Based on functions from the base bb module, Copyright 2003 Holger Schurig
+"""
+
+import os, re
+import bb
+from   bb import data
+from   bb.fetch import Fetch
+from   bb.fetch import FetchError
+from   bb.fetch import MissingParameterError
+
+class Cvs(Fetch):
+    """Class to fetch a module or modules from cvs repositories"""
+    def supports(url, d):
+        """Check to see if a given url can be fetched with cvs.
+           Expects supplied url in list form, as outputted by bb.decodeurl().
+        """
+        (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
+        return type in ['cvs', 'pserver']
+    supports = staticmethod(supports)
+
+    def localpath(url, d):
+        (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
+        if "localpath" in parm:
+#           if user overrides local path, use it.
+            return parm["localpath"]
+
+        if not "module" in parm:
+            raise MissingParameterError("cvs method needs a 'module' parameter")
+        else:
+            module = parm["module"]
+        if 'tag' in parm:
+            tag = parm['tag']
+        else:
+            tag = ""
+        if 'date' in parm:
+            date = parm['date']
+        else:
+            if not tag:
+                date = Fetch.getSRCDate(d)
+            else:
+                date = ""
+
+        return os.path.join(data.getVar("DL_DIR", d, 1),data.expand('%s_%s_%s_%s.tar.gz' % ( module.replace('/', '.'), host, tag, date), d))
+    localpath = staticmethod(localpath)
+
+    def go(self, d, urls = []):
+        """Fetch urls"""
+        if not urls:
+            urls = self.urls
+
+        localdata = data.createCopy(d)
+        data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata)
+        data.update_data(localdata)
+
+        for loc in urls:
+            (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, localdata))
+            if not "module" in parm:
+                raise MissingParameterError("cvs method needs a 'module' parameter")
+            else:
+                module = parm["module"]
+
+            dlfile = self.localpath(loc, localdata)
+            dldir = data.getVar('DL_DIR', localdata, 1)
+#           if local path contains the cvs
+#           module, consider the dir above it to be the
+#           download directory
+#           pos = dlfile.find(module)
+#           if pos:
+#               dldir = dlfile[:pos]
+#           else:
+#               dldir = os.path.dirname(dlfile)
+
+#           setup cvs options
+            options = []
+            if 'tag' in parm:
+                tag = parm['tag']
+            else:
+                tag = ""
+
+            if 'date' in parm:
+                date = parm['date']
+            else:
+                if not tag:
+                    date = Fetch.getSRCDate(d)
+                else:
+                    date = ""
+
+            if "method" in parm:
+                method = parm["method"]
+            else:
+                method = "pserver"
+
+            if "localdir" in parm:
+                localdir = parm["localdir"]
+            else:
+                localdir = module
+
+            cvs_rsh = None
+            if method == "ext":
+                if "rsh" in parm:
+                    cvs_rsh = parm["rsh"]
+
+            tarfn = data.expand('%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, tag, date), localdata)
+            data.setVar('TARFILES', dlfile, localdata)
+            data.setVar('TARFN', tarfn, localdata)
+
+            dl = os.path.join(dldir, tarfn)
+            if os.access(dl, os.R_OK):
+                bb.debug(1, "%s already exists, skipping cvs checkout." % tarfn)
+                continue
+
+            pn = data.getVar('PN', d, 1)
+            cvs_tarball_stash = None
+            if pn:
+                cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH_%s' % pn, d, 1)
+            if cvs_tarball_stash == None:
+                cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH', d, 1)
+            if cvs_tarball_stash:
+                fetchcmd = data.getVar("FETCHCOMMAND_wget", d, 1)
+                uri = cvs_tarball_stash + tarfn
+                bb.note("fetch " + uri)
+                fetchcmd = fetchcmd.replace("${URI}", uri)
+                ret = os.system(fetchcmd)
+                if ret == 0:
+                    bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn)
+                    continue
+
+            if date:
+                options.append("-D %s" % date)
+            if tag:
+                options.append("-r %s" % tag)
+
+            olddir = os.path.abspath(os.getcwd())
+            os.chdir(data.expand(dldir, localdata))
+
+#           setup cvsroot
+            if method == "dir":
+                cvsroot = path
+            else:
+                cvsroot = ":" + method + ":" + user
+                if pswd:
+                    cvsroot += ":" + pswd
+                cvsroot += "@" + host + ":" + path
+
+            data.setVar('CVSROOT', cvsroot, localdata)
+            data.setVar('CVSCOOPTS', " ".join(options), localdata)
+            data.setVar('CVSMODULE', module, localdata)
+            cvscmd = data.getVar('FETCHCOMMAND', localdata, 1)
+            cvsupdatecmd = data.getVar('UPDATECOMMAND', localdata, 1)
+
+            if cvs_rsh:
+                cvscmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvscmd)
+                cvsupdatecmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvsupdatecmd)
+
+#           create module directory
+            bb.debug(2, "Fetch: checking for module directory")
+            pkg=data.expand('${PN}', d)
+            pkgdir=os.path.join(data.expand('${CVSDIR}', localdata), pkg)
+            moddir=os.path.join(pkgdir,localdir)
+            if os.access(os.path.join(moddir,'CVS'), os.R_OK):
+                bb.note("Update " + loc)
+#               update sources there
+                os.chdir(moddir)
+                myret = os.system(cvsupdatecmd)
+            else:
+                bb.note("Fetch " + loc)
+#               check out sources there
+                bb.mkdirhier(pkgdir)
+                os.chdir(pkgdir)
+                bb.debug(1, "Running %s%s
>>> DIFF TRUNCATED @ 16K






More information about the Openembedded-commits mailing list