1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/firefly-iii_ynh.git synced 2024-09-03 18:36:13 +02:00

Merge pull request #15 from dr41nU/master

Version 5.0.5 bump
This commit is contained in:
James Cole 2020-02-25 05:13:31 +00:00 committed by GitHub
commit c85a617f3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 597 additions and 62 deletions

View file

@ -1,13 +1,13 @@
<p align="center"><img src="https://firefly-iii.org/static/img/logo-small-new.png"></p>
# Firefly III v4.7.17 for YunoHost
# Firefly III v5.0.5 for YunoHost
[![Integration level](https://dash.yunohost.org/integration/Firefly-III.svg)](https://ci-apps.yunohost.org/jenkins/job/firefly-iii%20%28Community%29/lastBuild/consoleFull)
[![Install Firefly III with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=firefly-iii)<br><br>
*Please note that this app will install PHP 7.2*
*Please note that this app will install PHP 7.3*
## Introduction
"Firefly III" is a (self-hosted) manager for your personal finances. It can help you keep track of your expenses and income, so you can spend less and save more. Firefly III supports the use of budgets, categories and tags. It can import data from external sources and it has many neat financial reports available. You can [read all about it in the main repository](https://github.com/firefly-iii/firefly-iii) and in the [official documentation](https://firefly-iii.readthedocs.io/en/latest/).
@ -69,11 +69,8 @@ Everything is organised:
### Installation on YunoHost
- Firefly III requires a **dedicated (sub)domain** (must install under web root like **https://firefly.example.com/** not **https://example.com/firefly/** )
#### Register a new domain and add it to YunoHost
Firefly III requires a dedicated (sub)domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Firefly III uses the full domain and is installed on the root, you can create a subdomain such as firefly.domain.tld. Don't forget to update your DNS if you manage them manually.
- Tested under a subdirectory on an existing domain
- Tested on amd64 and arm64 arches
#### Install the Firefly III application
@ -89,5 +86,11 @@ Or use the command line to install the Firefly III app:
$ yunohost app install https://github.com/YunoHost-Apps/firefly-iii_ynh
```
- The admin user should be a registered YunoHost user.
- Important: when the installation is complete, you will have to visit the domain on which the app is installed and register the first account with the **primary email address of the Admin user given at the time of installayion** (otherwise you will not get admin rights). The registration will lock itself after the first registration.
- The admin user should be the first user to log into firefly
- SSO is not working yet
- You will probably be warned about missing locale from your system. Once you change the language to those corresponding to your system, the warning will desapear
TODO
- [ ] make firefly admin user dependant of the user choosen at installation
- [ ] Make SSO Working
- [ ] Define default language accordingly to system one

View file

@ -19,7 +19,7 @@ TZ=UTC
# This variable must match your installation's external address but keep in mind that
# it's only used on the command line as a fallback value.
APP_URL=http://localhost
APP_URL=https://yunoappurl
# TRUSTED_PROXIES is a useful variable when using Docker and/or a reverse proxy.
TRUSTED_PROXIES=
@ -109,7 +109,7 @@ USE_ENCRYPTION=false
# and "adldap" for LDAP servers.
# For full instructions on these settings please visit:
# https://firefly-iii.readthedocs.io/en/latest/installation/authentication.html
LOGIN_PROVIDER=eloquent
LOGIN_PROVIDER=ldap
# LDAP connection configuration
# OpenLDAP, FreeIPA or ActiveDirectory
@ -117,10 +117,10 @@ ADLDAP_CONNECTION_SCHEME=OpenLDAP
ADLDAP_AUTO_CONNECT=true
# LDAP connection settings
ADLDAP_CONTROLLERS=
ADLDAP_CONTROLLERS=localhost
ADLDAP_PORT=389
ADLDAP_TIMEOUT=5
ADLDAP_BASEDN=""
ADLDAP_BASEDN="dc=yunohost,dc=org"
ADLDAP_FOLLOW_REFFERALS=false
ADLDAP_USE_SSL=false
ADLDAP_USE_TLS=false
@ -128,8 +128,8 @@ ADLDAP_USE_TLS=false
ADLDAP_ADMIN_USERNAME=
ADLDAP_ADMIN_PASSWORD=
ADLDAP_ACCOUNT_PREFIX=
ADLDAP_ACCOUNT_SUFFIX=
ADLDAP_ACCOUNT_PREFIX="uid="
ADLDAP_ACCOUNT_SUFFIX=",ou=users,dc=yunohost,dc=org"
ADLDAP_ADMIN_ACCOUNT_PREFIX=
ADLDAP_ADMIN_ACCOUNT_SUFFIX=
@ -137,15 +137,15 @@ ADLDAP_ADMIN_ACCOUNT_SUFFIX=
ADLDAP_PASSWORD_SYNC=false
ADLDAP_LOGIN_FALLBACK=false
ADLDAP_DISCOVER_FIELD=distinguishedname
ADLDAP_AUTH_FIELD=distinguishedname
ADLDAP_DISCOVER_FIELD=uid
ADLDAP_AUTH_FIELD=uid
# Will allow SSO if your server provides an AUTH_USER field.
WINDOWS_SSO_DISCOVER=samaccountname
WINDOWS_SSO_KEY=AUTH_USER
# field to sync as local username.
ADLDAP_SYNC_FIELD=userprincipalname
ADLDAP_SYNC_FIELD=uid
# Leave the following configuration vars as is.
# Unless you like to tinker and know what you're doing.

View file

@ -1,6 +1,6 @@
SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/4.7.17.tar.gz
SOURCE_SUM=f070089d89f2ac5f27c1c2adaadc911d0779533978226606c5f6d8d69cf5d1db
SOURCE_URL=https://github.com/firefly-iii/firefly-iii/archive/5.0.5.tar.gz
SOURCE_SUM=bb3c6ecbbc680c6ebbaab7439819a8c61a22b7911d21860c0d217bed655750c0
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_FILENAME=firefly-iii-5.0.5.tar.gz

View file

@ -1,26 +1,30 @@
location ^~ __PATH__ {
rewrite ^__PATH__$ __PATH__/ permanent;
location ^~ __PATH__/ {
alias __FINALPATH__/public/;
index index.php index.htm index.html;
index index.php;
# Force https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
try_files $uri $uri/ @firefly;
location ~ \.php {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php7.2-fpm-__NAME__.sock;
try_files $uri $uri/ /$uri /$uri/ @firefly;
fastcgi_index index.php;
location ~* \.php(?:$|/) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php7.3-fpm-__NAME__.sock;
fastcgi_param modHeadersAvailable true;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
include conf.d/yunohost_panel.conf.inc;
}
location @firefly {
rewrite /(.*)$ /index.php?/$1 last;
rewrite __PATH__/(.*)$ __PATH__/index.php?/$1 last;
}

View file

@ -30,7 +30,7 @@ group = __USER__
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php7.2-fpm-__NAMETOCHANGE__.sock
listen = /var/run/php7.3-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)

View file

@ -6,7 +6,7 @@
"en": "Firefly III is a self-hosted financial manager.",
"fr": "Firefly III est un gestionnaire de finances personnelles."
},
"version": "4.7.17",
"version": "5.0.5",
"url": "https://firefly-iii.org/",
"license": "GPL v3",
"maintainer": {
@ -34,6 +34,16 @@
},
"example": "example.com"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Firefly III",
"fr": "Choisissez un chemin pour Firefly III"
},
"example": "/example",
"default": "/firefly"
},
{
"name": "admin",
"type": "user",

View file

@ -5,7 +5,8 @@
#=================================================
# dependencies used by the app
pkg_dependencies="php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache php7.2-ldap"
phpversion="7.3"
pkg_dependencies="php${phpversion}-zip php${phpversion}-fpm php${phpversion}-mysql php${phpversion}-xml php${phpversion}-intl php${phpversion}-mbstring php${phpversion}-gd php${phpversion}-curl php${phpversion}-bcmath php${phpversion}-opcache php${phpversion}-ldap"
# ============= FUTURE YUNOHOST HELPER =============
# Delete a file checksum from the app settings

View file

@ -7,6 +7,9 @@
#=================================================
source _common.sh
source ynh_add_extra_apt_repos__3
source ynh_install_php__3
source ynh_composer
source /usr/share/yunohost/helpers
#=================================================
@ -21,7 +24,7 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
random_key=$(ynh_string_random 32)
@ -44,8 +47,8 @@ app=$YNH_APP_INSTANCE_NAME
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#mkdir $final_path
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -64,10 +67,9 @@ ynh_app_setting_set --app=$app --key=random_key --value=$random_key
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --time --weight=1
# ynh_install_php7
ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Installing dependencies..." --time --weight=1
ynh_install_php --phpversion="$phpversion" --package="$pkg_dependencies"
#=================================================
# CREATE A MYSQL DATABASE
@ -105,18 +107,22 @@ ynh_script_progression --message="Configuring system user..." --time --weight=1
ynh_system_user_create --username=$app
#=================================================
# PHP-FPM 7.2 CONFIGURATION
# PHP-FPM 7.3 CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
# Create a dedicated php-fpm7.1 config
#ynh_add_fpm7.2_config
ynh_add_fpm_config --phpversion=7.2
ynh_add_fpm_config --phpversion="$phpversion"
#=================================================
# SPECIFIC SETUP
#=================================================
# Install via composer
ynh_install_composer --phpversion="$phpversion"
# create a user
email=$(ynh_user_get_info $admin 'mail')
@ -132,24 +138,23 @@ ynh_replace_string "yunopass" "$db_pwd" "$final_path/.env"
ynh_replace_string "yunobase" "$db_name" "$final_path/.env"
ynh_replace_string "yunomail" "$email" "$final_path/.env"
ynh_replace_string "yunodomain" "$domain" "$final_path/.env"
ynh_replace_string "yunoappurl" "$domain$path_url" "$final_path/.env"
init_composer $final_path $app
( cd $final_path && sudo /usr/bin/php7.2 artisan config:clear )
db_name=$(ynh_sanitize_dbid $app)
#init_composer $final_path $app
cd $final_path && php$phpversion artisan migrate:refresh --seed
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
cd $final_path && php$phpversion artisan passport:install
# setup application config
(
cd $final_path && sudo /usr/bin/php7.2 artisan -q :refresh --seed --force
cd $final_path && sudo /usr/bin/php7.2 artisan passport:install --force
)
#=================================================
# SETUP APPLICATION PERMISSIONS
#=================================================
# Set right permissions
chown -R $app: $final_path
chown -R $app:$app $final_path
chmod -R 775 ${final_path}/storage
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
@ -202,27 +207,17 @@ ynh_use_logrotate
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
### - As well as the section "ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
yunohost service add $app --log "/var/log/$app/$app.log"
#yunohost service add $app --log "/var/log/$app/$app.log"
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
# systemctl reload php7.2-fpm
# systemctl reload nginx
ynh_systemd_action --service_name=php7.2-fpm --action=reload
ynh_systemd_action --service_name=php7.3-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
# Set default php to php5 or php7.0
# if [ "$(lsb_release --codename --short)" == "jessie" ]; then
# update-alternatives --set php /usr/bin/php5
# else
# update-alternatives --set php /usr/bin/php7.0
# fi
#=================================================
# END OF SCRIPT

View file

@ -7,6 +7,8 @@
#=================================================
source _common.sh
source ynh_add_extra_apt_repos__3
source ynh_install_php__3
source /usr/share/yunohost/helpers
#=================================================
@ -74,7 +76,14 @@ ynh_script_progression --message="Removing php-fpm configuration..." --time --we
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
# ynh_remove_fpm7.2_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --time --weight=1
# Remove metapackage and its dependencies
ynh_remove_php
#=================================================
# REMOVE LOGROTATE CONFIGURATION

View file

@ -7,6 +7,9 @@
#=================================================
source _common.sh
source ynh_add_extra_apt_repos__3
source ynh_install_php__3
source ynh_composer
source /usr/share/yunohost/helpers
#=================================================
@ -92,14 +95,31 @@ mkdir -p "$final_path/storage/upload/"
mkdir -p "$final_path/storage/export/"
cp -a "$final_path/storage/upload/" "$tmpdir/storage/upload/"
cp -a "$final_path/storage/export/" "$tmpdir/storage/export/"
rm -Rf "$final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_install_composer --phpversion="$phpversion"
cd $final_path && php$phpversion artisan migrate:refresh --seed
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
cd $final_path && php$phpversion artisan passport:install
rm -rf "$final_path/bootstrap/cache/*"
cd $final_path && php$phpversion artisan cache:clear
cd $final_path && php$phpversion artisan migrate --seed
cd $final_path && php$phpversion artisan firefly-iii:upgrade-database
cd $final_path && php$phpversion artisan passport:install
cd $final_path && php$phpversion artisan cache:clear
cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/"
cp -a "$tmpdir/storage/export/" "$final_path/storage/export/"
# Set right permissions
chown -R $app:$app $final_path
chmod -R 775 ${final_path}/storage
#remove tmp dir
sudo rm -Rf "$tmpdir"

View file

@ -0,0 +1,295 @@
#!/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}"
}

52
scripts/ynh_composer Normal file
View file

@ -0,0 +1,52 @@
#!/bin/bash
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Execute a command with Composer
#
# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands"
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -c, --commands - Commands to execute.
ynh_composer_exec () {
# Declare an array to define the options of this helper.
local legacy_args=vwc
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
local phpversion
local workdir
local commands
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-7.0}"
COMPOSER_HOME="$workdir/.composer" \
php${phpversion} "$workdir/composer.phar" $commands \
-d "$workdir" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
#
# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path]
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
ynh_install_composer () {
# Declare an array to define the options of this helper.
local legacy_args=vw
declare -Ar args_array=( [v]=phpversion= [w]=workdir= )
local phpversion
local workdir
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-7.0}"
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
php${phpversion} -- --quiet --install-dir="$workdir" \
|| ynh_die "Unable to install Composer."
# update dependencies to create composer.lock
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|| ynh_die "Unable to update core dependencies with Composer."
}

64
scripts/ynh_composer~ Normal file
View file

@ -0,0 +1,64 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# Package dependencies
pkg_dependencies="php-cli php-common php-intl php-json php-mcrypt php-pear php-auth-sasl php-mail-mime php-patchwork-utf8 php-net-smtp php-net-socket php-net-ldap2 php-net-ldap3 php-zip php-gd php-mbstring php-curl"
# Plugins version
contextmenu_version=2.3
automatic_addressbook_version=v0.4.3
carddav_version=3.0.3
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Execute a command with Composer
#
# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands"
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -c, --commands - Commands to execute.
ynh_composer_exec () {
# Declare an array to define the options of this helper.
local legacy_args=vwc
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
local phpversion
local workdir
local commands
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-7.0}"
COMPOSER_HOME="$workdir/.composer" \
php${phpversion} "$workdir/composer.phar" $commands \
-d "$workdir" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
#
# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path]
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
ynh_install_composer () {
# Declare an array to define the options of this helper.
local legacy_args=vw
declare -Ar args_array=( [v]=phpversion= [w]=workdir= )
local phpversion
local workdir
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-7.0}"
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
php${phpversion} -- --quiet --install-dir="$workdir" \
|| ynh_die "Unable to install Composer."
# update dependencies to create composer.lock
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|| ynh_die "Unable to update core dependencies with Composer."
}

View file

@ -0,0 +1,82 @@
#!/bin/bash
# Install another version of php.
#
# usage: ynh_install_php --phpversion=phpversion [--package=packages]
# | arg: -v, --phpversion - Version of php to install. Can be one of 7.1, 7.2 or 7.3
# | 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:-}
# Store php_version into the config of this app
ynh_app_setting_set $app php_version $phpversion
if [ "$phpversion" == "7.0" ]
then
ynh_die "Do not use ynh_install_php to install php7.0"
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
if [ ! -f "/etc/apt/sources.list.d/sury.list" ]; then
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
fi
# 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.0 back as the default version for php-cli.
update-alternatives --set php /usr/bin/php7.0
# Remove this extra repository after packages are installed
if [ ! -f "/etc/apt/sources.list.d/sury.list" ]; then
ynh_remove_extra_repo --name=extra_php_version
fi
# Advertise service in admin panel
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
}
ynh_remove_php () {
# Get the version of php used by this app
local phpversion=$(ynh_app_setting_get $app php_version)
if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ]
then
if [ "$phpversion" == "7.0" ]
then
ynh_print_err "Do not use ynh_remove_php to install php7.0"
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
}