Convert fetchers to use bb.msg
authorRichard Purdie <rpurdie@linux.intel.com>
Sat, 9 Sep 2006 16:58:58 +0000 (16:58 +0000)
committerRichard Purdie <rpurdie@linux.intel.com>
Sat, 9 Sep 2006 16:58:58 +0000 (16:58 +0000)
lib/bb/fetch/__init__.py
lib/bb/fetch/cvs.py
lib/bb/fetch/git.py
lib/bb/fetch/svk.py
lib/bb/fetch/svn.py
lib/bb/fetch/wget.py
lib/bb/msg.py

index c69de2b..cc246fa 100644 (file)
@@ -45,9 +45,9 @@ 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)
+#   bb.msg.note(1, bb.msg.domain.Fetcher, "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")
+        bb.msg.debug(1, bb.msg.domain.Fetcher, "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))
@@ -65,9 +65,9 @@ def uri_replace(uri, uri_find, uri_replace, 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]))
+#                       bb.msg.note(1, bb.msg.domain.Fetcher, "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")
+#               bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: no match")
                 return uri
 #           else:
 #               for j in i.keys():
@@ -78,7 +78,7 @@ methods = []
 
 def init(urls = [], d = None):
     if d == None:
-        bb.debug(2,"BUG init called with None as data object!!!")
+        bb.msg.debug(2, bb.msg.domain.Fetcher, "BUG init called with None as data object!!!")
         return
 
     for m in methods:
