Skip to content

Commit

Permalink
Merge pull request #1717 from Salamandar/helpers
Browse files Browse the repository at this point in the history
Create versionned directories of the helpers
  • Loading branch information
alexAubin authored May 27, 2024
2 parents 6aa9d05 + 1e47a14 commit c1b3c3f
Show file tree
Hide file tree
Showing 36 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion debian/install
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
31 changes: 31 additions & 0 deletions helpers/helpers
Original file line number Diff line number Diff line change
@@ -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"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion helpers/nodejs → helpers/helpers.v1.d/nodejs
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion helpers/utils → helpers/helpers.v1.d/utils
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions share/helpers

This file was deleted.

1 change: 1 addition & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down

0 comments on commit c1b3c3f

Please sign in to comment.