From: Thomas Roos Date: Mon, 16 Jan 2023 14:30:22 +0000 (+0100) Subject: devtool: fix devtool finish when gitmodules file is empty X-Git-Tag: 2020-04.23-dunfell~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=077edd3992683985f0779afc73d4207a795ced39;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git devtool: fix devtool finish when gitmodules file is empty When a .gitmodules file exists but is empty then devtool finish fails. Add an additional check for this. [YOCTO #14999] Signed-off-by: Thomas Roos Signed-off-by: Luca Ceresoli Signed-off-by: Richard Purdie (cherry picked from commit b4f0f7c4934bade9e4d4a1086f9d8b29d8e9ad45) Signed-off-by: Steve Sakoman --- diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass index ed118afada4..9c9451e5285 100644 --- a/meta/classes/externalsrc.bbclass +++ b/meta/classes/externalsrc.bbclass @@ -225,7 +225,7 @@ def srctree_hash_files(d, srcdir=None): env['GIT_INDEX_FILE'] = tmp_index.name subprocess.check_output(['git', 'add', '-A', '.'], cwd=s_dir, env=env) git_sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env).decode("utf-8") - if os.path.exists(os.path.join(s_dir, ".gitmodules")): + if os.path.exists(os.path.join(s_dir, ".gitmodules")) and os.path.getsize(os.path.join(s_dir, ".gitmodules")) > 0: submodule_helper = subprocess.check_output(["git", "config", "--file", ".gitmodules", "--get-regexp", "path"], cwd=s_dir, env=env).decode("utf-8") for line in submodule_helper.splitlines(): module_dir = os.path.join(s_dir, line.rsplit(maxsplit=1)[1])