1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wekan_ynh.git synced 2024-09-03 20:36:09 +02:00

Merge pull request #80 from YunoHost-Apps/testing

Testing
This commit is contained in:
yalh76 2020-03-23 18:31:24 +01:00 committed by GitHub
commit a196efb062
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 335 additions and 16 deletions

View file

@ -12,17 +12,17 @@
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 1.07~ynh2 # 1.07~ynh2
upgrade=1 from_commit=37d226544f2738bd37f97b612ff4798545b3dc5a # upgrade=1 from_commit=37d226544f2738bd37f97b612ff4798545b3dc5a
# 2.09~ynh1 # 2.09~ynh1
upgrade=1 from_commit=3105eb5a3c515ea55a38b8b80c9b5dda1277a82e # upgrade=1 from_commit=3105eb5a3c515ea55a38b8b80c9b5dda1277a82e
# 2.56~ynh2 # 2.56~ynh2
upgrade=1 from_commit=b26768aad2627da739677da740429591ffbb9a6e # upgrade=1 from_commit=b26768aad2627da739677da740429591ffbb9a6e
# 2.98~ynh2 # 2.98~ynh2
upgrade=1 from_commit=dab614bd7679f2f7978d1df2e360fba7ae0edfa4 # upgrade=1 from_commit=dab614bd7679f2f7978d1df2e360fba7ae0edfa4
# 3.45~ynh1 # 3.45~ynh1
upgrade=1 from_commit=2e6131af03c723cf9eaf82e13aa9488f42c085f9 # upgrade=1 from_commit=2e6131af03c723cf9eaf82e13aa9488f42c085f9
# 3.55~ynh1 # 3.55~ynh1
upgrade=1 from_commit=3be3f1d7290b534f7689222645a42c06f3103589 # upgrade=1 from_commit=3be3f1d7290b534f7689222645a42c06f3103589
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.

View file

@ -1,7 +1,7 @@
[Unit] [Unit]
Description=Wekan, task board Description=Wekan, task board
Wants=mongodb.service Wants=__MONGODB_SERVICENAME__.service
After=network.target mongodb.service After=network.target __MONGODB_SERVICENAME__.service
[Service] [Service]
Type=simple Type=simple

View file

@ -6,6 +6,9 @@
# dependencies used by the app # dependencies used by the app
pkg_dependencies="mongodb mongodb-server mongo-tools" pkg_dependencies="mongodb mongodb-server mongo-tools"
pkg_dependencies_buster="mongodb-org mongodb-org-server mongodb-org-tools"
mongodb_stretch="mongodb"
mongodb_buster="mongod"
nodejsversion=12.15.0 nodejsversion=12.15.0
#================================================= #=================================================

View file

@ -8,6 +8,7 @@
source _common.sh source _common.sh
source ynh_detect_arch__2 source ynh_detect_arch__2
source ynh_add_extra_apt_repos__3
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -78,7 +79,13 @@ ynh_print_info --message="Installing dependencies..."
ynh_install_nodejs --nodejs_version=$nodejsversion ynh_install_nodejs --nodejs_version=$nodejsversion
ynh_use_nodejs ynh_use_nodejs
ynh_install_app_dependencies $pkg_dependencies if [ "$(lsb_release --codename --short)" = "buster" ]; then
ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc"
mongodb_servicename=$mongodb_buster
else
ynh_install_app_dependencies $pkg_dependencies
mongodb_servicename=$mongodb_stretch
fi
#================================================= #=================================================
# CREATE A MONGODB DATABASE # CREATE A MONGODB DATABASE
@ -86,8 +93,8 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_print_info --message="Creating a MongoDB database..." ynh_print_info --message="Creating a MongoDB database..."
# Start mongodb # Start mongodb
systemctl enable mongodb systemctl enable $mongodb_servicename
systemctl start mongodb systemctl start $mongodb_servicename
# Registering db name # Registering db name
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
@ -127,6 +134,7 @@ ynh_print_info --message="Configuring a systemd service..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__MONGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service"
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================

