summaryrefslogtreecommitdiff
path: root/eclass/java-war.eclass
blob: 3693da5fbc13144300bd85f6284d3af1ed2a36ef (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

#
# Original Author: beber
# Purpose: 
#

DEPEND="${DEPEND}
	app-arch/unzip"

JAVA_WAR_UNPACK_DIR="${WORKDIR}/${ECLASS}-unpack"

java-war_src_unpack() {
	[[ ${#} == 0 ]] && die "${FUNCNAME} need at least one argument"

	mkdir "${JAVA_WAR_UNPACK_DIR}" || die "Failed to create ${JAVA_WAR_UNPACK_DIR}"

	local a
	while (( $# > 0 )) ; do
		for a in "${1}" "${S}/${1}" ; do
			if [[ -e "${a}" ]] ; then
				break
			fi
		done

		if [[ -z "${a}" ]] ; then
			die "WAR file ${1} does not exist"
		fi

		local _unpack_dir="${JAVA_WAR_UNPACK_DIR}/${a/#${S}\/}"

		echo ">>> Unpacking ${a/#${S}\/} to ${_unpack_dir}"
		mkdir -p "${_unpack_dir}" \
			|| die "Failed to create ${_unpack_dir}"
		unzip -qd "${_unpack_dir}" "${a}" \
			|| die "Failed to unpack ${a}"

		shift
	done
}

java-war_src_install() {
	[[ ${#} == 0 ]] && die "${FUNCNAME} need at least one argument"

	local a
	while (( $# > 0 )) ; do
		a="${1}"

		local _unpack_dir="${JAVA_WAR_UNPACK_DIR}/${a/#${S}\/}"

		if [[ ! -d "${_unpack_dir}" ]] ; then
			die "Unable to find unpacked ${a}"
		fi

		cd "${_unpack_dir}"
		doins -r .

		shift
	done
}