mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #1586 from ericgaspar/dev
Fix composer workdir variable for package v2
This commit is contained in:
commit
add0dbb864
2 changed files with 22 additions and 17 deletions
10
helpers/php
10
helpers/php
|
@ -499,9 +499,9 @@ ynh_composer_exec() {
|
||||||
|
|
||||||
# Install and initialize Composer in the given directory
|
# Install and initialize Composer in the given directory
|
||||||
#
|
#
|
||||||
# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion]
|
# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$install_dir] [--install_args="--optimize-autoloader"] [--composerversion=composerversion]
|
||||||
# | arg: -v, --phpversion - PHP version to use with composer
|
# | arg: -v, --phpversion - PHP version to use with composer
|
||||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
# | arg: -w, --workdir - The directory from where the command will be executed. Default $install_dir.
|
||||||
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
|
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
|
||||||
# | arg: -c, --composerversion - Composer version to install
|
# | arg: -c, --composerversion - Composer version to install
|
||||||
#
|
#
|
||||||
|
@ -516,7 +516,11 @@ ynh_install_composer() {
|
||||||
local composerversion
|
local composerversion
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
workdir="${workdir:-$final_path}"
|
if dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} lt 2; then
|
||||||
|
workdir="${workdir:-$final_path}"
|
||||||
|
else
|
||||||
|
workdir="${workdir:-$install_dir}"
|
||||||
|
fi
|
||||||
phpversion="${phpversion:-$YNH_PHP_VERSION}"
|
phpversion="${phpversion:-$YNH_PHP_VERSION}"
|
||||||
install_args="${install_args:-}"
|
install_args="${install_args:-}"
|
||||||
composerversion="${composerversion:-$YNH_COMPOSER_VERSION}"
|
composerversion="${composerversion:-$YNH_COMPOSER_VERSION}"
|
||||||
|
|
|
@ -58,13 +58,13 @@ class AppResourceManager:
|
||||||
try:
|
try:
|
||||||
if todo == "deprovision":
|
if todo == "deprovision":
|
||||||
# FIXME : i18n, better info strings
|
# FIXME : i18n, better info strings
|
||||||
logger.info(f"Deprovisionning {name} ...")
|
logger.info(f"Deprovisionning {name}...")
|
||||||
old.deprovision(context=context)
|
old.deprovision(context=context)
|
||||||
elif todo == "provision":
|
elif todo == "provision":
|
||||||
logger.info(f"Provisionning {name} ...")
|
logger.info(f"Provisionning {name}...")
|
||||||
new.provision_or_update(context=context)
|
new.provision_or_update(context=context)
|
||||||
elif todo == "update":
|
elif todo == "update":
|
||||||
logger.info(f"Updating {name} ...")
|
logger.info(f"Updating {name}...")
|
||||||
new.provision_or_update(context=context)
|
new.provision_or_update(context=context)
|
||||||
except (KeyboardInterrupt, Exception) as e:
|
except (KeyboardInterrupt, Exception) as e:
|
||||||
exception = e
|
exception = e
|
||||||
|
@ -87,13 +87,13 @@ class AppResourceManager:
|
||||||
# (NB. here we want to undo the todo)
|
# (NB. here we want to undo the todo)
|
||||||
if todo == "deprovision":
|
if todo == "deprovision":
|
||||||
# FIXME : i18n, better info strings
|
# FIXME : i18n, better info strings
|
||||||
logger.info(f"Reprovisionning {name} ...")
|
logger.info(f"Reprovisionning {name}...")
|
||||||
old.provision_or_update(context=context)
|
old.provision_or_update(context=context)
|
||||||
elif todo == "provision":
|
elif todo == "provision":
|
||||||
logger.info(f"Deprovisionning {name} ...")
|
logger.info(f"Deprovisionning {name}...")
|
||||||
new.deprovision(context=context)
|
new.deprovision(context=context)
|
||||||
elif todo == "update":
|
elif todo == "update":
|
||||||
logger.info(f"Reverting {name} ...")
|
logger.info(f"Reverting {name}...")
|
||||||
old.provision_or_update(context=context)
|
old.provision_or_update(context=context)
|
||||||
except (KeyboardInterrupt, Exception) as e:
|
except (KeyboardInterrupt, Exception) as e:
|
||||||
if isinstance(e, KeyboardInterrupt):
|
if isinstance(e, KeyboardInterrupt):
|
||||||
|
@ -222,7 +222,7 @@ ynh_abort_if_errors
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# FIXME: currently in app install code, we have
|
# FIXME: currently in app install code, we have
|
||||||
# more sophisticated code checking if this broke something on the system etc ...
|
# more sophisticated code checking if this broke something on the system etc.
|
||||||
# dunno if we want to do this here or manage it elsewhere
|
# dunno if we want to do this here or manage it elsewhere
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ class InstalldirAppResource(AppResource):
|
||||||
owner: str = ""
|
owner: str = ""
|
||||||
group: str = ""
|
group: str = ""
|
||||||
|
|
||||||
# FIXME: change default dir to /opt/stuff if app ain't a webapp ...
|
# FIXME: change default dir to /opt/stuff if app ain't a webapp...
|
||||||
|
|
||||||
def provision_or_update(self, context: Dict = {}):
|
def provision_or_update(self, context: Dict = {}):
|
||||||
assert self.dir.strip() # Be paranoid about self.dir being empty...
|
assert self.dir.strip() # Be paranoid about self.dir being empty...
|
||||||
|
@ -554,7 +554,7 @@ class InstalldirAppResource(AppResource):
|
||||||
# and check for available space on the destination
|
# and check for available space on the destination
|
||||||
if current_install_dir and os.path.isdir(current_install_dir):
|
if current_install_dir and os.path.isdir(current_install_dir):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Moving {current_install_dir} to {self.dir} ... (this may take a while)"
|
f"Moving {current_install_dir} to {self.dir}... (this may take a while)"
|
||||||
)
|
)
|
||||||
shutil.move(current_install_dir, self.dir)
|
shutil.move(current_install_dir, self.dir)
|
||||||
else:
|
else:
|
||||||
|
@ -658,7 +658,7 @@ class DatadirAppResource(AppResource):
|
||||||
# FIXME: same as install_dir, is this what we want ?
|
# FIXME: same as install_dir, is this what we want ?
|
||||||
if current_data_dir and os.path.isdir(current_data_dir):
|
if current_data_dir and os.path.isdir(current_data_dir):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Moving {current_data_dir} to {self.dir} ... (this may take a while)"
|
f"Moving {current_data_dir} to {self.dir}... (this may take a while)"
|
||||||
)
|
)
|
||||||
shutil.move(current_data_dir, self.dir)
|
shutil.move(current_data_dir, self.dir)
|
||||||
else:
|
else:
|
||||||
|
@ -771,7 +771,8 @@ class PortsResource(AppResource):
|
||||||
##### Example:
|
##### Example:
|
||||||
```toml
|
```toml
|
||||||
[resources.ports]
|
[resources.ports]
|
||||||
# (empty should be fine for most apps ... though you can customize stuff if absolutely needed)
|
# (empty should be fine for most apps... though you can customize stuff if absolutely needed)
|
||||||
|
|
||||||
|
|
||||||
main.default = 12345 # if you really want to specify a prefered value .. but shouldnt matter in the majority of cases
|
main.default = 12345 # if you really want to specify a prefered value .. but shouldnt matter in the majority of cases
|
||||||
|
|
||||||
|
@ -829,7 +830,7 @@ class PortsResource(AppResource):
|
||||||
super().__init__({"ports": properties}, *args, **kwargs)
|
super().__init__({"ports": properties}, *args, **kwargs)
|
||||||
|
|
||||||
def _port_is_used(self, port):
|
def _port_is_used(self, port):
|
||||||
# FIXME : this could be less brutal than two os.system ...
|
# FIXME : this could be less brutal than two os.system...
|
||||||
cmd1 = (
|
cmd1 = (
|
||||||
"ss --numeric --listening --tcp --udp | awk '{print$5}' | grep --quiet --extended-regexp ':%s$'"
|
"ss --numeric --listening --tcp --udp | awk '{print$5}' | grep --quiet --extended-regexp ':%s$'"
|
||||||
% port
|
% port
|
||||||
|
@ -918,7 +919,7 @@ class DatabaseAppResource(AppResource):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Notes for future?
|
# Notes for future?
|
||||||
# deep_clean -> ... idk look into any db name that would not be related to any app ...
|
# deep_clean -> ... idk look into any db name that would not be related to any app...
|
||||||
# backup -> dump db
|
# backup -> dump db
|
||||||
# restore -> setup + inject db dump
|
# restore -> setup + inject db dump
|
||||||
|
|
||||||
|
@ -941,7 +942,7 @@ class DatabaseAppResource(AppResource):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Hack so that people can write type = "mysql/postgresql" in toml but it's loaded as dbtype
|
# Hack so that people can write type = "mysql/postgresql" in toml but it's loaded as dbtype
|
||||||
# to avoid conflicting with the generic self.type of the resource object ...
|
# to avoid conflicting with the generic self.type of the resource object...
|
||||||
# dunno if that's really a good idea :|
|
# dunno if that's really a good idea :|
|
||||||
properties = {"dbtype": properties["type"]}
|
properties = {"dbtype": properties["type"]}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue