mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #1717 from Salamandar/helpers
Create versionned directories of the helpers
This commit is contained in:
commit
c1b3c3f785
36 changed files with 35 additions and 11 deletions
2
debian/install
vendored
2
debian/install
vendored
|
@ -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/
|
||||||
|
|
31
helpers/helpers
Normal file
31
helpers/helpers
Normal 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"
|
|
@ -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_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"
|
||||||
|
|
|
@ -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_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
|
|
@ -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"
|
|
|
@ -2968,6 +2968,7 @@ def _make_environment_for_app_script(
|
||||||
"YNH_APP_INSTANCE_NUMBER": str(app_instance_nb),
|
"YNH_APP_INSTANCE_NUMBER": str(app_instance_nb),
|
||||||
"YNH_APP_MANIFEST_VERSION": manifest.get("version", "?"),
|
"YNH_APP_MANIFEST_VERSION": manifest.get("version", "?"),
|
||||||
"YNH_APP_PACKAGING_FORMAT": str(manifest["packaging_format"]),
|
"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_ARCH": system_arch(),
|
||||||
"YNH_DEBIAN_VERSION": debian_version(),
|
"YNH_DEBIAN_VERSION": debian_version(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue