summaryrefslogtreecommitdiffhomepage
path: root/subr/pkg_fetch_extract.subr
blob: bb54c87f7084aca8a61281c21b9953954fbef14e (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
28
29
30
31
32
33
34
35
#
# set -o errexit -o noglob are assumed.
#

pkg_fetch_extract() {
	local _chainport_patch_fname="${BUILD_WORKDIR}/chainport/patches/${PKG_NAME%%_*}/${PKG_NAME%%_*}-${PKG_VERSION}.midipix.patch"
		_chainport_patch_dname="${PKG_BASE_DIR}/${PKG_SUBDIR}/patches/${PKG_NAME%%_*}" _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.}" = "lz" ]\
		|| [ "${PKG_FNAME##*.t}" = "lz" ]; then
			lzip -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;
	if [ -e "${_chainport_patch_fname}" ]; then
		ex_rtl_fileop mkdir "${_chainport_patch_dname}";
		ex_rtl_fileop cp "${_chainport_patch_fname}" "${_chainport_patch_dname}";
	fi;
};

# vim:filetype=sh