summaryrefslogtreecommitdiffhomepage
path: root/subr/pkg_fetch_extract.subr
blob: 0afa837e6b26ea629fcea4edccad4478b6d0d688 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# set -o errexit -o noglob are assumed.
#

pkg_fetch_extract() {
	local _oldpwd="";
	if [ -n "${PKG_URL}" ]\
	&& [ "${PKG_URL_TYPE:-wget}" = wget ]; then
		_oldpwd="${PWD}"; ex_rtl_fileop cd "${PKG_BASE_DIR}";
		ex_rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}";
		if [ "${PKG_FNAME##*.tar.}" = "bz2" ]\
		|| [ "${PKG_FNAME##*.t}" = "bz2" ]; then
			bunzip2 -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
		elif [ "${PKG_FNAME##*.tar.}" = "gz" ]\
		|| [ "${PKG_FNAME##*.t}" = "gz" ]; then
			gunzip -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
		elif [ "${PKG_FNAME##*.tar.}" = "xz" ]\
		|| [ "${PKG_FNAME##*.t}" = "xz" ]; then
			xz -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -;
		else
			tar -C "${PKG_BASE_DIR}" -xf "${BUILD_DLCACHEDIR}/${PKG_FNAME}";
		fi;
		ex_rtl_fileop cd "${_oldpwd}";
	fi;
};

# vim:filetype=sh