[prev in list] [next in list] [prev in thread] [next in thread]
List: buildroot
Subject: [Buildroot] [PATCH] utils/check-package: improve windows support
From: James Knight <james.d.knight () live ! com>
Date: 2023-04-29 18:51:04
Message-ID: SN4P221MB068289AD66243971AC49547BA0689 () SN4P221MB0682 ! NAMP221 ! PROD ! OUTLOOK ! COM
[Download RAW message or body]
The following includes a series of tweaks to the check-package script to
provide flexibility when sanity checking files when sources are checked
out in a Windows environment. This includes:
- When populating a list of files to check, ensure POSIX paths are used;
otherwise, the internal list of files to check will be improperly
formed and no checks will occur.
- When interpreting an ignore list (which provides POSIX paths of files
to ignore), resolve the absolute file path for these entries to
ensure files can be ignored when cycling through a provided file
list.
- Ignore execute bit checks on Windows since X_OK is only an existence
check on Windows.
- When running ShellCheck, always ignore SC1017 [1] to avoid line
ending warnings since Windows environments will typically utilize
`git config core.autocrlf`.
[1]: https://www.shellcheck.net/wiki/SC1017
Signed-off-by: James Knight <james.d.knight@live.com>
---
utils/check-package | 9 +++++++--
utils/checkpackagelib/tool.py | 4 +++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/utils/check-package b/utils/check-package
index 83b9750f5a9c181dc96dcba508682776a600aac5..817dcb0b7203d28b7d2133ac1d8c27ac8093b3c4 \
100755
--- a/utils/check-package
+++ b/utils/check-package
@@ -5,6 +5,7 @@ import argparse
import inspect
import magic
import os
+import posixpath
import re
import sys
@@ -50,7 +51,8 @@ def get_ignored_parsers_per_file(intree_only, ignore_filename):
for line in f.readlines():
filename, warnings_str = line.split(' ', 1)
warnings = warnings_str.split()
- ignored[os.path.join(entry_base_dir, filename)] = warnings
+ entry = os.path.abspath(os.path.join(entry_base_dir, filename))
+ ignored[entry] = warnings
return ignored
@@ -275,7 +277,10 @@ def __main__():
if flags.intree_only:
# change all paths received to be relative to the base dir
base_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
- files_to_check = [os.path.relpath(os.path.abspath(f), base_dir) for f in \
flags.files] + files_to_check = []
+ for f in flags.files:
+ relpath = os.path.relpath(os.path.abspath(f), base_dir)
+ files_to_check.append(relpath.replace(os.sep, posixpath.sep))
# move current dir so the script find the files
os.chdir(base_dir)
else:
diff --git a/utils/checkpackagelib/tool.py b/utils/checkpackagelib/tool.py
index 907ada704fe4beaa57b1c18e7ce2f17977272257..8b2af64d3899a2e7958f79d61722b1b359351747 \
100644
--- a/utils/checkpackagelib/tool.py
+++ b/utils/checkpackagelib/tool.py
@@ -12,7 +12,7 @@ class NotExecutable(_Tool):
def run(self):
if self.ignore():
return
- if os.access(self.filename, os.X_OK):
+ if os.access(self.filename, os.X_OK) and os.name != "nt":
return ["{}:0: This file does not need to be \
executable{}".format(self.filename, self.hint())]
@@ -32,6 +32,8 @@ class Flake8(_Tool):
class Shellcheck(_Tool):
def run(self):
cmd = ['shellcheck', self.filename]
+ if os.name == "nt":
+ cmd.append("--exclude=SC1017")
try:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, \
stderr=subprocess.PIPE) stdout = p.communicate()[0]
--
2.40.1.windows.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic