Skip to contentSkip to conversation

Fix sstate error

PATCH Applied Zhai Edwin 2 participants 6 messages Feb 11, 2011 – Feb 12, 2011

lore
Share & tools
lore

Zhai Edwin

author
#0 lore raw

cover Fix sstate error

From: Zhai Edwin <[email protected]>

RP,
Current sstate's fetch code doesn't reflect latest fetcher changes, so old fetch style cause exception and fail silently. This patch fix it.

Another issue is "import xxx" in python function from sstate.bbclass can only sit in the head of the function, else have UnboundLocalError: "local variable XXX referenced before assignment".

We don't know if it is a known limitation of *.bbclass or some potential bug. Can you give some comments?

Thanks,
edwin

Pull URL: git://git.pokylinux.org/poky-contrib.git
Branch: gzhai/fix2
Browse: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=gzhai/fix2

Thanks,
Zhai Edwin <[email protected]>
---

Zhai Edwin (1):
sstate: Fix bugs after new fetcher

 meta/classes/sstate.bbclass |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
author
#1 lore raw

PATCH 1/1 sstate: Fix bugs after new fetcher

From: Zhai Edwin <[email protected]>

Current sstate's fetch code doesn't reflect latest fetcher changes, so old fetch style cause exception and fail silently.

[BUGID #708] got fixed.

Another issue is "import xxx" in python function from sstate.bbclass can only sit in the head of the function, else have UnboundLocalError: "local variable XXX referenced before assignment".

---
 meta/classes/sstate.bbclass |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
meta/classes/sstate.bbclass +3 -3
index e4564e4..4f1bc39 100644
@@ -326,13 +326,13 @@ def sstate_package(ss, d):
     return
 
 def pstaging_fetch(sstatepkg, d):
+    import bb.fetch2
 
     # Only try and fetch if the user has configured a mirror
     mirrors = bb.data.getVar('SSTATE_MIRRORS', d, True)
     if not mirrors:
         return
 
-    import bb.fetch2
     # Copy the data object and override DL_DIR and SRC_URI
     localdata = bb.data.createCopy(d)
     bb.data.update_data(localdata)
@@ -453,8 +453,8 @@ def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d):
             #bb.note(str(srcuri))
 
             try:
-                bb.fetch.init(srcuri.split(), localdata)
-                bb.fetch.checkstatus(localdata, srcuri.split())
+                fetcher = bb.fetch2.Fetch(srcuri.split(), localdata)
+                fetcher.checkstatus()
                 ret.append(task)
             except:
                 pass     
Signature · 1 line
1.6.3.3
#2 lore raw
In reply to Zhai Edwin
Quoted 5 lines · Zhai Edwin

From: Zhai Edwin <[email protected]>

RP,
Current sstate's fetch code doesn't reflect latest fetcher changes, so old fetch style cause exception and fail silently. This patch fix it.

I've merged the fix to master, thanks.

Quoted 6 lines

Another issue is "import xxx" in python function from sstate.bbclass can only sit in the head of the function, else have UnboundLocalError: "local variable XXX referenced before assignment".

We don't know if it is a known limitation of *.bbclass or some potential bug. Can you give some comments?

Good question. The import should really always be at the top of the code block in question so I think its a python constraint, not a .bbclass one...

Cheers,

Richard

#3 lore raw
Quoted 17 lines · Richard Purdie
Quoted 4 lines · Zhai Edwin

From: Zhai Edwin <[email protected]>

RP,
Current sstate's fetch code doesn't reflect latest fetcher changes,

so old

Quoted 1 line

fetch style cause exception and fail silently. This patch fix it.

I've merged the fix to master, thanks.

Quoted 1 line

Another issue is "import xxx" in python function from sstate.bbclass

can only

Quoted 1 line

sit in the head of the function, else have UnboundLocalError: "local

variable

Quoted 2 lines

XXX referenced before assignment".

Quoted 8 lines
Quoted 1 line

We don't know if it is a known limitation of *.bbclass or some

potential bug.

Quoted 1 line

Can you give some comments?

Good question. The import should really always be at the top of the code block in question so I think its a python constraint, not a .bbclass one...

Seems in-middle "import" is widely used in other *.py, See bitbake/lib/bb/fetch/ssh.py,
def go(self, url, urldata, d):
..........................

       import commands
       cmd = 'scp -B -r %s %s %s/' % (
           port,
           commands.mkarg(fr),
           commands.mkarg(ldir)
       )

I found only bb has such limitation:all the "import bb.xxx" are in the head of function, and adding stuff before it will cause same problem. Anything special for bb module?

Quoted 10 lines

Cheers,

Richard

#4 lore raw
Quoted 17 lines · Edwin
Quoted 4 lines · Richard Purdie

Good question. The import should really always be at the top of the code block in question so I think its a python constraint, not a .bbclass one...

Seems in-middle "import" is widely used in other *.py, See bitbake/lib/bb/fetch/ssh.py,
def go(self, url, urldata, d):
..........................

        import commands
        cmd = 'scp -B -r %s %s %s/' % (
            port,
            commands.mkarg(fr),
            commands.mkarg(ldir)
        )
Quoted 3 lines

I found only bb has such limitation:all the "import bb.xxx" are in the head of function, and adding stuff before it will cause same problem. Anything special for bb module?

Is it just specific to the way we hacked the fetch vs fetch2 switch in?

Also, are you saying this problem only happens in parsed python in the .bb and .bbclass files or that it happens in the bitbake code in general?

Cheers,

Richard

#5 lore raw
Quoted 24 lines · Richard Purdie
Quoted 2 lines · Edwin
Quoted 1 line · Richard Purdie

Good question. The import should really always be at the top of

the code

Quoted 15 lines
Quoted 3 lines

block in question so I think its a python constraint, not a .bbclass one...

Seems in-middle "import" is widely used in other *.py, See bitbake/lib/bb/fetch/ssh.py,
def go(self, url, urldata, d):
..........................

        import commands
        cmd = 'scp -B -r %s %s %s/' % (
            port,
            commands.mkarg(fr),
            commands.mkarg(ldir)
        )
Quoted 3 lines

I found only bb has such limitation:all the "import bb.xxx" are in the head of function, and adding stuff before it will cause same problem. Anything special for bb module?

Quoted 6 lines

Is it just specific to the way we hacked the fetch vs fetch2 switch in?

Also, are you saying this problem only happens in parsed python in the .bb and .bbclass files or that it happens in the bitbake code in general?

Also in bitbake code like bitbake/lib/bb/utils.py.

Quoted 4 lines

Cheers,

Richard