mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
externalsrc: Always ask Git for location of .git directory
externalsrc_configure_prefunc assumed that the .git directory is
${S}/.git. This isn't true for submodules at least.
srctree_hash_files already contained code to ask Git for the correct
path to the .git directory. Let's move that code to a new find_git_dir
function and call it from both places and make the behaviour consistent.
(From OE-Core rev: 47891e200e92ba34a6ff2df2fba1032738f52f98)
Signed-off-by: Mike Crowe <mac@mcrowe.com>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
08c8e9066d
commit
7ec0bdc24a
@@ -28,6 +28,20 @@
|
|||||||
SRCTREECOVEREDTASKS ?= "do_patch do_unpack do_fetch"
|
SRCTREECOVEREDTASKS ?= "do_patch do_unpack do_fetch"
|
||||||
EXTERNALSRC_SYMLINKS ?= "oe-workdir:${WORKDIR} oe-logs:${T}"
|
EXTERNALSRC_SYMLINKS ?= "oe-workdir:${WORKDIR} oe-logs:${T}"
|
||||||
|
|
||||||
|
def find_git_dir(d, s_dir):
|
||||||
|
import subprocess
|
||||||
|
git_dir = None
|
||||||
|
try:
|
||||||
|
git_dir = os.path.join(s_dir,
|
||||||
|
subprocess.check_output(['git', '-C', s_dir, 'rev-parse', '--git-dir'], stderr=subprocess.DEVNULL).decode("utf-8").rstrip())
|
||||||
|
top_git_dir = os.path.join(d.getVar("TOPDIR"),
|
||||||
|
subprocess.check_output(['git', '-C', d.getVar("TOPDIR"), 'rev-parse', '--git-dir'], stderr=subprocess.DEVNULL).decode("utf-8").rstrip())
|
||||||
|
if git_dir == top_git_dir:
|
||||||
|
git_dir = None
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
pass
|
||||||
|
return git_dir
|
||||||
|
|
||||||
python () {
|
python () {
|
||||||
externalsrc = d.getVar('EXTERNALSRC')
|
externalsrc = d.getVar('EXTERNALSRC')
|
||||||
externalsrcbuild = d.getVar('EXTERNALSRC_BUILD')
|
externalsrcbuild = d.getVar('EXTERNALSRC_BUILD')
|
||||||
@@ -169,14 +183,16 @@ python externalsrc_configure_prefunc() {
|
|||||||
newlinks.append(symsplit[0])
|
newlinks.append(symsplit[0])
|
||||||
# Hide the symlinks from git
|
# Hide the symlinks from git
|
||||||
try:
|
try:
|
||||||
git_exclude_file = os.path.join(s_dir, '.git/info/exclude')
|
git_dir = find_git_dir(d, s_dir)
|
||||||
if os.path.exists(git_exclude_file):
|
if git_dir:
|
||||||
with open(git_exclude_file, 'r+') as efile:
|
git_exclude_file = os.path.join(git_dir, 'info/exclude')
|
||||||
elines = efile.readlines()
|
if os.path.exists(git_exclude_file):
|
||||||
for link in newlinks:
|
with open(git_exclude_file, 'r+') as efile:
|
||||||
if link in elines or '/'+link in elines:
|
elines = efile.readlines()
|
||||||
continue
|
for link in newlinks:
|
||||||
efile.write('/' + link + '\n')
|
if link in elines or '/'+link in elines:
|
||||||
|
continue
|
||||||
|
efile.write('/' + link + '\n')
|
||||||
except IOError as ioe:
|
except IOError as ioe:
|
||||||
bb.note('Failed to hide EXTERNALSRC_SYMLINKS from git')
|
bb.note('Failed to hide EXTERNALSRC_SYMLINKS from git')
|
||||||
}
|
}
|
||||||
@@ -207,17 +223,7 @@ def srctree_hash_files(d, srcdir=None):
|
|||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
s_dir = srcdir or d.getVar('EXTERNALSRC')
|
s_dir = srcdir or d.getVar('EXTERNALSRC')
|
||||||
git_dir = None
|
git_dir = find_git_dir(d, s_dir)
|
||||||
|
|
||||||
try:
|
|
||||||
git_dir = os.path.join(s_dir,
|
|
||||||
subprocess.check_output(['git', '-C', s_dir, 'rev-parse', '--git-dir'], stderr=subprocess.DEVNULL).decode("utf-8").rstrip())
|
|
||||||
top_git_dir = os.path.join(d.getVar("TOPDIR"),
|
|
||||||
subprocess.check_output(['git', '-C', d.getVar("TOPDIR"), 'rev-parse', '--git-dir'], stderr=subprocess.DEVNULL).decode("utf-8").rstrip())
|
|
||||||
if git_dir == top_git_dir:
|
|
||||||
git_dir = None
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
ret = " "
|
ret = " "
|
||||||
if git_dir is not None:
|
if git_dir is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user