From 56c45133b6e1997dbb0e9e3019b8ca0da8b54808 Mon Sep 17 00:00:00 2001 From: Emmanuel Averty Date: Wed, 28 Feb 2024 11:59:38 +0100 Subject: [PATCH 1/5] add xz decompression for sources --- helpers/utils | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helpers/utils b/helpers/utils index 98e610f213..c397f2b59d 100644 --- a/helpers/utils +++ b/helpers/utils @@ -201,6 +201,9 @@ ynh_setup_source() { elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]] then src_format="tar.bz2" + elif [[ "$src_url" =~ ^.*\.xz$ ]] + then + src_format="xz" elif [[ -z "$src_extract" ]] then src_extract="false" @@ -329,6 +332,13 @@ ynh_setup_source() { unzip -quo $src_filename -d "$dest_dir" fi ynh_secure_remove --file="$src_filename" + elif [[ "$src_format" == "xz" ]]; then + if [[ -z "$src_rename" ]]; then + xz -d --stdout $src_filename > "$dest_dir/$(basename $src_filename)" + else + xz -d --stdout $src_filename > "$dest_dir/$src_rename" + fi + else local strip="" if [ "$src_in_subdir" != "false" ]; then From aa64f07a3fbb62d9b566b6768015f552170ca29b Mon Sep 17 00:00:00 2001 From: Emmanuel Averty Date: Wed, 13 Mar 2024 12:54:15 +0100 Subject: [PATCH 2/5] add bz2 and gzip source decompression --- helpers/utils | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/helpers/utils b/helpers/utils index c397f2b59d..cc9341273d 100644 --- a/helpers/utils +++ b/helpers/utils @@ -187,25 +187,22 @@ ynh_setup_source() { [[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?" [[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?" - if [[ -z "$src_format" ]] - then - if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]] - then + if [[ -z "$src_format" ]]; then + if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]; then src_format="zip" - elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]] - then + elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]; then src_format="tar.gz" - elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]] - then + elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]; then src_format="tar.xz" - elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]] - then + elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]; then src_format="tar.bz2" - elif [[ "$src_url" =~ ^.*\.xz$ ]] - then + elif [[ "$src_url" =~ ^.*\.gz$ ]]; then + src_format="gz" + elif [[ "$src_url" =~ ^.*\.xz$ ]]; then src_format="xz" - elif [[ -z "$src_extract" ]] - then + elif [[ "$src_url" =~ ^.*\.bz2$ ]]; then + src_format="bz2" + elif [[ -z "$src_extract" ]]; then src_extract="false" fi fi @@ -332,13 +329,22 @@ ynh_setup_source() { unzip -quo $src_filename -d "$dest_dir" fi ynh_secure_remove --file="$src_filename" - elif [[ "$src_format" == "xz" ]]; then + elif [[ "$src_format" =~ ^gz|xz|bz2$ ]]; then if [[ -z "$src_rename" ]]; then - xz -d --stdout $src_filename > "$dest_dir/$(basename $src_filename)" - else + if [[ "$source_id" == "main" ]]; then + local src_rename=$app + else + local src_rename=$source_id + fi + fi + if [[ "$src_format" == "gz" ]]; then + gunzip --stdout $src_filename > "$dest_dir/$src_rename" + elif [[ "$src_format" == "xz" ]]; then xz -d --stdout $src_filename > "$dest_dir/$src_rename" + elif [[ "$src_format" == "bz2" ]]; then + bunzip2 --stdout $src_filename > "$dest_dir/$src_rename" fi - + _ynh_apply_default_permissions "$dest_dir/$src_rename" else local strip="" if [ "$src_in_subdir" != "false" ]; then From 10e79999fc89da11d1c898e012f07e7570e9497f Mon Sep 17 00:00:00 2001 From: Emmanuel Averty Date: Wed, 13 Mar 2024 22:53:41 +0100 Subject: [PATCH 3/5] add documentation for gz/bz2/xz --- helpers/utils | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helpers/utils b/helpers/utils index cc9341273d..de42d9b229 100644 --- a/helpers/utils +++ b/helpers/utils @@ -97,6 +97,9 @@ fi # ```text # format = "tar.gz"/xz/bz2 # automatically guessed from the extension of the URL, but can be set explicitly. Will use `tar` to extract # "zip" # automatically guessed from the extension of the URL, but can be set explicitly. Will use `unzip` to extract +# "gz" # automatically guessed from the extension of the URL, but can be set explicitly. Will use `gunzip` to extract +# "bz2" # automatically guessed from the extension of the URL, but can be set explicitly. Will use `bunzip2` to extract +# "xz" # automatically guessed from the extension of the URL, but can be set explicitly. Will use `xz -d` to extract # "docker" # useful to extract files from an already-built docker image (instead of rebuilding them locally). Will use `docker-image-extract` to extract # "whatever" # an arbitrary value, not really meaningful except to imply that the file won't be extracted # @@ -104,11 +107,12 @@ fi # false # sources are directly in the archive root # n # (special cases) an integer representing a number of subdirs levels to get rid of # -# extract = true # default if file is indeed an archive such as .zip, .tar.gz, .tar.bz2, ... +# extract = true # default if file is indeed an archive such as .zip, .tar.gz, .tar.bz2, gz, ... # = false # default if file 'format' is not set and the file is not to be extracted because it is not an archive but a script or binary or whatever asset. # # in which case the file will only be `mv`ed to the location possibly renamed using the `rename` value # # rename = "whatever_your_want" # to be used for convenience when `extract` is false and the default name of the file is not practical +# # also used for single file archives (gz, bz2, xz) to rename the extracted file (default : the source id, or the app name for main source) # platform = "linux/amd64" # (defaults to "linux/$YNH_ARCH") to be used in conjonction with `format = "docker"` to specify which architecture to extract for # ``` # From 865ffb458803cd8fa8b1ebd3067cbc2f6aaa4ea9 Mon Sep 17 00:00:00 2001 From: Emmanuel Averty Date: Sat, 16 Mar 2024 17:13:54 +0100 Subject: [PATCH 4/5] add documentation in resources.py --- src/utils/resources.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/resources.py b/src/utils/resources.py index 166be46f25..0a645cb69a 100644 --- a/src/utils/resources.py +++ b/src/utils/resources.py @@ -317,6 +317,9 @@ class SourcesResource(AppResource): - `format` : The "format" of the asset. It is typically automatically guessed from the extension of the URL (or the mention of "tarball", "zipball" in the URL), but can be set explicitly: - `tar.gz`, `tar.xz`, `tar.bz2` : will use `tar` to extract the archive - `zip` : will use `unzip` to extract the archive + - `gz` : will use `gunzip` to extract + - `bz2` : will use `bunzip2` to extract + - `xz` : will use `xz -d` to extract - `docker` : useful to extract files from an already-built docker image (instead of rebuilding them locally). Will use `docker-image-extract` - `whatever`: whatever arbitrary value, not really meaningful except to imply that the file won't be extracted (eg because it's a .deb to be manually installed with dpkg/apt, or a script, or ...) - `in_subdir`: `true` (default) or `false`, depending on if there's an intermediate subdir in the archive before accessing the actual files. Can also be `N` (an integer) to handle special cases where there's `N` level of subdir to get rid of to actually access the files From 04fbff343eda710a705d6e394989be9ca7450cf8 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:57:19 +0100 Subject: [PATCH 5/5] Update debian/control: add explicit dependencies for compression tools --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 2fa1a12206..86f13148ba 100644 --- a/debian/control +++ b/debian/control @@ -27,7 +27,7 @@ Depends: ${python3:Depends}, ${misc:Depends} , rspamd, opendkim-tools, postsrsd, procmail, mailutils , redis-server , acl - , git, curl, wget, cron, unzip, jq, bc, at, procps + , git, curl, wget, cron, unzip, jq, bc, at, procps, tar, gzip, bzip2, xz-utils , lsb-release, haveged, fake-hwclock, equivs, lsof, whois Recommends: yunohost-admin , ntp, inetutils-ping | iputils-ping