From c1212ba4918e64ea358ad5df24d2c53c99f9368e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 22 Jul 2017 22:16:20 +0200 Subject: Adding automatic compression detection for downloads in in curl container create directory. Signed-off-by: Daniel Baumann --- share/scripts/curl | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'share') diff --git a/share/scripts/curl b/share/scripts/curl index 62ce9be..4a719f0 100755 --- a/share/scripts/curl +++ b/share/scripts/curl @@ -142,16 +142,25 @@ then exit 1 fi +COMPRESSIONS="" + if [ -x /usr/bin/lzip ] then - COMPRESSION="lz" -elif [ -x /usr/bin/xz ] + COMPRESSIONS="${COMPRESSIONS} lz" +fi + +if [ -x /usr/bin/xz ] +then + COMPRESSIONS="${COMPRESSIONS} xz" +fi + +if [ -x /bin/gzip ] then - COMPRESSION="xz" -elif [ -x /bin/gzip ] + COMPRESSIONS="${COMPRESSIONS} gz" +fi + +if [ -z "${COMPRESSIONS}" ] then - COMPRESSION="gz" -else echo "'${NAME}': no supported compressor available (lz, xz, gz)." exit 1 fi @@ -252,14 +261,21 @@ then # Read-in configuration from debconf . "${DEBCONF_TMPDIR}/debconf.default" - SYSTEM="${SYSTEM}.${COMPRESSION}" - # Remove debconf temporary files rm --preserve-root --one-file-system -rf "${DEBCONF_TMPDIR}" rmdir --ignore-fail-on-non-empty /tmp/container-tools 2>&1 || true fi fi +for COMPRESSION in ${COMPRESSIONS} +do + if curl --fail --head --output /dev/null --silent "${SERVER}/${SYSTEM}.${COMPRESSION}" + then + SYSTEM="${SYSTEM}.${COMPRESSION}" + break + fi +done + # Downloading container files mkdir -p "${CACHE}" -- cgit v1.2.3