]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
lib/oe/patch: ensure os.chdir restoring always happens
authorRoss Burton <ross.burton@arm.com>
Tue, 21 Nov 2023 14:06:17 +0000 (14:06 +0000)
committerSteve Sakoman <steve@sakoman.com>
Thu, 28 Dec 2023 14:43:58 +0000 (04:43 -1000)
If we chdir(), do the chdir back to the original directory in a finally
block so they always run.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit cdc40292818683b6df1c814498c7589450a163fa)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/lib/oe/patch.py

index ff9afc9df9f63f7cc11593e26ecbc3f44cd5c664..9b480b2b285728cda1d90d464170990326e29909 100644 (file)
@@ -772,8 +772,9 @@ class NOOPResolver(Resolver):
             self.patchset.Push()
         except Exception:
             import sys
-            os.chdir(olddir)
             raise
+        finally:
+            os.chdir(olddir)
 
 # Patch resolver which relies on the user doing all the work involved in the
 # resolution, with the exception of refreshing the remote copy of the patch
@@ -833,9 +834,9 @@ class UserResolver(Resolver):
                             # User did not fix the problem.  Abort.
                             raise PatchError("Patch application failed, and user did not fix and refresh the patch.")
         except Exception:
-            os.chdir(olddir)
             raise
-        os.chdir(olddir)
+        finally:
+            os.chdir(olddir)
 
 
 def patch_path(url, fetch, workdir, expand=True):