[3/9] isar-sstate: lint: check for absolute paths in SRC_URI

Message ID 20240405163135.2987489-4-chris.larson@siemens.com
State Accepted, archived
Headers show
Series Add more signature cachability tests to the testsuite | expand

Commit Message

Larson, Chris April 5, 2024, 4:31 p.m. UTC
From: Christopher Larson <chris.larson@siemens.com>

In addition to the current checks for variables starting with an
absolute path, particularly those within the build or sources
directories, we should also check for absolute paths in SRC_URI
file entries.

Submitted at https://groups.google.com/g/isar-users/c/2NB-PXyswq8/m/C8LiWa1TAQAJ.

Signed-off-by: Christopher Larson <chris.larson@siemens.com>
---
 scripts/isar-sstate | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Patch

diff --git a/scripts/isar-sstate b/scripts/isar-sstate
index c14c2843..9b20cb8e 100755
--- a/scripts/isar-sstate
+++ b/scripts/isar-sstate
@@ -839,6 +839,23 @@  def sstate_lint(target, verbose, sources_dir, build_dir, exit_code, pedantic, **
                 continue
             # remove leading whitespaces possibly added by appending
             val = val.lstrip()
+            if name == 'SRC_URI':
+                src_uri = val.split()
+                for entry in src_uri:
+                    if entry.startswith('file:///'):
+                        entry_path = entry[7:]
+                        if entry_path.startswith(build_dir):
+                            pn_issues.append(f'\033[0;31m-> path in build-dir:   SRC_URI entry "{entry}"\033[0m')
+                            hits_builddir += 1
+                        elif entry_path.startswith(sources_dir):
+                            pn_issues.append(f'\033[0;31m-> path in sources-dir: SRC_URI entry "{entry}"\033[0m')
+                            hits_srcdir += 1
+                        else:
+                            hits_other += 1
+                            if verbose:
+                                pn_issues.append(f'\033[0;34m-> other absolute path: SRC_URI entry "{entry}"\033[0m')
+                continue
+
             if not val[0] == '/':
                 continue
             if val.startswith(build_dir):