midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pkg_fetch_extract.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz 2b85d0
# set +o errexit -o noglob is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz 2b85d0
pkgp_fetch_extract_type() {
Lucio Andrés Illanes Albornoz 2b85d0
	local _fname="${1}";
Lucio Andrés Illanes Albornoz 2b85d0
	if [ "${1##*.tar.}" != "${1}" ]; then
Lucio Andrés Illanes Albornoz 2b85d0
		echo "${1##*.tar.}";
Lucio Andrés Illanes Albornoz 2b85d0
	elif [ "${1##*.t}" != "${1}" ]; then
Lucio Andrés Illanes Albornoz 2b85d0
		echo "${1##*.t}";
Lucio Andrés Illanes Albornoz 2b85d0
	fi;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pkg_fetch_extract() {
Lucio Andrés Illanes Albornoz aa37e6
	if [ -n "${PKG_URL}" ]; then
Lucio Andrés Illanes Albornoz bf9edf
		_oldpwd="${PWD}";
Lucio Andrés Illanes Albornoz bf9edf
		if ! rtl_fileop cd "${PKG_BASE_DIR}"\
Lucio Andrés Illanes Albornoz bf9edf
		|| ! rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}"; then
Lucio Andrés Illanes Albornoz bf9edf
			rtl_fileop cd "${_oldpwd}"; return 1;
Lucio Andrés Illanes Albornoz bf9edf
		else
Lucio Andrés Illanes Albornoz bf9edf
			case "$(pkgp_fetch_extract_type "${PKG_NAME}")" in
Lucio Andrés Illanes Albornoz bf9edf
			bz2)	bunzip2 -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;;
Lucio Andrés Illanes Albornoz bf9edf
			gz)	gunzip -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;;
Lucio Andrés Illanes Albornoz bf9edf
			lz)	lzip -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;;
Lucio Andrés Illanes Albornoz bf9edf
			xz)	xz -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;;
Lucio Andrés Illanes Albornoz bf9edf
			*)	tar -C "${PKG_BASE_DIR}" -xf "${BUILD_DLCACHEDIR}/${PKG_FNAME}"; ;;
Lucio Andrés Illanes Albornoz bf9edf
			esac;
Lucio Andrés Illanes Albornoz bf9edf
			if [ "${?}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz bf9edf
				rtl_fileop cd "${_oldpwd}"; return 1;
Lucio Andrés Illanes Albornoz bf9edf
			else
Lucio Andrés Illanes Albornoz bf9edf
				rtl_fileop cd "${_oldpwd}";
Lucio Andrés Illanes Albornoz bf9edf
			fi;
Lucio Andrés Illanes Albornoz bf9edf
		fi;
Lucio Andrés Illanes Albornoz a53c26
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
# vim:filetype=sh