Bug 13798

Summary: Exception: UnboundLocalError: local variable 'svnfetchcmd' referenced before assignment when fetch from svn
Product: [Build System, Metadata & Runtime] BitBake Reporter: Georgi <georgi.georgiev>
Component: bitbakeAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Undecided CC: poky.bs.watcher, poky.watcher
Version: 3.0   
Target Milestone: ---   
Hardware: Other   
OS: arm   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Georgi 2020-02-19 11:57:09 UTC
When doing incremental builds on our build server always we observe the following:
ERROR: ww-pacman-121204-r0 do_fetch: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:base_do_fetch(d)
     0003:
File: '/data/home/w23698/projects/proj/build/../sources/poky/meta/classes/base.bbclass', lineno: 163, function: base_do_fetch
     0159:        return
     0160:
     0161:    try:
     0162:        fetcher = bb.fetch2.Fetch(src_uri, d)
 *** 0163:        fetcher.download()
     0164:    except bb.fetch2.BBFetchException as e:
     0165:        bb.fatal(str(e))
     0166:}
     0167:
File: '/data/home/w23698/projects/proj/sources/poky/bitbake/lib/bb/fetch2/__init__.py', lineno: 1678, function: download
     1674:                    try:
     1675:                        if not trusted_network(self.d, ud.url):
     1676:                            raise UntrustedUrl(ud.url)
     1677:                        logger.debug(1, "Trying Upstream")
 *** 1678:                        m.download(ud, self.d)
     1679:                        if hasattr(m, "build_mirror_data"):
     1680:                            m.build_mirror_data(ud, self.d)
     1681:                        localpath = ud.localpath
     1682:                        # early checksum verify, so that if checksum mismatched,
File: '/data/home/w23698/projects/proj/sources/poky/bitbake/lib/bb/fetch2/svn.py', lineno: 150, function: download
     0146:            if not ("externals" in ud.parm and ud.parm["externals"] == "nowarn"):
     0147:                # Warn the user if this had externals (won't catch them all)
     0148:                output = runfetchcmd("svn propget svn:externals || true", d, workdir=ud.moddir)
     0149:                if output:
 *** 0150:                    if "--ignore-externals" in svnfetchcmd.split():
     0151:                        bb.warn("%s contains svn:externals." % ud.url)
     0152:                        bb.warn("These should be added to the recipe SRC_URI as necessary.")
     0153:                        bb.warn("svn fetch has ignored externals:\n%s" % output)
     0154:                        bb.warn("To disable this warning add ';externals=nowarn' to the url.")
Exception: UnboundLocalError: local variable 'svnfetchcmd' referenced before assignment

This puts a serious obstacle to automate our builds and make CI in the future.
I made a change which works. I am aware that it is possible this not to be the proper solution:
--- a/bitbake/lib/bb/fetch2/svn.py
+++ b/bitbake/lib/bb/fetch2/svn.py
@@ -145,6 +145,7 @@ class Svn(FetchMethod):

             if not ("externals" in ud.parm and ud.parm["externals"] == "nowarn"):
                 # Warn the user if this had externals (won't catch them all)
+                svnfetchcmd = self._buildsvncommand(ud, d, "fetch")
                 output = runfetchcmd("svn propget svn:externals || true", d, workdir=ud.moddir)
                 if output:
                     if "--ignore-externals" in svnfetchcmd.split():
Greetings,
Georgi
Comment 1 Richard Purdie 2020-02-19 18:44:54 UTC
I've put a patch to test in master-next
Comment 3 Georgi 2020-02-20 15:29:45 UTC
Thanks Richard,
It works on our side too. What is the process? Should I close this or you handle this?

Cheers
Georgi