From 8439fd0b2e72fc052312dc73fba53e2a21dbf432 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 8 Apr 2020 01:50:29 +0200 Subject: [PATCH] Reorganize some stuff --- package_linter.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/package_linter.py b/package_linter.py index 69883ef..7fe1bfc 100755 --- a/package_linter.py +++ b/package_linter.py @@ -260,7 +260,6 @@ class App(): self.check_manifest() self.misc_file_checks() self.check_helpers_usage() - self.check_source_management() for script in [self.scripts[s] for s in scriptnames if self.scripts[s].exists]: script.analyze() @@ -342,6 +341,19 @@ class App(): ) # + # Source management + # + source_dir = os.path.join(self.path, "sources") + if os.path.exists(source_dir) \ + and len([name for name in os.listdir(source_dir) if os.path.isfile(os.path.join(source_dir, name))]) > 5: + print_warning( + "[YEP-3.3] Upstream app sources shouldn't be stored in this 'sources' folder of this git repository as a copy/paste\n" + "During installation, the package should download sources from upstream via 'ynh_setup_source'.\n" + "See the helper documentation. " + "Original discussion happened here : " + "https://github.com/YunoHost/issues/issues/201#issuecomment-391549262" + ) + # # Analyze nginx conf # - Deprecated usage of 'add_header' in nginx conf # - Spot path traversal issue vulnerability @@ -456,19 +468,6 @@ class App(): "but not 'yunohost service remove' in the remove script." ) - def check_source_management(self): - print_header("SOURCES MANAGEMENT") - DIR = os.path.join(self.path, "sources") - # Check if there is more than six files on 'sources' folder - if os.path.exists(os.path.join(self.path, "sources")) \ - and len([name for name in os.listdir(DIR) if os.path.isfile(os.path.join(DIR, name))]) > 5: - print_warning( - "[YEP-3.3] Upstream app sources shouldn't be stored in this 'sources' folder of this git repository as a copy/paste\n" - "During installation, the package should download sources from upstream via 'ynh_setup_source'.\n" - "See the helper documentation. " - "Original discussion happened here : " - "https://github.com/YunoHost/issues/issues/201#issuecomment-391549262" - ) def check_manifest(self): manifest = os.path.join(self.path, 'manifest.json') @@ -722,7 +721,6 @@ class Script(): self.check_set_usage() self.check_helper_usage_dependencies() self.check_deprecated_practices() - self.check_source_common() def check_set_usage(self): @@ -843,8 +841,6 @@ class Script(): helpers_after_official = helpers_after_official.split("\n") print_warning("Please avoid sourcing additional helpers after the official helpers (in this case file %s)" % ", ".join(helpers_after_official)) - def check_source_common(self): - if self.name in ["backup", "restore"]: if self.contains("source _common.sh") or self.contains("source ./_common.sh"): print_warning("In the context of backup and restore script, you should load _common.sh with \"source ../settings/scripts/_common.sh\"")