From d2c1aea0643f23dff161866abdcb70b5894c2a94 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Tue, 26 Feb 2013 18:38:35 +0100 Subject: [PATCH] beesh: Add support for zip source archives To emulate the strip-components behavior of tar we scan the extracted sources and prepend a sourcesubdirectory if the archive is extracted into a subdirectory. This is a much cleaner solution then to strip components out of pathnames within the archive. So tar extraction should be changed too in the future. --- src/beesh.sh.in | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index 00879ae..43995bb 100644 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -363,6 +363,22 @@ function bee_getsources() { #### bee_extract() ############################################################# +function bee_extract_do_zip() { + local file="${1}" + local dest="${2}" + local -a list + + shift 2 + + start_cmd unzip -q -o "${file}" -d "${dest}" "${@}" + + readarray -t list < <(ls -a "${dest}" | grep -vE '^\.(\.|)$' | head -2) + + if [ "${#list[@]}" = "1" ] ; then + sourcesubdir_prepend "${list[0]}" + fi +} + function bee_extract_do_tar() { local file="${1}" local dest="${2}" @@ -400,7 +416,8 @@ function bee_extract_do() { mimetype=$(get_or_guess_mimetype "${file}") if [ "${mimetype}" = "application/zip" ] ; then - print_error "zip extraction not yet implemented" + bee_extract_do_zip "${file}" "${dest}" + return fi if [ "${mode}" = "primary" ] ; then