mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
Add shellcheck check
This commit is contained in:
parent
d0dd509ca2
commit
e468a790c7
1 changed files with 25 additions and 0 deletions
|
@ -8,9 +8,12 @@ import json
|
||||||
import shlex
|
import shlex
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import codecs
|
import codecs
|
||||||
|
import apt
|
||||||
|
import subprocess
|
||||||
|
|
||||||
reader = codecs.getreader("utf-8")
|
reader = codecs.getreader("utf-8")
|
||||||
return_code = 0
|
return_code = 0
|
||||||
|
pkg_name = "shellcheck"
|
||||||
|
|
||||||
|
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
|
@ -437,12 +440,33 @@ def check_deprecated_practices(script):
|
||||||
if script["name"] == "install" and "ynh_print_info" not in script["shlex"] and "ynh_script_progression" not in script["shlex"]:
|
if script["name"] == "install" and "ynh_print_info" not in script["shlex"] and "ynh_script_progression" not in script["shlex"]:
|
||||||
print_warning("Please add a few messages for the user, to explain what is going on (in friendly, not-too-technical terms) during the installation. You can use 'ynh_print_info' or 'ynh_script_progression' for this.")
|
print_warning("Please add a few messages for the user, to explain what is going on (in friendly, not-too-technical terms) during the installation. You can use 'ynh_print_info' or 'ynh_script_progression' for this.")
|
||||||
|
|
||||||
|
def install_shellcheck():
|
||||||
|
print("Check if "+ pkg_name +" is installed... ", end=" ")
|
||||||
|
cache = apt.cache.Cache()
|
||||||
|
cache.update()
|
||||||
|
cache.open()
|
||||||
|
|
||||||
|
pkg = cache[pkg_name]
|
||||||
|
if pkg.is_installed:
|
||||||
|
print ("OK")
|
||||||
|
else:
|
||||||
|
pkg.mark_install()
|
||||||
|
try:
|
||||||
|
cache.commit()
|
||||||
|
print ("OK")
|
||||||
|
except Exception:
|
||||||
|
print ("Package installation failed " + str(arg),file=sys.stderr)
|
||||||
|
|
||||||
|
def check_shellcheck(script_path):
|
||||||
|
subprocess.run(["shellcheck",script_path])
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print("Give one app package path.")
|
print("Give one app package path.")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
app_path = sys.argv[1]
|
app_path = sys.argv[1]
|
||||||
|
install_shellcheck()
|
||||||
header(app_path)
|
header(app_path)
|
||||||
|
|
||||||
# Global checks
|
# Global checks
|
||||||
|
@ -473,6 +497,7 @@ def main():
|
||||||
check_helper_consistency(script)
|
check_helper_consistency(script)
|
||||||
check_deprecated_practices(script)
|
check_deprecated_practices(script)
|
||||||
# check_arg_retrieval(script)
|
# check_arg_retrieval(script)
|
||||||
|
check_shellcheck(script["path"])
|
||||||
|
|
||||||
sys.exit(return_code)
|
sys.exit(return_code)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue