mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Mode dégradé sans check_process
This commit is contained in:
parent
6ba1d93a26
commit
2030cf01b8
4 changed files with 313 additions and 166 deletions
|
@ -54,7 +54,7 @@ then
|
|||
fi
|
||||
else # Si le fichier de version n'existe pas, il est créé.
|
||||
echo "$version_plinter" > "$script_dir/plinter_version"
|
||||
ECHO_FORMAT "Installation de package_linter." "white"
|
||||
ECHO_FORMAT "Installation de package_linter.\n" "white"
|
||||
git clone --quiet https://github.com/YunoHost/package_linter "$script_dir/package_linter"
|
||||
fi
|
||||
echo "$version_plinter" > "$script_dir/plinter_version"
|
||||
|
@ -163,10 +163,11 @@ fi
|
|||
sudo rm -rf "$APP_CHECK/.git" # Purge des fichiers de git
|
||||
|
||||
# Vérifie l'existence du fichier check_process
|
||||
check_file=1
|
||||
if [ ! -e "$APP_CHECK/check_process" ]; then
|
||||
ECHO_FORMAT "\nImpossible de trouver le fichier check_process pour procéder aux tests.\n" "red"
|
||||
ECHO_FORMAT "Merci d'ajouter un fichier check_process à la racine de l'app à tester.\n" "red"
|
||||
exit 1
|
||||
ECHO_FORMAT "Package check va être utilisé en mode dégradé.\n" "lyellow"
|
||||
check_file=0
|
||||
fi
|
||||
|
||||
|
||||
|
@ -445,10 +446,12 @@ if [ "$no_lxc" -eq 0 ]; then
|
|||
LXC_INIT
|
||||
fi
|
||||
|
||||
## Parsing du fichier check_process de manière séquentielle.
|
||||
echo "Parsing du fichier check_process"
|
||||
while read <&4 LIGNE
|
||||
do
|
||||
if [ "$check_file" -eq 1 ]
|
||||
then # Si le fichier check_process est trouvé
|
||||
## Parsing du fichier check_process de manière séquentielle.
|
||||
echo "Parsing du fichier check_process"
|
||||
while read <&4 LIGNE
|
||||
do
|
||||
LIGNE=$(echo $LIGNE | sed 's/^ *"//g') # Efface les espaces en début de ligne
|
||||
if [ "${LIGNE:0:1}" == "#" ]; then
|
||||
# Ligne de commentaire, ignorée.
|
||||
|
@ -621,8 +624,67 @@ do
|
|||
fi
|
||||
fi
|
||||
fi
|
||||
done 4< "$APP_CHECK/check_process" # Utilise le descripteur de fichier 4. Car le descripteur 1 est utilisé par d'autres boucles while read dans ces scripts.
|
||||
|
||||
done 4< "$APP_CHECK/check_process" # Utilise le descripteur de fichier 4. Car le descripteur 1 est utilisé par d'autres boucles while read dans ces scripts.
|
||||
else # Si le fichier check_process n'a pas été trouvé, fonctionne en mode dégradé.
|
||||
python "$script_dir/sub_scripts/ci/maniackc.py" "$APP_CHECK/manifest.json" > "$script_dir/manifest_extract" # Extrait les infos du manifest avec le script de Bram
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
wrong_user=1
|
||||
wrong_path=1
|
||||
incorrect_path=1
|
||||
all_test=$((all_test+9))
|
||||
while read LIGNE
|
||||
do
|
||||
if echo "$LIGNE" | grep -q ":ynh.local"; then
|
||||
MANIFEST_DOMAIN=$(echo "$LIGNE" | grep ":ynh.local" | cut -d ':' -f1) # Garde uniquement le nom de la clé.
|
||||
fi
|
||||
if echo "$LIGNE" | grep -q "path:"; then
|
||||
MANIFEST_PATH=$(echo "$LIGNE" | grep "path:" | cut -d ':' -f1) # Garde uniquement le nom de la clé.
|
||||
fi
|
||||
if echo "$LIGNE" | grep -q "user:\|admin:"; then
|
||||
MANIFEST_USER=$(echo "$LIGNE" | grep "user:\|admin:" | cut -d ':' -f1) # Garde uniquement le nom de la clé.
|
||||
fi
|
||||
MANIFEST_ARGS="$MANIFEST_ARGS$(echo "$LIGNE" | cut -d ':' -f1,2 | sed s/:/=/)&" # Ajoute l'argument du manifest
|
||||
done < "$script_dir/manifest_extract"
|
||||
if [ "$MANIFEST_DOMAIN" == "null" ]
|
||||
then
|
||||
ECHO_FORMAT "La clé de manifest du domaine n'a pas été trouvée.\n" "lyellow"
|
||||
setup_sub_dir=0
|
||||
setup_root=0
|
||||
upgrade=0
|
||||
backup_restore=0
|
||||
multi_instance=0
|
||||
wrong_user=0
|
||||
wrong_path=0
|
||||
incorrect_path=0
|
||||
all_test=$((all_test-8))
|
||||
fi
|
||||
if [ "$MANIFEST_PATH" == "null" ]
|
||||
then
|
||||
ECHO_FORMAT "La clé de manifest du path n'a pas été trouvée.\n" "lyellow"
|
||||
setup_root=0
|
||||
multi_instance=0
|
||||
incorrect_path=0
|
||||
all_test=$((all_test-3))
|
||||
fi
|
||||
if [ "$MANIFEST_USER" == "null" ]
|
||||
then
|
||||
ECHO_FORMAT "La clé de manifest de l'user admin n'a pas été trouvée.\n" "lyellow"
|
||||
setup_sub_dir=0
|
||||
setup_root=0
|
||||
upgrade=0
|
||||
backup_restore=0
|
||||
multi_instance=0
|
||||
wrong_user=0
|
||||
wrong_path=0
|
||||
incorrect_path=0
|
||||
all_test=$((all_test-8))
|
||||
fi
|
||||
fi
|
||||
|
||||
TESTING_PROCESS
|
||||
if [ "$no_lxc" -eq 0 ]; then
|
||||
|
@ -632,6 +694,6 @@ TEST_RESULTS
|
|||
|
||||
echo "Le log complet des installations et suppressions est disponible dans le fichier $COMPLETE_LOG"
|
||||
# Clean
|
||||
rm -f "$OUTPUTD" "$temp_RESULT" "$script_dir/url_output" "$script_dir/curl_print"
|
||||
rm -f "$OUTPUTD" "$temp_RESULT" "$script_dir/url_output" "$script_dir/curl_print" "$script_dir/manifest_extract"
|
||||
|
||||
sudo rm -rf "$APP_CHECK"
|
||||
|
|
73
sub_scripts/ci/default_args.py
Executable file
73
sub_scripts/ci/default_args.py
Executable file
|
@ -0,0 +1,73 @@
|
|||
# Merci a Bram pour ce code python.
|
||||
# https://github.com/YunoHost/ci
|
||||
|
||||
import os
|
||||
import json
|
||||
from urllib import urlretrieve
|
||||
|
||||
|
||||
def argument_for_question(question, all_choices=False):
|
||||
question_type = question.get("type")
|
||||
|
||||
if question_type is None and question.get("choices"):
|
||||
question_type = "boolean"
|
||||
elif question_type is None and question.get("default"):
|
||||
question_type = "with_default"
|
||||
elif question_type is None and question["name"] == "admin":
|
||||
question_type = "user"
|
||||
elif question_type is None and question["name"] == "domain":
|
||||
question_type = "domain"
|
||||
|
||||
if question_type == "domain":
|
||||
return (question["name"], "ynh.local")
|
||||
elif question_type == "path":
|
||||
if all_choices:
|
||||
return (question["name"], question["default"], "/")
|
||||
else:
|
||||
return (question["name"], question["default"])
|
||||
elif question_type == "with_default":
|
||||
return (question["name"], question["default"])
|
||||
elif question_type == "boolean":
|
||||
if not all_choices:
|
||||
if isinstance(question["default"], bool):
|
||||
if question["default"]:
|
||||
question["default"] = "Yes"
|
||||
else:
|
||||
question["default"] = "No"
|
||||
|
||||
return (question["name"], question["default"])
|
||||
else:
|
||||
if isinstance(question["default"], bool) :
|
||||
return (question["name"], "Yes", "No")
|
||||
|
||||
if question.get("choices"):
|
||||
return (question["name"],) + tuple(question["choices"])
|
||||
|
||||
return (question["name"], question["default"])
|
||||
elif question_type == "password":
|
||||
return (question["name"], "ynh")
|
||||
elif question_type == "user":
|
||||
return (question["name"], "johndoe")
|
||||
else:
|
||||
raise Exception("Unknow question type: %s\n" % question_type, question)
|
||||
|
||||
def default_arguments_for_app(app_data):
|
||||
answers = []
|
||||
for question in app_data["manifest"]["arguments"]["install"]:
|
||||
answers.append(argument_for_question(question))
|
||||
|
||||
return "&".join(["=".join([x[0], x[1]]) for x in answers])
|
||||
|
||||
|
||||
def main():
|
||||
if not os.path.exists("/tmp/yunohost_official_apps_list.json"):
|
||||
urlretrieve("https://app.yunohost.org/official.json", "/tmp/yunohost_official_apps_list.json")
|
||||
|
||||
app_list = json.load(open("/tmp/yunohost_official_apps_list.json"))
|
||||
|
||||
for name, data in sorted(app_list.items(), key=lambda x: x[0]):
|
||||
print "%s:" % name, default_arguments_for_app(data)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
15
sub_scripts/ci/maniackc.py
Executable file
15
sub_scripts/ci/maniackc.py
Executable file
|
@ -0,0 +1,15 @@
|
|||
# Merci a Bram pour ce code python.
|
||||
# https://github.com/YunoHost/ci
|
||||
|
||||
import sys
|
||||
import json
|
||||
|
||||
from default_args import argument_for_question
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
manifest_path = sys.argv[1:][0]
|
||||
manifest = json.load(open(manifest_path, "r"))
|
||||
|
||||
for question in manifest["arguments"]["install"]:
|
||||
print ":".join(argument_for_question(question, all_choices=True))
|
|
@ -703,15 +703,12 @@ PACKAGE_LINTER () {
|
|||
ECHO_FORMAT "\n\n>> Package linter... [Test $cur_test/$all_test]\n" "white" "bold" clog
|
||||
cur_test=$((cur_test+1))
|
||||
"$script_dir/package_linter/package_linter.py" "$APP_CHECK" | tee "$script_dir/package_linter.log" # Effectue un test du package avec package_linter
|
||||
while read LIGNE
|
||||
do
|
||||
if echo "$LIGNE" | grep -q ">>>> "; then # Prend le header de la section
|
||||
if grep -q ">>>> " "$script_dir/package_linter.log"; then
|
||||
GLOBAL_LINTER=1 # Si au moins 1 header est trouvé, c'est que l'exécution s'est bien déroulée.
|
||||
fi
|
||||
if echo "$LIGNE" | grep -q -F "[91m"; then # Si une erreur a été détectée par package_linter.
|
||||
if grep -q -F "[91m" "$script_dir/package_linter.log"; then # Si une erreur a été détectée par package_linter.
|
||||
GLOBAL_LINTER=-1 # Au moins une erreur a été détectée par package_linter
|
||||
fi
|
||||
done < "$script_dir/package_linter.log"
|
||||
tnote=$((tnote+1))
|
||||
if [ "$GLOBAL_LINTER" -eq 1 ]; then
|
||||
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
|
||||
|
|
Loading…
Add table
Reference in a new issue