From 5266670b2da48cccc9f042ca7afc7f86d7ff89ae Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 9 Jun 2022 11:27:14 +0100 Subject: lib/buildcfg: Share common clean/dirty layer function The comments even say this was copy/paste code. Move to a shared library function. (From OE-Core rev: ac3de2f850a418673b87e1c454970cb099e191b0) Signed-off-by: Richard Purdie --- meta/lib/oe/buildcfg.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'meta/lib') diff --git a/meta/lib/oe/buildcfg.py b/meta/lib/oe/buildcfg.py index a749fc5303..a7549f1e22 100644 --- a/meta/lib/oe/buildcfg.py +++ b/meta/lib/oe/buildcfg.py @@ -37,4 +37,17 @@ def get_metadata_git_revision(path, d): except bb.process.ExecutionError: rev = '' return rev.strip() - + +def is_layer_modified(path): + try: + subprocess.check_output("""cd %s; export PSEUDO_UNLOAD=1; set -e; + git diff --quiet --no-ext-diff + git diff --quiet --no-ext-diff --cached""" % path, + shell=True, + stderr=subprocess.STDOUT) + return "" + except subprocess.CalledProcessError as ex: + # Silently treat errors as "modified", without checking for the + # (expected) return code 1 in a modified git repo. For example, we get + # output and a 129 return code when a layer isn't a git repo at all. + return " -- modified" -- cgit v1.2.3-54-g00ecf