Skip to contentSkip to conversation

fetch2: save/restore cwd for mirror URL downloads

PATCH In review Matt Madison 2 participants 3 messages Aug 8, 2016 – Aug 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2: save/restore cwd for mirror URL downloads

Fixes "changed cwd" warnings from setscene tasks when the packages are downloaded from a shared-state mirror.

---
 lib/bb/fetch2/__init__.py | 5 +++++
 1 file changed, 5 insertions(+)
lib/bb/fetch2/__init__.py +5 -0
index 9054b2e..c0017a8 100644
@@ -928,6 +928,8 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
     if ud.lockfile and ud.lockfile != origud.lockfile:
         lf = bb.utils.lockfile(ud.lockfile)
 
+    save_cwd = os.getcwd()
+
     try:
         if check:
             found = ud.method.checkstatus(fetch, ud, ld)
@@ -995,6 +997,7 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
             pass
         return False
     finally:
+        os.chdir(save_cwd)
         if ud.lockfile and ud.lockfile != origud.lockfile:
             bb.utils.unlockfile(lf)
 
@@ -1558,6 +1561,7 @@ class Fetch(object):
 
         network = self.d.getVar("BB_NO_NETWORK", True)
         premirroronly = (self.d.getVar("BB_FETCH_PREMIRRORONLY", True) == "1")
+        save_cwd = os.getcwd()
 
         for u in urls:
             ud = self.ud[u]
@@ -1635,6 +1639,7 @@ class Fetch(object):
             finally:
                 if ud.lockfile:
                     bb.utils.unlockfile(lf)
+        os.chdir(save_cwd)
 
     def checkstatus(self, urls=None):
         """
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines · Matt Madison

Fixes "changed cwd" warnings from setscene tasks when the packages are downloaded from a shared-state mirror.

---
 lib/bb/fetch2/__init__.py | 5 +++++
 1 file changed, 5 insertions(+)

bitbake-selftest doesn't seem to like this change:

https://autobuilder.yoctoproject.org/main/builders/nightly/builds/973/steps/BitbakeSelftest/logs/stdio

I do wonder if we need to fix the individual fetcher modules...

Cheers,

Richard

Quoted 43 lines
lib/bb/fetch2/__init__.py +0 -0
index 9054b2e..c0017a8 100644
@@ -928,6 +928,8 @@ def try_mirror_url(fetch, origud, ud, ld, check =

False):
if ud.lockfile and ud.lockfile != origud.lockfile:
lf = bb.utils.lockfile(ud.lockfile)

lib/bb/fetch2/__init__.py +2 -0
+    save_cwd = os.getcwd()
+
     try:
         if check:
             found = ud.method.checkstatus(fetch, ud, ld)
@@ -995,6 +997,7 @@ def try_mirror_url(fetch, origud, ud, ld, check =

False):
pass
return False
finally:

lib/bb/fetch2/__init__.py +2 -0
+        os.chdir(save_cwd)
         if ud.lockfile and ud.lockfile != origud.lockfile:
             bb.utils.unlockfile(lf)
@@ -1558,6 +1561,7 @@ class Fetch(object):
 
         network = self.d.getVar("BB_NO_NETWORK", True)
         premirroronly = (self.d.getVar("BB_FETCH_PREMIRRORONLY",
 True) == "1")
+        save_cwd = os.getcwd()
 
         for u in urls:
             ud = self.ud[u]
lib/bb/fetch2/__init__.py +1 -0
@@ -1635,6 +1639,7 @@ class Fetch(object):
             finally:
                 if ud.lockfile:
                     bb.utils.unlockfile(lf)
+        os.chdir(save_cwd)
 
     def checkstatus(self, urls=None):
         """
Signature · 1 line
2.7.4
#2 lore raw
Quoted 9 lines · Richard Purdie
Quoted 7 lines · Matt Madison

Fixes "changed cwd" warnings from setscene tasks when the packages are downloaded from a shared-state mirror.

---
 lib/bb/fetch2/__init__.py | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 5 lines

bitbake-selftest doesn't seem to like this change:

https://autobuilder.yoctoproject.org/main/builders/nightly/builds/973/steps/BitbakeSelftest/logs/stdio

I do wonder if we need to fix the individual fetcher modules...

I could at least rework the patch to put the getcwd call into a try/except block. I'll
take a closer look.

Thanks,
-Matt

Quoted 48 lines

Cheers,

Richard

Quoted 43 lines
lib/bb/fetch2/__init__.py +0 -0
index 9054b2e..c0017a8 100644
@@ -928,6 +928,8 @@ def try_mirror_url(fetch, origud, ud, ld, check =

False):
if ud.lockfile and ud.lockfile != origud.lockfile:
lf = bb.utils.lockfile(ud.lockfile)

lib/bb/fetch2/__init__.py +2 -0
+    save_cwd = os.getcwd()
+
     try:
         if check:
             found = ud.method.checkstatus(fetch, ud, ld)
@@ -995,6 +997,7 @@ def try_mirror_url(fetch, origud, ud, ld, check =

False):
pass
return False
finally:

lib/bb/fetch2/__init__.py +2 -0
+        os.chdir(save_cwd)
         if ud.lockfile and ud.lockfile != origud.lockfile:
             bb.utils.unlockfile(lf)
@@ -1558,6 +1561,7 @@ class Fetch(object):
 
         network = self.d.getVar("BB_NO_NETWORK", True)
         premirroronly = (self.d.getVar("BB_FETCH_PREMIRRORONLY",
 True) == "1")
+        save_cwd = os.getcwd()
 
         for u in urls:
             ud = self.ud[u]
lib/bb/fetch2/__init__.py +1 -1
@@ -1635,6 +1639,7 @@ class Fetch(object):
             finally:
                 if ud.lockfile:
                     bb.utils.unlockfile(lf)
+        os.chdir(save_cwd)
 
     def checkstatus(self, urls=None):
         """
--

2.7.4