Merge pull request #1717 from Salamandar/helpers

Create versionned directories of the helpers
This commit is contained in:
Alexandre Aubin 2024-05-27 16:49:05 +02:00 committed by GitHub
commit c1b3c3f785
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 35 additions and 11 deletions

2
debian/install vendored
View file

@ -1,7 +1,7 @@
bin/* /usr/bin/
share/* /usr/share/yunohost/
hooks/* /usr/share/yunohost/hooks/
helpers/* /usr/share/yunohost/helpers.d/
helpers/* /usr/share/yunohost/
conf/* /usr/share/yunohost/conf/
locales/* /usr/share/yunohost/locales/
doc/yunohost.8.gz /usr/share/man/man8/

31
helpers/helpers Normal file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Entrypoint for the helpers scripts
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [[ -n "${1:-}" ]]; then
# helpers version can be passed as first when sourcing.
YNH_HELPERS_VERSION="$1"
else
# ...or as environment variable set from manifest
# ...or default to 1
YNH_HELPERS_VERSION=${YNH_HELPERS_VERSION:-1}
fi
# This is a trick to later only restore set -x if it was set when calling this script
readonly XTRACE_ENABLE=$(set +o | grep xtrace)
set +x
YNH_HELPERS_DIR="$SCRIPT_DIR/helpers.v${YNH_HELPERS_VERSION}.d"
case "$YNH_HELPERS_VERSION" in
1)
readarray -t HELPERS < <(find "$YNH_HELPERS_DIR" -mindepth 1 -maxdepth 1 -type f)
for helper in "${HELPERS[@]}"; do
[ -r "$helper" ] && source "$helper"
done
;;
*)
echo "Helpers are not available in version '$YNH_HELPERS_VERSION'." >&2
exit 1
esac
eval "$XTRACE_ENABLE"

View file

@ -115,7 +115,7 @@ ynh_install_nodejs() {
# Install (or update if YunoHost vendor/ folder updated since last install) n
mkdir -p $n_install_dir/bin/
cp /usr/share/yunohost/helpers.d/vendor/n/n $n_install_dir/bin/n
cp "$YNH_HELPERS_DIR/vendor/n/n" $n_install_dir/bin/n
# Tweak for n to understand it's installed in $N_PREFIX
ynh_replace_string --match_string="^N_PREFIX=\${N_PREFIX-.*}$" --replace_string="N_PREFIX=\${N_PREFIX-$N_PREFIX}" --target_file="$n_install_dir/bin/n"

View file

@ -318,7 +318,7 @@ ynh_setup_source() {
mv $src_filename $dest_dir/$src_rename
fi
elif [[ "$src_format" == "docker" ]]; then
/usr/share/yunohost/helpers.d/vendor/docker-image-extract/docker-image-extract -p $src_platform -o $dest_dir $src_url 2>&1
"$YNH_HELPERS_DIR/vendor/docker-image-extract/docker-image-extract" -p $src_platform -o $dest_dir $src_url 2>&1
elif [[ "$src_format" == "zip" ]]; then
# Zip format
# Using of a temp directory, because unzip doesn't manage --strip-components

View file

@ -1,8 +0,0 @@
# -*- shell-script -*-
readonly XTRACE_ENABLE=$(set +o | grep xtrace) # This is a trick to later only restore set -x if it was set when calling this script
set +x
for helper in $(run-parts --list /usr/share/yunohost/helpers.d 2>/dev/null) ; do
[ -r $helper ] && . $helper || true
done
eval "$XTRACE_ENABLE"

View file

@ -2968,6 +2968,7 @@ def _make_environment_for_app_script(
"YNH_APP_INSTANCE_NUMBER": str(app_instance_nb),
"YNH_APP_MANIFEST_VERSION": manifest.get("version", "?"),
"YNH_APP_PACKAGING_FORMAT": str(manifest["packaging_format"]),
"YNH_HELPERS_VERSION": manifest.get("integration", {}).get("helpers_version") or manifest["packaging_format"],
"YNH_ARCH": system_arch(),
"YNH_DEBIAN_VERSION": debian_version(),
}