@@ -173,7 +173,7 @@ class Fetch(object):
         """
         tarpath = os.path.join(data.getVar("DL_DIR", d, 1), tarfn)
         if os.access(tarpath, os.R_OK):
-            bb.debug(1, "%s already exists, skipping checkout." % tarfn)
+            bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists, skipping checkout." % tarfn)
             return True
 
         pn = data.getVar('PN', d, True)
@@ -184,11 +184,11 @@ class Fetch(object):
         for stash in src_tarball_stash:
             fetchcmd = data.getVar("FETCHCOMMAND_mirror", d, True) or data.getVar("FETCHCOMMAND_wget", d, True)
             uri = stash + tarfn
-            bb.note("fetch " + uri)
+            bb.msg.note(1, bb.msg.domain.Fetcher, "fetch " + uri)
             fetchcmd = fetchcmd.replace("${URI}", uri)
             ret = os.system(fetchcmd)
             if ret == 0:
-                bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn)
+                bb.msg.note(1, bb.msg.domain.Fetcher, "Fetched %s from tarball stash, skipping checkout" % tarfn)
                 return True
         return False
     try_mirror = staticmethod(try_mirror)
@@ -205,7 +205,7 @@ class Fetch(object):
         if "now" != date:
             dl = os.path.join(dldir, tarfn)
             if os.access(dl, os.R_OK):
-                bb.debug(1, "%s already exists, skipping checkout." % tarfn)
+                bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists, skipping checkout." % tarfn)
                 return True
 
             # try to use the tarball stash
index 17952ed..45d40c1 100644 (file)
@@ -130,7 +130,7 @@ class Cvs(Fetch):
 
             # try to use the tarball stash
             if Fetch.check_for_tarball(d, tarfn, dldir, date):
-                bb.debug(1, "%s already exists or was mirrored, skipping cvs checkout." % tarfn)
+                bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping cvs checkout." % tarfn)
                 continue
 
             if date:
@@ -161,21 +161,21 @@ class Cvs(Fetch):
                 cvsupdatecmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvsupdatecmd)
 
 #           create module directory
-            bb.debug(2, "Fetch: checking for module directory")
+            bb.msg.debug(2, bb.msg.domain.Fetcher, "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)
+                bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc)
 #               update sources there
                 os.chdir(moddir)
                 myret = os.system(cvsupdatecmd)
             else:
-                bb.note("Fetch " + loc)
+                bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
 #               check out sources there
                 bb.mkdirhier(pkgdir)
                 os.chdir(pkgdir)
-                bb.debug(1, "Running %s" % cvscmd)
+                bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % cvscmd)
                 myret = os.system(cvscmd)
 
             if myret != 0 or not os.access(moddir, os.R_OK):
index 0646885..fe88ee0 100644 (file)
@@ -37,7 +37,7 @@ def prunedir(topdir):
 
 def rungitcmd(cmd,d):
 
-    bb.debug(1, "Running %s" % cmd)
+    bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % cmd)
 
     # Need to export PATH as git is likely to be in metadata paths 
     # rather than host provided
@@ -120,7 +120,7 @@ class Git(Fetch):
 
             # tag=="master" must always update
             if (tag != "master") and Fetch.try_mirror(d, localfile(loc, d)):
-                bb.debug(1, "%s already exists (or was stashed). Skipping git checkout." % cofile)
+                bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists (or was stashed). Skipping git checkout." % cofile)
                 continue
 
             if not os.path.exists(repodir):
@@ -142,7 +142,7 @@ class Git(Fetch):
             #rungitcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (host, path, os.path.join(repodir, ".git", "")),d)
 
             os.chdir(repodir)
-            bb.note("Creating tarball of git repository")
+            bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git repository")
             rungitcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d)
 
             if os.path.exists(codir):
@@ -154,5 +154,5 @@ class Git(Fetch):
             rungitcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d)
 
             os.chdir(codir)
-            bb.note("Creating tarball of git checkout")
+            bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout")
             rungitcmd("tar -czf %s %s" % (cofile, os.path.join(".", "*") ),d)
index 1910321..3c9ccba 100644 (file)
@@ -118,19 +118,19 @@ class Svk(Fetch):
                 svkcmd = "svk co -r %s/%s" % (revision, svkroot, module)
 
 #           create temp directory
-            bb.debug(2, "Fetch: creating temporary directory")
+            bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: creating temporary directory")
             bb.mkdirhier(data.expand('${WORKDIR}', localdata))
             data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata)
             tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false")
             tmpfile = tmppipe.readline().strip()
             if not tmpfile:
-                bb.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.")
+                bb.msg.error(bb.msg.domain.Fetcher, "Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.")
                 raise FetchError(module)
 
 #           check out sources there
             os.chdir(tmpfile)
-            bb.note("Fetch " + loc)
-            bb.debug(1, "Running %s" % svkcmd)
+            bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
+            bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svkcmd)
             myret = os.system(svkcmd)
             if myret != 0:
                 try:
index fbb3f2f..ad36b01 100644 (file)
@@ -114,7 +114,7 @@ class Svn(Fetch):
 
             # try to use the tarball stash
             if Fetch.check_for_tarball(d, tarfn, dldir, date):
-                bb.debug(1, "%s already exists or was mirrored, skipping svn checkout." % tarfn)
+                bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping svn checkout." % tarfn)
                 continue
 
             olddir = os.path.abspath(os.getcwd())
@@ -141,20 +141,20 @@ class Svn(Fetch):
             pkg=data.expand('${PN}', d)
             pkgdir=os.path.join(data.expand('${SVNDIR}', localdata), pkg)
             moddir=os.path.join(pkgdir, module)
-            bb.debug(2, "Fetch: checking for module directory '" + moddir + "'")
+            bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory '" + moddir + "'")
 
             if os.access(os.path.join(moddir,'.svn'), os.R_OK):
-                bb.note("Update " + loc)
+                bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc)
                # update sources there
                 os.chdir(moddir)
-                bb.debug(1, "Running %s" % svnupcmd)
+                bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svnupcmd)
                 myret = os.system(svnupcmd)
             else:
-                bb.note("Fetch " + loc)
+                bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
                # check out sources there
                 bb.mkdirhier(pkgdir)
                 os.chdir(pkgdir)
-                bb.debug(1, "Running %s" % svncmd)
+                bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svncmd)
                 myret = os.system(svncmd)
 
             if myret != 0:
index e47a885..c009740 100644 (file)
@@ -86,10 +86,10 @@ class Wget(Fetch):
             else:
                 fetchcmd = data.getVar("FETCHCOMMAND", d, 1)
 
-            bb.note("fetch " + uri)
+            bb.msg.note(1, bb.msg.domain.Fetcher, "fetch " + uri)
             fetchcmd = fetchcmd.replace("${URI}", uri)
             fetchcmd = fetchcmd.replace("${FILE}", basename)
-            bb.debug(2, "executing " + fetchcmd)
+            bb.msg.debug(2, bb.msg.domain.Fetcher, "executing " + fetchcmd)
             ret = os.system(fetchcmd)
             if ret != 0:
                 return False
@@ -98,7 +98,7 @@ class Wget(Fetch):
             dl_dir = data.getVar("DL_DIR", d, True)
             if not os.path.exists(dl):
                 os.system("rm %s*" % dl) # FIXME shell quote it
-                bb.debug(2,"sourceforge.net send us to the mirror on %s" % basename)
+                bb.msg.debug(2, bb.msg.domain.Fetcher, "sourceforge.net send us to the mirror on %s" % basename)
                 return False
 
 #           supposedly complete.. write out md5sum
index a30a70c..8634f1f 100644 (file)
@@ -30,7 +30,7 @@ debug_level = 0
 
 verbose = False
 
-domain = bb.utils.Enum('Depends', 'Provider', 'Build', 'Parsing', 'Collection', 'RunQueue', "TaskData")
+domain = bb.utils.Enum('Depends', 'Provider', 'Build', 'Parsing', 'Collection', 'RunQueue', 'TaskData', 'Fetcher')
 
 #
 # Message control functions