summaryrefslogtreecommitdiff
path: root/eclass/libreoffice-l10n-2.eclass
blob: e57c83ce5c1d38e4c02f554a8c1cce62e606d175 (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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright 2004-2012 Sabayon Linux
# Distributed under the terms of the GNU General Public License v2
# $

OO_EXTENSIONS=(
	"472ffb92d82cf502be039203c606643d-Sun-ODF-Template-Pack-en-US_1.0.0.oxt"
	"53ca5e56ccd4cab3693ad32c6bd13343-Sun-ODF-Template-Pack-de_1.0.0.oxt"
	"4ad003e7bbda5715f5f38fde1f707af2-Sun-ODF-Template-Pack-es_1.0.0.oxt"
	"a53080dc876edcddb26eb4c3c7537469-Sun-ODF-Template-Pack-fr_1.0.0.oxt"
	"09ec2dac030e1dcd5ef7fa1692691dc0-Sun-ODF-Template-Pack-hu_1.0.0.oxt"
	"b33775feda3bcf823cad7ac361fd49a6-Sun-ODF-Template-Pack-it_1.0.0.oxt"
)

inherit base rpm multilib versionator office-ext-r1

MY_LANG=${PN/libreoffice-l10n-/}
MY_LANG=${MY_LANG/_/-}

# export all the available functions here
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install pkg_postinst pkg_prerm

# @ECLASS-VARIABLE: L10N_LANG
# @DESCRIPTION:
# Localization language name
L10N_LANG="${L10N_LANG:-${MY_LANG}}"

# @ECLASS-VARIABLE: HELPPACK_AVAIL
# @DESCRIPTION:
# Set this to "0" if help pack package is not available
HELPPACK_AVAIL="${HELPPACK_AVAIL:-1}"

# @ECLASS-VARIABLE: LANGPACK_AVAIL
# @DESCRIPTION:
# Set this to "0" if lang pack package is not available
LANGPACK_AVAIL="${LANGPACK_AVAIL:-1}"

DESCRIPTION="LibreOffice.org ${L10N_LANG} localisation"
HOMEPAGE="http://www.documentfoundation.org"
RESTRICT="nomirror"

L10N_VER="$(get_version_component_range 1-3)"
L10N_RC_VERSION="rc2"
LO_BRANCH=$(get_version_component_range 1-2)

BASE_SRC_URI="http://download.documentfoundation.org/libreoffice/stable/${L10N_VER}/rpm"
SRC_URI=""
# try guessing
if [ "${LANGPACK_AVAIL}" = "1" ]; then
	SRC_URI+="${BASE_SRC_URI}/x86/LibO_${L10N_VER}_Linux_x86_langpack-rpm_${MY_LANG}.tar.gz"
fi
if [ "${HELPPACK_AVAIL}" = "1" ]; then
	SRC_URI+=" ${BASE_SRC_URI}/x86/LibO_${L10N_VER}_Linux_x86_helppack-rpm_${MY_LANG}.tar.gz"
fi

IUSE=""

EXT_URI="http://ooo.itc.hu/oxygenoffice/download/libreoffice"
TDEPEND=""
if [[ "${MY_LANG}" == "en_US" ]]; then
	for i in ${OO_EXTENSIONS[@]}; do
		TDEPEND+=" ${EXT_URI}/${i}"
	done
	SRC_URI+=" templates? ( ${TDEPEND} )"
	IUSE+=" templates"
fi

LICENSE="LGPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"

RDEPEND="=app-office/libreoffice-${LO_BRANCH}*"
DEPEND="dev-util/pkgconfig
	dev-util/intltool"

S="${WORKDIR}"

OOO_INSTDIR="/usr/$(get_libdir)/libreoffice"

libreoffice-l10n-2_src_unpack() {
	default

	local lang="${MY_LANG}"
	local dir=${lang/_/-}
	# for english we provide just helppack, as translation is always there
	if [[ "${LANGPACK_AVAIL}" == "1" ]]; then
		rpmdir="LibO_${L10N_VER}${L10N_RC_VERSION}_Linux_x86_langpack-rpm_${dir}/RPMS/"
		[[ -d ${rpmdir} ]] || die "Missing directory: \"${rpmdir}\""
		# First remove dictionaries, we want to use system ones.
		rm -rf "${S}/${rpmdir}/"*dict*.rpm
		einfo "Unpacking Langpack"
		rpm_unpack "./${rpmdir}/"*.rpm
	fi
	if [[ "${HELPPACK_AVAIL}" == "1" ]]; then
		rpmdir="LibO_${L10N_VER}${L10N_RC_VERSION}_Linux_x86_helppack-rpm_${dir}/RPMS/"
		[[ -d ${rpmdir} ]] || die "Missing directory: \"${rpmdir}\""
		einfo "Unpacking Helppack"
		rpm_unpack ./"${rpmdir}/"*.rpm
	fi
	if [[ -n "${TDEPEND}" ]]; then
		if use templates; then
			for i in ${OO_EXTENSIONS[@]}; do
				if [[ ! -f "${S}/${i}" ]]; then
					cp -v "${DISTDIR}/${i}" "${S}"
					ooextused+=( "${i}" )
				fi
                	done
		fi
	fi
	OO_EXTENSIONS=()
	for i in ${ooextused[@]}; do
		OO_EXTENSIONS+=( ${i} )
	done
}

libreoffice-l10n-2_src_prepare() { :; }
libreoffice-l10n-2_src_configure() { :; }
libreoffice-l10n-2_src_compile() { :; }

libreoffice-l10n-2_src_install() {
	local dir="${S}"/opt/libreoffice${LO_BRANCH}/
	# Condition required for people that do not install anything eg no linguas
	# or just english with no offlinehelp.
	if [[ -d "${dir}" ]] ; then
		insinto /usr/$(get_libdir)/libreoffice/
		doins -r "${dir}"/*
	fi
	# remove extensions that are in the l10n for some weird reason
	rm -rf "${ED}"/usr/$(get_libdir)/libreoffice/share/extensions/

	echo "${OO_EXTENSIONS[@]}"
	office-ext_src_install
}

libreoffice-l10n-2_pkg_postinst() {
	office-ext_pkg_postinst
}
libreoffice-l10n-2_pkg_prerm() {
	office-ext_pkg_prerm
}