1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: office-ext-r1.eclass
7 # The office team <openoffice@gentoo.org>
9 # Tomáš Chvátal <scarabeus@gentoo.org>
10 # @BLURB: Eclass for installing libreoffice/openoffice extensions
12 # Eclass for easing maitenance of libreoffice/openoffice extensions.
15 5) OEXT_EXPORTED_FUNCTIONS="src_unpack src_install pkg_postinst pkg_prerm" ;;
16 *) die "EAPI=${EAPI} is not supported" ;;
19 inherit eutils multilib
21 # @ECLASS-VARIABLE: OFFICE_REQ_USE
23 # Useflags required on office implementation for the extension.
27 # OFFICE_REQ_USE="java,jemalloc(-)?"
29 if [[ ${OFFICE_REQ_USE} ]]; then
30 # Append the brackets for the depend bellow
31 OFFICE_REQ_USE="[${OFFICE_REQ_USE}]"
34 # @ECLASS-VARIABLE: OFFICE_IMPLEMENTATIONS
36 # List of implementations supported by the extension.
37 # Some work only for libreoffice and vice versa.
38 # Default value is all implementations.
42 # OFFICE_IMPLEMENTATIONS=( "libreoffice" "openoffice" )
44 [[ -z ${OFFICE_IMPLEMENTATIONS} ]] && OFFICE_IMPLEMENTATIONS=( "libreoffice" "openoffice" )
46 # @ECLASS-VARIABLE: OFFICE_EXTENSIONS
49 # Array containing list of extensions to install.
53 # OFFICE_EXTENSIONS=( ${PN}_${PV}.oxt )
55 [[ -z ${OFFICE_EXTENSIONS} ]] && die "OFFICE_EXTENSIONS variable is unset."
56 if [[ "$(declare -p OFFICE_EXTENSIONS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
57 die "OFFICE_EXTENSIONS variable is not an array."
60 # @ECLASS-VARIABLE: OFFICE_EXTENSIONS_LOCATION
62 # Path to the extensions location. Defaults to ${DISTDIR}.
66 # OFFICE_EXTENSIONS_LOCATION="${S}/unpacked/"
68 : ${OFFICE_EXTENSIONS_LOCATION:=${DISTDIR}}
73 for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
74 IUSE+=" office_implementation_${i}"
76 office_implementation_${i}? (
78 app-office/${i}${OFFICE_REQ_USE}
79 app-office/${i}-bin${OFFICE_REQ_USE}
86 for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
87 REQUIRED_USE+=" office_implementation_${i} "
95 # Most projects actually do not provide any relevant sourcedir as they are oxt.
98 # @FUNCTION: office-ext-r1_src_unpack
100 # Flush the cache after removal of an extension.
101 office-ext-r1_src_unpack() {
102 debug-print-function ${FUNCNAME} "$@"
107 for i in ${OFFICE_EXTENSIONS[@]}; do
108 # Unpack the extensions where required and add case for oxt
109 # which should be most common case for the extensions.
110 if [[ -f "${OFFICE_EXTENSIONS_LOCATION}/${i}" ]] ; then
113 mkdir -p "${WORKDIR}/${i}/"
114 pushd "${WORKDIR}/${i}/" > /dev/null
115 echo ">>> Unpacking "${OFFICE_EXTENSIONS_LOCATION}/${i}" to ${PWD}"
116 unzip -qo ${OFFICE_EXTENSIONS_LOCATION}/${i}
117 assert "failed unpacking ${OFFICE_EXTENSIONS_LOCATION}/${i}"
126 # @FUNCTION: office-ext-r1_src_install
128 # Install the extension source to the proper location.
129 office-ext-r1_src_install() {
130 debug-print-function ${FUNCNAME} "$@"
131 debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
135 for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
136 if use office_implementation_${i}; then
137 if [[ ${i} == openoffice ]]; then
138 # OOO needs to use uno because direct deployment segfaults.
139 # This is bug by their side, but i don't want to waste time
141 insinto /usr/$(get_libdir)/${i}/share/extension/install
142 for j in ${OFFICE_EXTENSIONS[@]}; do
143 doins ${OFFICE_EXTENSIONS_LOCATION}/${j}
146 for j in ${OFFICE_EXTENSIONS[@]}; do
147 pushd "${WORKDIR}/${j}/" > /dev/null
148 insinto /usr/$(get_libdir)/${i}/share/extensions/${j/.oxt/}
157 #### OPENOFFICE COMPAT CODE
159 UNOPKG_BINARY="/usr/lib64/openoffice/program/unopkg"
161 # @FUNCTION: office-ext-r1_add_extension
163 # Install the extension into the libreoffice/openoffice.
164 office-ext-r1_add_extension() {
165 debug-print-function ${FUNCNAME} "$@"
167 local tmpdir=$(emktemp -d)
169 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
170 ebegin "Adding office extension: \"${ext}\""
171 ${UNOPKG_BINARY} add --suppress-license \
173 "-env:UserInstallation=file:///${tmpdir}" \
174 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
176 ${UNOPKG_BINARY} list --shared > /dev/null
180 # @FUNCTION: office-ext-r1_remove_extension
182 # Remove the extension from the libreoffice/openoffice.
183 office-ext-r1_remove_extension() {
184 debug-print-function ${FUNCNAME} "$@"
186 local tmpdir=$(mktemp -d --tmpdir="${T}")
188 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
189 ebegin "Removing office extension: \"${ext}\""
190 ${UNOPKG_BINARY} remove --suppress-license \
192 "-env:UserInstallation=file:///${tmpdir}" \
193 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
195 ${UNOPKG_BINARY} list --shared > /dev/null
199 # @FUNCTION: office-ext-r1_pkg_postinst
201 # Add the extensions to the openoffice.
202 office-ext-r1_pkg_postinst() {
203 if in_iuse office_implementation_openoffice && use office_implementation_openoffice; then
204 debug-print-function ${FUNCNAME} "$@"
205 debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
208 for i in ${OFFICE_EXTENSIONS[@]}; do
209 office-ext-r1_add_extension "/usr/lib64/openoffice/share/extension/install/${i}"
214 # @FUNCTION: office-ext-r1_pkg_prerm
216 # Remove the extensions from the openoffice.
217 office-ext-r1_pkg_prerm() {
218 if in_iuse office_implementation_openoffice && use office_implementation_openoffice; then
219 debug-print-function ${FUNCNAME} "$@"
220 debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
223 for i in ${OFFICE_EXTENSIONS[@]}; do
224 office-ext-r1_remove_extension "${i}"
229 EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
230 unset OEXT_EXPORTED_FUNCTIONS