Create versionned directories of the helpers

This commit is contained in:
Salamandar 2023-09-28 17:31:55 +02:00
parent 6aa9d05372
commit a2bc8c4f38
35 changed files with 41 additions and 11 deletions

2
debian/install vendored
View file

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

38
helpers/helpers Normal file
View file

@ -0,0 +1,38 @@
#!/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_APP_HELPERS_VERSION="$1"
elif [[ -n "${YNH_APP_HELPERS_VERSION:-}" ]]; then
# ...or as environment variable set from manifest
:
elif [[ -n "${YNH_APP_PACKAGING_FORMAT:-}" ]]; then
# ...or default to packaging format version.
YNH_APP_HELPERS_VERSION="$YNH_APP_PACKAGING_FORMAT"
else
# ...or default to 1
YNH_APP_HELPERS_VERSION=1
fi
YNH_APP_HELPERS_DIR="$SCRIPT_DIR/helpers.v${YNH_APP_HELPERS_VERSION}.d"
if [[ ! -d "$YNH_APP_HELPERS_DIR" ]]; then
echo "Helpers are not available in version '$YNH_APP_HELPERS_VERSION'." >&2
exit 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
readarray -t HELPERS < <(find "$YNH_APP_HELPERS_DIR" -mindepth 1 -maxdepth 1 -type f)
for helper in "${HELPERS[@]}"; do
[ -r "$helper" ] && source "$helper"
done
eval "$XTRACE_ENABLE"

View file

@ -115,7 +115,7 @@ ynh_install_nodejs() {
# Install (or update if YunoHost vendor/ folder updated since last install) n # Install (or update if YunoHost vendor/ folder updated since last install) n
mkdir -p $n_install_dir/bin/ mkdir -p $n_install_dir/bin/
cp /usr/share/yunohost/helpers.d/vendor/n/n $n_install_dir/bin/n cp "$YNH_APP_HELPERS_DIR/vendor/n/n" $n_install_dir/bin/n
# Tweak for n to understand it's installed in $N_PREFIX # 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" 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 mv $src_filename $dest_dir/$src_rename
fi fi
elif [[ "$src_format" == "docker" ]]; then 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_APP_HELPERS_DIR/vendor/docker-image-extract/docker-image-extract" -p $src_platform -o $dest_dir $src_url 2>&1
elif [[ "$src_format" == "zip" ]]; then elif [[ "$src_format" == "zip" ]]; then
# Zip format # Zip format
# Using of a temp directory, because unzip doesn't manage --strip-components # 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"