From f326cb97993eb47c14ff2f790553ec9ef2440514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 5 Apr 2024 17:56:33 +0200 Subject: [PATCH 1/2] Add option to avoid to wait for dpkg free if not needed --- helpers/apt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/helpers/apt b/helpers/apt index 8ff9a3cd1..979e71fa7 100644 --- a/helpers/apt +++ b/helpers/apt @@ -45,20 +45,25 @@ ynh_wait_dpkg_free() { # # example: ynh_package_is_installed --package=yunohost && echo "installed" # -# usage: ynh_package_is_installed --package=name -# | arg: -p, --package= - the package name to check +# usage: ynh_package_is_installed --package=name [--wait_dpkg_free] +# | arg: -p, --package= - the package name to check +# | arg: -l, --wait_dpkg_free= - wait for dpkg to be free. +# | Note that waiting on dpkg free could take about 0.2s on quick platform +# | and about 2 seconds on slow platform so in case of multiple call it could be slow # | ret: 0 if the package is installed, 1 else. -# -# Requires YunoHost version 2.2.4 or higher. ynh_package_is_installed() { # Declare an array to define the options of this helper. - local legacy_args=p - local -A args_array=([p]=package=) + local legacy_args=pl + local -A args_array=([p]=package= [l]=wait_dpkg_free=) local package + local wait_dpkg_free # Manage arguments with getopts ynh_handle_getopts_args "$@" + wait_dpkg_free="${wait_dpkg_free:-0}" - ynh_wait_dpkg_free + if [ "$wait_dpkg_free" -eq 1 ]; then + ynh_wait_dpkg_free + fi dpkg-query --show --showformat='${Status}' "$package" 2>/dev/null \ | grep --count "ok installed" &>/dev/null } From 73fc55484007bee8af56e84ceb5562ed3852e5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 5 Apr 2024 20:41:41 +0200 Subject: [PATCH 2/2] Remove optional flag wait-dpkg-free --- helpers/apt | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/helpers/apt b/helpers/apt index 979e71fa7..5ce94e26c 100644 --- a/helpers/apt +++ b/helpers/apt @@ -45,25 +45,19 @@ ynh_wait_dpkg_free() { # # example: ynh_package_is_installed --package=yunohost && echo "installed" # -# usage: ynh_package_is_installed --package=name [--wait_dpkg_free] -# | arg: -p, --package= - the package name to check -# | arg: -l, --wait_dpkg_free= - wait for dpkg to be free. -# | Note that waiting on dpkg free could take about 0.2s on quick platform -# | and about 2 seconds on slow platform so in case of multiple call it could be slow +# usage: ynh_package_is_installed --package=name +# | arg: -p, --package= - the package name to check # | ret: 0 if the package is installed, 1 else. +# +# Requires YunoHost version 2.2.4 or higher. ynh_package_is_installed() { # Declare an array to define the options of this helper. - local legacy_args=pl - local -A args_array=([p]=package= [l]=wait_dpkg_free=) + local legacy_args=p + local -A args_array=([p]=package=) local package - local wait_dpkg_free # Manage arguments with getopts ynh_handle_getopts_args "$@" - wait_dpkg_free="${wait_dpkg_free:-0}" - if [ "$wait_dpkg_free" -eq 1 ]; then - ynh_wait_dpkg_free - fi dpkg-query --show --showformat='${Status}' "$package" 2>/dev/null \ | grep --count "ok installed" &>/dev/null }