From 11b60e838bec7e745852f4a3de30245d6e2062dd Mon Sep 17 00:00:00 2001 From: Antoine Fontaine Date: Tue, 19 May 2020 21:59:49 +0200 Subject: [PATCH] ci: check for executable files (MR 1257) fix https://gitlab.com/postmarketOS/pmaports/-/issues/593. --- .../testcases/test_directory_structure.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.gitlab-ci/testcases/test_directory_structure.py b/.gitlab-ci/testcases/test_directory_structure.py index 195e1475c..e96c555cc 100644 --- a/.gitlab-ci/testcases/test_directory_structure.py +++ b/.gitlab-ci/testcases/test_directory_structure.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later import glob import os +import stat expected_directories = [ "console", @@ -28,6 +29,23 @@ def test_directories(): "Consider adding it to test_directory_structure.py!" +# Ensure no file in pmaports are executable. +# see https://gitlab.com/postmarketOS/pmaports/-/issues/593. +def test_executable_files(): + for file in glob.iglob("**/*", recursive=True): + if os.path.isdir(file) or os.path.islink(file): + continue + # still check other less common inode types + permissions = os.stat(file).st_mode + executable_bits = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH + if permissions & executable_bits != 0: + raise RuntimeError(f"\"{file}\" is executable. Files in pmaports" + + " should not be executables. post-* files" + + " don't need to be executable and executables" + + " should be installed using `install -D" + + "m0755` or a variation thereof.") + + # Make sure files are either: # - in root directory (README.md) # - hidden (.gitlab-ci/, device/.shared-patches/)