From ce04570bfda75291a06727d1607641c13fcdfbfa Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 12 Mar 2021 23:18:16 +0100 Subject: [PATCH] helpers: Simplify manifest path / parsing --- data/helpers.d/apt | 9 +++------ data/helpers.d/utils | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/data/helpers.d/apt b/data/helpers.d/apt index bfdeffe7b..f0c650ace 100644 --- a/data/helpers.d/apt +++ b/data/helpers.d/apt @@ -224,13 +224,10 @@ ynh_install_app_dependencies () { # Add a comma for each space between packages. But not add a comma if the space separate a version specification. (See below) dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" local dependencies=${dependencies//|/ | } - local manifest_path="../manifest.json" - if [ ! -e "$manifest_path" ]; then - manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi + local manifest_path="$YNH_APP_BASEDIR/manifest.json" - local version=$(grep '\"version\": ' "$manifest_path" | cut --delimiter='"' --fields=4) # Retrieve the version number in the manifest file. - if [ ${#version} -eq 0 ]; then + local version=$(jq -r '.version' "$manifest_path") + if [ -z "${version}" ] || [ "$version" == "null" ]; then version="1.0" fi local dep_app=${app//_/-} # Replace all '_' by '-' diff --git a/data/helpers.d/utils b/data/helpers.d/utils index 8246b9986..c5ebdcb96 100644 --- a/data/helpers.d/utils +++ b/data/helpers.d/utils @@ -553,7 +553,7 @@ ynh_read_manifest () { if [ ! -e "$manifest" ]; then # If the manifest isn't found, try the common place for backup and restore script. - manifest="../settings/manifest.json" + manifest="$YNH_APP_BASEDIR/manifest.json" fi jq ".$manifest_key" "$manifest" --raw-output