diff --git a/helpers/apt b/helpers/apt index 5ddcba381..8807b8229 100644 --- a/helpers/apt +++ b/helpers/apt @@ -327,6 +327,59 @@ EOF } +# Define and install dependencies with a equivs control file, for the app build +# +# This helper can/should only be called once per app +# +# example : ynh_install_app_build_dependencies dep1 dep2 "dep3|dep4|dep5" +# +# usage: ynh_install_app_build_dependencies dep [dep [...]] +# | arg: dep - the package name to install in dependence. +# | arg: "dep1|dep2|…" - You can specify alternatives. It will require to install (dep1 or dep2, etc). +# +# Requires YunoHost version 4.3.6.4 or higher. +ynh_install_app_build_dependencies() { + local 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="$YNH_APP_BASEDIR/manifest.json" + + local version=$(jq -r '.version' "$manifest_path") + if [ -z "${version}" ] || [ "$version" == "null" ]; then + version="1.0" + fi + local dep_app=${app//_/-} # Replace all '_' by '-' + + # Handle specific versions + if [[ "$dependencies" =~ [\<=\>] ]]; then + # Replace version specifications by relationships syntax + # https://www.debian.org/doc/debian-policy/ch-relationships.html + # Sed clarification + # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. + # [\<=\>] matches < = or > + # \+ matches one or more occurence of the previous characters, for >= or >>. + # [^,]\+ matches all characters except ',' + # Ex: 'package>=1.0' will be replaced by 'package (>= 1.0)' + dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" + fi + + cat >/tmp/${dep_app}-ynh-build-deps.control <