]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
scripts/git: Ensure we don't have circular references
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 6 May 2022 15:56:03 +0000 (16:56 +0100)
committerAnuj Mittal <anuj.mittal@intel.com>
Tue, 10 May 2022 03:55:08 +0000 (11:55 +0800)
This is horrible but I'm running out of better ideas. We hit circular reference
issues which we were trying to avoid in the core HOSTTOOLS code. When building
the eSDK, there can be two copies of the script.

Therefore assume git will never be in a directory called scripts. This
fixes eSDK build failures.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 27de610ac30d4c81352efc794df7e9b1060f7a68)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
scripts/git

index 8adf5c9ecb71735fc8cae4f020db3d03801aa539..644055e54017028bf0d7e7ce132cbd030a273d06 100755 (executable)
@@ -10,7 +10,14 @@ os.environ['PSEUDO_UNLOAD'] = '1'
 
 # calculate path to the real 'git'
 path = os.environ['PATH']
-path = path.replace(os.path.dirname(sys.argv[0]), '')
+# we need to remove our path but also any other copy of this script which
+# may be present, e.g. eSDK.
+replacements = [os.path.dirname(sys.argv[0])]
+for p in path.split(":"):
+    if p.endswith("/scripts"):
+        replacements.append(p)
+for r in replacements:
+    path = path.replace(r, '/ignoreme')
 real_git = shutil.which('git', path=path)
 
 if len(sys.argv) == 1: