Use appropriciate tar option per compression types (#58)

This commit is contained in:
Yamashita Yuu 2013-09-14 10:28:33 +09:00
parent 02a348b657
commit fb3e9b020e

View file

@ -267,18 +267,27 @@ fetch_tarball() {
fi fi
fi fi
local _package_filename="${package_url##*/}" local package_suffix extract_option
local _package_suffix="${_package_filename##*.}" case "${package_url}" in
case "${_package_suffix}" in *".tar.gz" )
"Z" | "bz2" | "gz" | "xz" ) package_suffix=".tar.gz"
local package_suffix="tar.${_package_suffix}" extract_option="zxvf"
;;
*".tgz" )
package_suffix=".tgz"
extract_option="zxvf"
;;
*".tar.bz2" )
package_suffix=".tar.bz2"
extract_option="jxvf"
;; ;;
* ) * )
local package_suffix="${_package_suffix}" package_suffix=".${package_url##*.}"
extract_option="xvf"
;; ;;
esac esac
local package_filename="${package_name}.${package_suffix}" local package_filename="${package_name}${package_suffix:-.tar.gz}"
symlink_tarball_from_cache "$package_filename" "$checksum" || { symlink_tarball_from_cache "$package_filename" "$checksum" || {
echo "Downloading ${package_filename}..." >&2 echo "Downloading ${package_filename}..." >&2
{ http head "$mirror_url" && { http head "$mirror_url" &&
@ -287,7 +296,7 @@ fetch_tarball() {
download_tarball "$package_url" "$package_filename" "$checksum" download_tarball "$package_url" "$package_filename" "$checksum"
} }
{ if tar xvf "$package_filename"; then { if tar "${extract_options:-xvf}" "$package_filename"; then
if [ -z "$KEEP_BUILD_PATH" ]; then if [ -z "$KEEP_BUILD_PATH" ]; then
rm -f "$package_filename" rm -f "$package_filename"
else else