summaryrefslogtreecommitdiffhomepage
path: root/subr/pkg_extract.subr
blob: 95c32d5d7c821f967401731a7093f3641369a7a9 (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
#
# set -o errexit -o noglob are assumed.
#

pkg_extract() {
	if [ -n "${PKG_URL}" ]\
	&& [ "${PKG_URL_TYPE:-wget}" = wget ]; then
		build_fileop rm ${PKG_SUBDIR};
		if [ ${PKG_SUBDIR_CREATE:-0} -eq 1 ]; then
			build_fileop mkdir ${PKG_SUBDIR};
		fi;
		if [ "${PKG_FNAME##*.tar.}" = "bz2" ]; then
			bunzip2 -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
		elif [ "${PKG_FNAME##*.tar.}" = "gz" ]; then
			gunzip -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
		elif [ "${PKG_FNAME##*.tar.}" = "xz" ]; then
			xz -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
		elif [ "${PKG_FNAME##*.t}" = "bz2" ]; then
			bunzip2 -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
		elif [ "${PKG_FNAME##*.t}" = "gz" ]; then
			gunzip -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
		elif [ "${PKG_FNAME##*.t}" = "xz" ]; then
			xz -d < ${DLCACHEDIR}/${PKG_FNAME} | tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf -;
		else
			tar ${PKG_SUBDIR_CREATE:+-C ${PKG_SUBDIR}} -xf ${DLCACHEDIR}/${PKG_FNAME};
		fi;
		if test_cmd pkg_${PKG_NAME}_extract_post; then
			pkg_${PKG_NAME}_extract_post;
		fi;
	fi;
};

# vim:filetype=sh