View file

@ -7,7 +7,7 @@
#================================================= #=================================================
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_systemd_action source ../settings/scripts/ynh_add_extra_apt_repos__3
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -87,7 +87,13 @@ ynh_print_info --message="Reinstalling dependencies..."
ynh_install_nodejs --nodejs_version=$nodejsversion ynh_install_nodejs --nodejs_version=$nodejsversion
ynh_use_nodejs ynh_use_nodejs
ynh_install_app_dependencies $pkg_dependencies if [ "$(lsb_release --codename --short)" = "buster" ]; then
ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc"
mongodb_servicename=$mongodb_buster
else
ynh_install_app_dependencies $pkg_dependencies
mongodb_servicename=$mongodb_stretch
fi
#================================================= #=================================================
# RESTORE THE MONGODB DATABASE # RESTORE THE MONGODB DATABASE
@ -95,8 +101,8 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_print_info --message="Restoring the MongoDB database..." ynh_print_info --message="Restoring the MongoDB database..."
# Start mongodb # Start mongodb
systemctl enable mongodb systemctl enable $mongodb_servicename
systemctl start mongodb systemctl start $mongodb_servicename
mongorestore --db $db_name ./dump/$db_name mongorestore --db $db_name ./dump/$db_name
#================================================= #=================================================

View file

@ -7,6 +7,7 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_add_extra_apt_repos__3
source ynh_package_version source ynh_package_version
source ynh_detect_arch__2 source ynh_detect_arch__2
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -163,7 +164,13 @@ ynh_remove_nodejs
ynh_install_nodejs --nodejs_version=$nodejsversion ynh_install_nodejs --nodejs_version=$nodejsversion
ynh_use_nodejs ynh_use_nodejs
ynh_install_app_dependencies $pkg_dependencies if [ "$(lsb_release --codename --short)" = "buster" ]; then
ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc"
mongodb_servicename=$mongodb_buster
else
ynh_install_app_dependencies $pkg_dependencies
mongodb_servicename=$mongodb_stretch
fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -196,6 +203,7 @@ ynh_print_info --message="Upgrading systemd configuration..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__MONGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service"
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================

View file

