Skip to content

Commit

Permalink
beesh: Add support for zip source archives
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mariux committed Feb 28, 2013
1 parent 5d091b5 commit d2c1aea
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/beesh.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d2c1aea

Please sign in to comment.