2018-03-24 01:26:05 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
Update to version 0.9.5 with the last commit (#16)
* try to update source to 0.9.5
* try to update source to 0.9.5
* refactoring and try to update version
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try update garradin
* try the upgrade without php7.2
* try to debug
* try to debug
* try to debug
* try to debug
* add hooks to copy file config.dist.php in config.local.php with good options
* add hooks to copy file config.dist.php in config.local.php with good options
* try again to correct values
* try again to correct values
* try again to correct values
* change the upgrade file
* change the upgrade file
* try to backup sql for the upgrade
* try to save sqlite bdd since upgarade
* try to save sqlite bdd since upgarade
* try to save sqlite bdd since upgarade
* make the upgrade with backup of the bdd
* syntax error on file backup
* syntax error on file backup
* change the hook post_upgrade
* change the hook post_upgrade
* delete folder hooks and update the scripts install and upgrade
* correct url for backup file config.local.php
* correct url for backup files
* correct url for backup files
* delete the backup of config.local.php because this file must be edited with this upgrade
* delete the backup of config.local.php because this file must be edited with this upgrade
* change the script backup
* change the script backup
* add a missing bracket in script restore
* prepare package_check
* prepare package_check
* delete php.ini not used and add the values (commented) on php_fpm.conf
* delete sudo for bash commands
* remove file script jenkins
* syntax error
* try ro change PATH nginx.conf
* the garrdin must be insstalled on a sub-domain, back to put the correct path
* try to delete slash at the end of PATH in nginx.conf
* change path_url in config.local.php for sripts install and upgrade
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* try to debug upgrade
* error syntax
* chnage the code in upgrade to look for exist or not file association.bdd
* try to debug update script conditions
* try change install and update to debug scripts
* try to debug update script conditions
* try to debug update script conditions
* try to debug update script conditions
* check_url available for check_package
* try to make better check_packages dependencies
* try to make better check_packages dependencies
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* come back to precedent config por nginx
* just a test to watch if it is possible like this install on root path
* come back to this code, have not found how to install on root path with this version
* but back check_up as origin
* add a search for nginx.conf
* try change nginx.conf and how to add a line on config.local.php
* try change nginx.conf and how to add a line on config.local.php
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* change install
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* success, change check_path
* few change to delete blanks
* delete sudo not need on install
* comment ynh_delete_file_checksum in common.sh
* delete ynh_delete_file_checksum in common.sh
* delete sudo on upgrade, no need
* put condition in install and update for config.local.php
* put condition in install and update for config.local.php
* try to save secret key if exist on update
* try to save secret key if exist on update
* try to save secret key if exist on update
* try to save secret key if exist on update
* try to keep secret key script on install
* back to previous version
* try to keep secret key script on install
* try to keep secret key script on install
* try create secret key script on install
* create secret key script on install
* put same lenght for secret key then the example in config.dist.php script for install
* try to debug slash for root directory in install and upgrade
* try to debug slash for root directory in cahnge_url
* try to debug slash for root directory in change_url
* try to debug slash for root directory in change_url
* try to put clean upgrade script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* change manifest
* change url debug
* change Readme
* change url debug
* change url debug
* add a line in config.local.php for domain in change_url script
* add a line in config.local.php for domain in change_url script
* add a line in config.local.php for domain in change_url script
* add a lines for doamin in config.local.php in change_url install and upgrade script
* comme back to previous version
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* remove file_checksum md5 not needed
* cleaning syntax
2020-04-11 13:02:18 +02:00
|
|
|
#=================================================
|
|
|
|
# COMMON VARIABLES
|
|
|
|
#=================================================
|
|
|
|
# dependencies used by the app
|
2021-04-17 23:44:09 +02:00
|
|
|
#pkg_dependencies="imagemagick"
|
|
|
|
|
2021-04-17 18:01:12 +02:00
|
|
|
YNH_PHP_VERSION="7.4"
|
Update to version 0.9.5 with the last commit (#16)
* try to update source to 0.9.5
* try to update source to 0.9.5
* refactoring and try to update version
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try to debug
* try update garradin
* try the upgrade without php7.2
* try to debug
* try to debug
* try to debug
* try to debug
* add hooks to copy file config.dist.php in config.local.php with good options
* add hooks to copy file config.dist.php in config.local.php with good options
* try again to correct values
* try again to correct values
* try again to correct values
* change the upgrade file
* change the upgrade file
* try to backup sql for the upgrade
* try to save sqlite bdd since upgarade
* try to save sqlite bdd since upgarade
* try to save sqlite bdd since upgarade
* make the upgrade with backup of the bdd
* syntax error on file backup
* syntax error on file backup
* change the hook post_upgrade
* change the hook post_upgrade
* delete folder hooks and update the scripts install and upgrade
* correct url for backup file config.local.php
* correct url for backup files
* correct url for backup files
* delete the backup of config.local.php because this file must be edited with this upgrade
* delete the backup of config.local.php because this file must be edited with this upgrade
* change the script backup
* change the script backup
* add a missing bracket in script restore
* prepare package_check
* prepare package_check
* delete php.ini not used and add the values (commented) on php_fpm.conf
* delete sudo for bash commands
* remove file script jenkins
* syntax error
* try ro change PATH nginx.conf
* the garrdin must be insstalled on a sub-domain, back to put the correct path
* try to delete slash at the end of PATH in nginx.conf
* change path_url in config.local.php for sripts install and upgrade
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* change also the path for change_url
* try to debug upgrade
* error syntax
* chnage the code in upgrade to look for exist or not file association.bdd
* try to debug update script conditions
* try change install and update to debug scripts
* try to debug update script conditions
* try to debug update script conditions
* try to debug update script conditions
* check_url available for check_package
* try to make better check_packages dependencies
* try to make better check_packages dependencies
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* try to make possible install on root path and change url from or to root path
* come back to precedent config por nginx
* just a test to watch if it is possible like this install on root path
* come back to this code, have not found how to install on root path with this version
* but back check_up as origin
* add a search for nginx.conf
* try change nginx.conf and how to add a line on config.local.php
* try change nginx.conf and how to add a line on config.local.php
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* change install
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* try change nginx.conf
* success, change check_path
* few change to delete blanks
* delete sudo not need on install
* comment ynh_delete_file_checksum in common.sh
* delete ynh_delete_file_checksum in common.sh
* delete sudo on upgrade, no need
* put condition in install and update for config.local.php
* put condition in install and update for config.local.php
* try to save secret key if exist on update
* try to save secret key if exist on update
* try to save secret key if exist on update
* try to save secret key if exist on update
* try to keep secret key script on install
* back to previous version
* try to keep secret key script on install
* try to keep secret key script on install
* try create secret key script on install
* create secret key script on install
* put same lenght for secret key then the example in config.dist.php script for install
* try to debug slash for root directory in install and upgrade
* try to debug slash for root directory in cahnge_url
* try to debug slash for root directory in change_url
* try to debug slash for root directory in change_url
* try to put clean upgrade script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* try to debug change_url script
* change manifest
* change url debug
* change Readme
* change url debug
* change url debug
* add a line in config.local.php for domain in change_url script
* add a line in config.local.php for domain in change_url script
* add a line in config.local.php for domain in change_url script
* add a lines for doamin in config.local.php in change_url install and upgrade script
* comme back to previous version
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* sripts modified, try to resolve change url
* remove file_checksum md5 not needed
* cleaning syntax
2020-04-11 13:02:18 +02:00
|
|
|
|
2021-04-22 16:30:20 +02:00
|
|
|
extra_php_dependencies="php${YNH_PHP_VERSION}-sqlite3 php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-cli"
|
2020-06-17 18:44:53 +02:00
|
|
|
|
2020-07-14 12:56:01 +02:00
|
|
|
#=================================================
|
|
|
|
# PERSONAL HELPERS
|
|
|
|
#=================================================
|
2020-06-17 18:44:53 +02:00
|
|
|
|
2020-09-24 23:40:05 +02:00
|
|
|
#=================================================
|
|
|
|
# EXPERIMENTAL HELPERS
|
|
|
|
#=================================================
|
2021-04-17 18:01:12 +02:00
|
|
|
# Install another version of php.
|
|
|
|
#
|
|
|
|
# usage: ynh_install_php --phpversion=phpversion [--package=packages]
|
|
|
|
# | arg: -v, --phpversion - Version of php to install.
|
|
|
|
# | arg: -p, --package - Additionnal php packages to install
|
|
|
|
ynh_install_php () {
|
|
|
|
# Declare an array to define the options of this helper.
|
|
|
|
local legacy_args=vp
|
|
|
|
declare -Ar args_array=( [v]=phpversion= [p]=package= )
|
|
|
|
local phpversion
|
|
|
|
local package
|
|
|
|
# Manage arguments with getopts
|
|
|
|
ynh_handle_getopts_args "$@"
|
|
|
|
package=${package:-}
|
2020-06-17 18:44:53 +02:00
|
|
|
|
2021-04-17 18:01:12 +02:00
|
|
|
# Store phpversion into the config of this app
|
|
|
|
ynh_app_setting_set $app phpversion $phpversion
|
|
|
|
|
|
|
|
if [ "$phpversion" == "7.3" ]
|
|
|
|
then
|
|
|
|
ynh_die "Do not use ynh_install_php to install php7.3"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Store the ID of this app and the version of php requested for it
|
|
|
|
echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version"
|
|
|
|
# Add an extra repository for those packages
|
|
|
|
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version
|
|
|
|
|
|
|
|
# Install requested dependencies from this extra repository.
|
|
|
|
# Install php-fpm first, otherwise php will install apache as a dependency.
|
|
|
|
ynh_add_app_dependencies --package="php${phpversion}-fpm"
|
|
|
|
ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package"
|
|
|
|
|
|
|
|
# Set php7.3 back as the default version for php-cli.
|
|
|
|
update-alternatives --set php /usr/bin/php7.3
|
|
|
|
|
|
|
|
# Pin this extra repository after packages are installed to prevent sury of doing shit
|
|
|
|
ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version
|
|
|
|
ynh_pin_repo --package="php7.3*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append
|
|
|
|
# Advertise service in admin panel
|
|
|
|
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
|
|
|
|
}
|
|
|
|
# Remove the specific version of php used by the app.
|
|
|
|
#
|
|
|
|
# usage: ynh_install_php
|
|
|
|
ynh_remove_php () {
|
|
|
|
# Get the version of php used by this app
|
|
|
|
local phpversion=$(ynh_app_setting_get $app phpversion)
|
|
|
|
if [ "$phpversion" == "7.3" ] || [ -z "$phpversion" ]
|
|
|
|
then
|
|
|
|
if [ "$phpversion" == "7.3" ]
|
|
|
|
then
|
|
|
|
ynh_print_err "Do not use ynh_remove_php to install php7.3"
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
# Remove the line for this app
|
|
|
|
sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version"
|
|
|
|
# If no other app uses this version of php, remove it.
|
|
|
|
if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version"
|
|
|
|
then
|
|
|
|
# Purge php dependences for this version.
|
|
|
|
ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common"
|
|
|
|
# Remove the service from the admin panel
|
|
|
|
yunohost service remove php${phpversion}-fpm
|
|
|
|
fi
|
|
|
|
# If no other app uses alternate php versions, remove the extra repo for php
|
|
|
|
if [ ! -s "/etc/php/ynh_app_version" ]
|
|
|
|
then
|
|
|
|
ynh_secure_remove /etc/php/ynh_app_version
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
#=================================================
|
|
|
|
# FUTURE OFFICIAL HELPERS
|
|
|
|
#=================================================
|
|
|
|
# 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}"
|
|
|
|
}
|
2020-09-24 23:40:05 +02:00
|
|
|
#=================================================
|
|
|
|
# FUTURE OFFICIAL HELPERS
|
2020-07-14 12:56:01 +02:00
|
|
|
#=================================================
|
2020-10-04 18:24:52 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# FUTURE OFFICIAL HELPERS
|
|
|
|
#=================================================
|