2019-04-21 15:32:30 +02:00
|
|
|
|
2017-06-09 14:03:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
2019-04-21 15:32:30 +02:00
|
|
|
# COMMON VARIABLES
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
|
|
|
|
2019-04-21 15:32:30 +02:00
|
|
|
# dependencies used by the app
|
2019-10-22 17:52:18 +02:00
|
|
|
pkg_dependencies="build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libluajit-5.1-dev"
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
2019-04-21 15:32:30 +02:00
|
|
|
# PERSONAL HELPERS
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
|
|
|
|
2019-10-26 22:42:12 +02:00
|
|
|
# To remove once https://github.com/YunoHost/yunohost/pull/827 get merged
|
|
|
|
ynh_find_port () {
|
|
|
|
# Declare an array to define the options of this helper.
|
|
|
|
local legacy_args=p
|
|
|
|
declare -Ar args_array=( [p]=port= )
|
|
|
|
local port
|
|
|
|
# Manage arguments with getopts
|
|
|
|
ynh_handle_getopts_args "$@"
|
|
|
|
|
|
|
|
test -n "$port" || ynh_die --message="The argument of ynh_find_port must be a valid port."
|
|
|
|
while ss -nltu | grep -q -w :$port # Check if the port is free
|
|
|
|
do
|
|
|
|
port=$((port+1)) # Else, pass to next port
|
|
|
|
done
|
|
|
|
echo $port
|
|
|
|
}
|
|
|
|
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
2019-04-21 15:32:30 +02:00
|
|
|
# EXPERIMENTAL HELPERS
|
2017-06-09 14:03:32 +02:00
|
|
|
#=================================================
|
|
|
|
|
2019-10-23 18:15:07 +02:00
|
|
|
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
|
|
|
|
|
|
|
|
# Read the value of a key in a ynh manifest file
|
|
|
|
#
|
|
|
|
# usage: ynh_read_manifest manifest key
|
|
|
|
# | arg: -m, --manifest= - Path of the manifest to read
|
|
|
|
# | arg: -k, --key= - Name of the key to find
|
|
|
|
ynh_read_manifest () {
|
|
|
|
# Declare an array to define the options of this helper.
|
|
|
|
declare -Ar args_array=( [m]=manifest= [k]=key= )
|
|
|
|
local manifest
|
|
|
|
local key
|
|
|
|
# Manage arguments with getopts
|
|
|
|
ynh_handle_getopts_args "$@"
|
|
|
|
|
|
|
|
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Read the upstream version from the manifest
|
|
|
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
|
|
|
# For example : 4.3-2~ynh3
|
|
|
|
# This include the number before ~ynh
|
|
|
|
# In the last example it return 4.3-2
|
|
|
|
#
|
|
|
|
# usage: ynh_app_upstream_version
|
|
|
|
ynh_app_upstream_version () {
|
|
|
|
manifest_path="../manifest.json"
|
|
|
|
if [ ! -e "$manifest_path" ]; then
|
|
|
|
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
|
|
|
fi
|
|
|
|
version_key=$(ynh_read_manifest --manifest="$manifest_path" --key="version")
|
|
|
|
echo "${version_key/~ynh*/}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Read package version from the manifest
|
|
|
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
|
|
|
# For example : 4.3-2~ynh3
|
|
|
|
# This include the number after ~ynh
|
|
|
|
# In the last example it return 3
|
|
|
|
#
|
|
|
|
# usage: ynh_app_package_version
|
|
|
|
ynh_app_package_version () {
|
|
|
|
manifest_path="../manifest.json"
|
|
|
|
if [ ! -e "$manifest_path" ]; then
|
|
|
|
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
|
|
|
fi
|
|
|
|
version_key=$(ynh_read_manifest --manifest="$manifest_path" --key="version")
|
|
|
|
echo "${version_key/*~ynh/}"
|
|
|
|
}
|
2017-06-09 14:03:32 +02:00
|
|
|
|
2019-04-21 15:32:30 +02:00
|
|
|
#=================================================
|
|
|
|
# FUTURE OFFICIAL HELPERS
|
|
|
|
#=================================================
|
2019-08-15 14:21:00 +02:00
|
|
|
|