@ -0,0 +1,294 @@
#!/bin/bash
# Pin a repository.
#
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
# | arg: -i, --pin - Filter for the pin.
# | arg: -p, --priority - Priority for the pin
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
#
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
#
ynh_pin_repo () {
# Declare an array to define the options of this helper.
local legacy_args=pirna
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
local package
local pin
local priority
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
package="${package:-*}"
priority=${priority:-50}
name="${name:-$app}"
append=${append:-0}
if [ $append -eq 1 ]
then
append="tee -a"
else
append="tee"
fi
mkdir -p "/etc/apt/preferences.d"
echo "Package: $package
Pin: $pin
Pin-Priority: $priority" \
| $append "/etc/apt/preferences.d/$name"
}
# Add a repository.
#
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
# | arg: -u, --uri - Uri of the repository.
# | arg: -s, --suite - Suite of the repository.
# | arg: -c, --component - Component of the repository.
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
#
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
# uri suite component
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
#
ynh_add_repo () {
# Declare an array to define the options of this helper.
local legacy_args=uscna
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
local uri
local suite
local component
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
append=${append:-0}
if [ $append -eq 1 ]
then
append="tee -a"
else
append="tee"
fi
mkdir -p "/etc/apt/sources.list.d"
# Add the new repo in sources.list.d
echo "deb $uri $suite $component" \
| $append "/etc/apt/sources.list.d/$name.list"
}
# Add an extra repository correctly, pin it and get the key.
#
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
# | arg: -r, --repo - Complete url of the extra repository.
# | arg: -k, --key - url to get the public key.
# | arg: -p, --priority - Priority for the pin
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
ynh_install_extra_repo () {
# Declare an array to define the options of this helper.
local legacy_args=rkpna
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
local repo
local key
local priority
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
append=${append:-0}
key=${key:-0}
priority=${priority:-}
if [ $append -eq 1 ]
then
append="--append"
wget_append="tee -a"
else
append=""
wget_append="tee"
fi
# Split the repository into uri, suite and components.
# Remove "deb " at the beginning of the repo.
repo="${repo#deb }"
# Get the uri
local uri="$(echo "$repo" | awk '{ print $1 }')"
# Get the suite
local suite="$(echo "$repo" | awk '{ print $2 }')"
# Get the components
local component="${repo##$uri $suite }"
# Add the repository into sources.list.d
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
# Pin the new repo with the default priority, so it won't be used for upgrades.
# Build $pin from the uri without http and any sub path
local pin="${uri#*://}"
pin="${pin%%/*}"
# Set a priority only if asked
if [ -n "$priority" ]
then
priority="--priority=$priority"
fi
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
# Get the public key for the repo
if [ -n "$key" ]
then
mkdir -p "/etc/apt/trusted.gpg.d"
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
fi
# Update the list of package with the new repo
ynh_package_update
}
# Remove an extra repository and the assiociated configuration.
#
# usage: ynh_remove_extra_repo [--name=name]
# | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_remove_extra_repo () {
# Declare an array to define the options of this helper.
local legacy_args=n
declare -Ar args_array=( [n]=name= )
local name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
ynh_secure_remove "/etc/apt/preferences.d/$name"
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
# Update the list of package to exclude the old repo
ynh_package_update
}
# Install packages from an extra repository properly.
#
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
# | arg: -r, --repo - Complete url of the extra repository.
# | arg: -p, --package - The packages to install from this extra repository
# | arg: -k, --key - url to get the public key.
# | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_install_extra_app_dependencies () {
# Declare an array to define the options of this helper.
local legacy_args=rpkn
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
local repo
local package
local key
local name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
key=${key:-0}
# Set a key only if asked
if [ -n "$key" ]
then
key="--key=$key"
fi
# Add an extra repository for those packages
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
# Install requested dependencies from this extra repository.
ynh_add_app_dependencies --package="$package"
# Remove this extra repository after packages are installed
ynh_remove_extra_repo --name=$app
}
#=================================================
# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies
# Define and install dependencies with a equivs control file
# This helper can/should only be called once per app
#
# usage: ynh_install_app_dependencies dep [dep [...]]
# | arg: dep - the package name to install in dependence
# You can give a choice between some package with this syntax : "dep1|dep2"
# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5)
#
# Requires YunoHost version 2.6.4 or higher.
ynh_install_app_dependencies () {
local dependencies=$@
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
dependencies=${dependencies//|/ | }
local 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
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
if [ ${#version} -eq 0 ]; then
version="1.0"
fi
local dep_app=${app//_/-} # Replace all '_' by '-'
# Handle specific versions
if [[ "$dependencies" =~ [\<=\>] ]]
then
# Replace version specifications by relationships syntax
# https://www.debian.org/doc/debian-policy/ch-relationships.html
# Sed clarification
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
# [\<=\>] matches < = or >
# \+ matches one or more occurence of the previous characters, for >= or >>.
# [^,]\+ matches all characters except ','
# Ex: package>=1.0 will be replaced by package (>= 1.0)
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
fi
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
Section: misc
Priority: optional
Package: ${dep_app}-ynh-deps
Version: ${version}
Depends: ${dependencies}
Architecture: all
Description: Fake package for $app (YunoHost app) dependencies
This meta-package is only responsible of installing its dependencies.
EOF
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
rm /tmp/${dep_app}-ynh-deps.control
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
}
ynh_add_app_dependencies () {
# Declare an array to define the options of this helper.
local legacy_args=pr
declare -Ar args_array=( [p]=package= [r]=replace)
local package
local replace
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
replace=${replace:-0}
local current_dependencies=""
if [ $replace -eq 0 ]
then
local dep_app=${app//_/-} # Replace all '_' by '-'
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
then
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
fi
current_dependencies=${current_dependencies// | /|}
fi
ynh_install_app_dependencies "${current_dependencies}${package}"
}