@@ -153,10 +153,16 @@ export -f exists_command
153153# Error function.
154154# Usage: error_file_not_downloaded <file_url>
155155error_file_not_downloaded () {
156- echo " "
157- echo " Error: ${1} not found."
158- echo " Are curl or wget able to reach it from your system?"
159- echo " "
156+ echo " Error: ${1} not found. Are curl or wget able to reach it from your system?"
157+ }
158+
159+
160+
161+
162+ # Error function.
163+ # Usage: error_tarball_non_working <file_name>
164+ error_tarball_non_working () {
165+ echo " Error: file '${1} ' is a non-working .tar.gz tarball and cannot be used. Deleting it."
160166}
161167
162168
@@ -385,7 +391,7 @@ archive_extract() {
385391 # "tar --strip-components 1" permit to extract sources in /tmp/bashpack and don't create a new directory /tmp/bashpack/bashpack
386392 tar -xf ${1} -C ${2} --strip-components 1
387393 else
388- echo " Error: file ' ${1} ' is not a real .tar.gz tarball and cannot be used. Deleting it. "
394+ error_tarball_non_working ${1}
389395 rm -f ${1}
390396 fi
391397}
@@ -587,8 +593,8 @@ create_cli() {
587593# - Github latest tarball release is accessible from https://api.github.com/repos/<user>/<repository>/tarball
588594update_cli () {
589595 # Download a first time the latest version from the "main" branch to be able to launch the installation script from it to get latest modifications.
590- # The install function will download the well-named archive with the version name
591- # (so yes, it means that the CLI is downloaded twice )
596+ # The install function will download the well-named archive with the version name.
597+ # (so yes, it means that the CLI is downloaded multiple times )
592598
593599 local error_already_installed=" Latest $NAME version is already installed ($VERSION $( detect_publication) )."
594600
@@ -598,40 +604,21 @@ update_cli() {
598604 if [[ $( curl -s " $URL /releases/latest" | grep tag_name | cut -d \" -f 4) = " $VERSION " ]] && [[ $( detect_publication) = $( get_config_value " $dir_config /$file_config " " publication" ) ]]; then
599605 echo $error_already_installed
600606 else
601-
602- # # To avoid broken installations, before deleting anything, testing if downloaded archive is a working tarball.
603- # # (archive is deleted in create_cli, which is called after in the process)
604- # if file $archive_tmp | grep -q 'gzip compressed data'; then
605- # # Delete current installed version to clean all old files
606- # delete_all exclude_main
607-
608- # # Execute the install_cli function of the script downloaded in /tmp
609- # exec "$archive_dir_tmp/$NAME_LOWERCASE.sh" -i
610- # else
611- # echo "Error: file '${1}' is not a real .tar.gz tarball and cannot be used. Deleting it, then exiting."
612- # rm -f ${1}
613- # exit
614- # fi
615-
616607 # To avoid broken installations, before deleting anything, testing if downloaded archive is a working tarball.
617608 # (archive is deleted in create_cli, which is called after in the process)
618609 if ! $NAME_LOWERCASE verify -d | grep -q ' Error:' ; then
619610
611+ # Download latest available version
620612 download_cli " $URL /tarball" $archive_tmp $archive_dir_tmp
621613
622614 # Delete current installed version to clean all old files
623615 delete_all exclude_main
624616
625617 # Execute the install_cli function of the script downloaded in /tmp
626618 exec " $archive_dir_tmp /$NAME_LOWERCASE .sh" -i
619+ else
620+ error_tarball_non_working $archive_tmp
627621 fi
628-
629- # # Delete current installed version to clean all old files
630- # delete_all exclude_main
631-
632- # # Execute the install_cli function of the script downloaded in /tmp
633- # exec "$archive_dir_tmp/$NAME_LOWERCASE.sh" -i
634-
635622 fi
636623}
637624
0 commit comments