diff --git a/install-compiled.sh b/install-compiled.sh index b9624a4..e57c399 100755 --- a/install-compiled.sh +++ b/install-compiled.sh @@ -117,10 +117,18 @@ fetch_source() { echo " Extracting $filename..." case "$filename" in *.zip) - unzip -q "$filepath" -d "$TMP_DIR" - local extracted - extracted=$(unzip -qql "$filepath" | head -n1 | awk '{print $NF}' | cut -d/ -f1) - mv "$TMP_DIR/$extracted" "$src_dir" + unzip -q "$filepath" -d "$src_dir" + # If the zip extracted into a single subdirectory, flatten it + local contents + contents=$(ls -1 "$src_dir") + local count + count=$(echo "$contents" | wc -l) + if [ "$count" -eq 1 ] && [ -d "$src_dir/$contents" ]; then + echo " Descending into $contents..." + local inner="$src_dir/$contents" + mv "$inner"/* "$src_dir/" + rmdir "$inner" + fi ;; *.tar.gz|*.tgz) tar -xzf "$filepath" -C "$src_dir" --strip-components=1