poky/scripts/git
Richard Purdie 7868ccd57a scripts/git: Ensure we don't have circular references
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.

(From OE-Core rev: b9dcaa76b3274ced1e4b9e2ca33f778e8cd50032)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 27de610ac30d4c81352efc794df7e9b1060f7a68)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-05-12 16:44:06 +01:00

638 B
Executable File

#!/usr/bin/env python3

Wrapper around 'git' that doesn't think we are root

import os import shutil import sys

os.environ['PSEUDO_UNLOAD'] = '1'

calculate path to the real 'git'

path = os.environ['PATH']

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: os.execl(real_git, 'git')

os.execv(real_git, sys.argv)