aboutsummaryrefslogtreecommitdiff
blob: 2706bc5509ce9afb949e7c40695b0404d8eea573 (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
#!/bin/bash
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

__module_main() {
	_unpack_main
}

_unpack_main() {
	if [[ -z "${UNPACK_FILE}" ]]
	then
		die "Unable to unpack: UNPACK_FILE not set!"
	elif [[ ! -e "${UNPACK_FILE}" ]]
	then
		die "Unable to unpack: UNPACK_FILE '${UNPACK_FILE}' does NOT exist!"
	elif [[ -z "${UNPACK_DIR}" ]]
	then
		die "Unable to unpack: UNPACK_DIR not set!"
	elif [[ ! -d "${UNPACK_DIR}" ]]
	then
		mkdir -p "${UNPACK_DIR}" || die "Failed to create '${UNPACK_DIR}'!"
	fi

	"${TAR_COMMAND}" -xaf "${UNPACK_FILE}" --directory "${UNPACK_DIR}" \
		|| die "Failed to unpack '${UNPACK_FILE}' to '${UNPACK_DIR}'!"
}