1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: office-ext-r1.eclass
6 # The office team <openoffice@gentoo.org>
8 # Tomáš Chvátal <scarabeus@gentoo.org>
9 # @BLURB: Eclass for installing libreoffice/openoffice extensions
11 # Eclass for easing maitenance of libreoffice/openoffice extensions.
14 5|6) OEXT_EXPORTED_FUNCTIONS="src_unpack src_install pkg_postinst pkg_prerm" ;;
15 *) die "EAPI=${EAPI} is not supported" ;;
18 inherit eutils multilib
20 # @ECLASS-VARIABLE: OFFICE_REQ_USE
22 # Useflags required on office implementation for the extension.
26 # OFFICE_REQ_USE="java,jemalloc(-)?"
28 if [[ ${OFFICE_REQ_USE} ]]; then
29 # Append the brackets for the depend bellow
30 OFFICE_REQ_USE="[${OFFICE_REQ_USE}]"
33 # @ECLASS-VARIABLE: OFFICE_IMPLEMENTATIONS
35 # List of implementations supported by the extension.
36 # Some work only for libreoffice and vice versa.
37 # Default value is all implementations.
41 # OFFICE_IMPLEMENTATIONS=( "libreoffice" "openoffice" )
43 [[ -z ${OFFICE_IMPLEMENTATIONS} ]] && OFFICE_IMPLEMENTATIONS=( "libreoffice" "openoffice" )
45 # @ECLASS-VARIABLE: OFFICE_EXTENSIONS
48 # Array containing list of extensions to install.
52 # OFFICE_EXTENSIONS=( ${PN}_${PV}.oxt )
54 [[ -z ${OFFICE_EXTENSIONS} ]] && die "OFFICE_EXTENSIONS variable is unset."
55 if [[ "$(declare -p OFFICE_EXTENSIONS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
56 die "OFFICE_EXTENSIONS variable is not an array."
59 # @ECLASS-VARIABLE: OFFICE_EXTENSIONS_LOCATION
61 # Path to the extensions location. Defaults to ${DISTDIR}.
65 # OFFICE_EXTENSIONS_LOCATION="${S}/unpacked/"
67 : ${OFFICE_EXTENSIONS_LOCATION:=${DISTDIR}}
72 for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
73 IUSE+=" office_implementation_${i}"
74 if [[ ${i} == "openoffice" ]]; then
77 office_implementation_openoffice? (
78 app-office/openoffice-bin${OFFICE_REQ_USE}
83 office_implementation_${i}? (
85 app-office/${i}${OFFICE_REQ_USE}
86 app-office/${i}-bin${OFFICE_REQ_USE}
94 for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
95 REQUIRED_USE+=" office_implementation_${i} "
103 # Most projects actually do not provide any relevant sourcedir as they are oxt.
106 # @FUNCTION: office-ext-r1_src_unpack
108 # Flush the cache after removal of an extension.
109 office-ext-r1_src_unpack() {
110 debug-print-function ${FUNCNAME} "$@"
115 for i in ${OFFICE_EXTENSIONS[@]}; do
116 # Unpack the extensions where required and add case for oxt
117 # which should be most common case for the extensions.
118 if [[ -f "${OFFICE_EXTENSIONS_LOCATION}/${i}" ]] ; then
121 mkdir -p "${WORKDIR}/${i}/"
122 pushd "${WORKDIR}/${i}/" > /dev/null
123 echo ">>> Unpacking "${OFFICE_EXTENSIONS_LOCATION}/${i}" to ${PWD}"
124 unzip -qo ${OFFICE_EXTENSIONS_LOCATION}/${i}
125 assert "failed unpacking ${OFFICE_EXTENSIONS_LOCATION}/${i}"
134 # @FUNCTION: office-ext-r1_src_install
136 # Install the extension source to the proper location.
137 office-ext-r1_src_install() {
138 debug-print-function ${FUNCNAME} "$@"
139 debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
143 for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
144 if use office_implementation_${i}; then
145 if [[ ${i} == openoffice ]]; then
146 # OOO needs to use uno because direct deployment segfaults.
147 # This is bug by their side, but i don't want to waste time
149 insinto /usr/$(get_libdir)/${i}/share/extension/install
150 for j in ${OFFICE_EXTENSIONS[@]}; do
151 doins ${OFFICE_EXTENSIONS_LOCATION}/${j}
154 for j in ${OFFICE_EXTENSIONS[@]}; do
155 pushd "${WORKDIR}/${j}/" > /dev/null
156 insinto /usr/$(get_libdir)/${i}/share/extensions/${j/.oxt/}
165 #### OPENOFFICE COMPAT CODE
167 UNOPKG_BINARY="/usr/lib64/openoffice/program/unopkg"
169 # @FUNCTION: office-ext-r1_add_extension
171 # Install the extension into the libreoffice/openoffice.
172 office-ext-r1_add_extension() {
173 debug-print-function ${FUNCNAME} "$@"
175 local tmpdir=$(emktemp -d)
177 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
178 ebegin "Adding office extension: \"${ext}\""
179 ${UNOPKG_BINARY} add --suppress-license \
181 "-env:UserInstallation=file:///${tmpdir}" \
182 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
184 ${UNOPKG_BINARY} list --shared > /dev/null
188 # @FUNCTION: office-ext-r1_remove_extension
190 # Remove the extension from the libreoffice/openoffice.
191 office-ext-r1_remove_extension() {
192 debug-print-function ${FUNCNAME} "$@"
194 local tmpdir=$(mktemp -d --tmpdir="${T}")
196 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
197 ebegin "Removing office extension: \"${ext}\""
198 ${UNOPKG_BINARY} remove --suppress-license \
200 "-env:UserInstallation=file:///${tmpdir}" \
201 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
203 ${UNOPKG_BINARY} list --shared > /dev/null
207 # @FUNCTION: office-ext-r1_pkg_postinst
209 # Add the extensions to the openoffice.
210 office-ext-r1_pkg_postinst() {
211 if in_iuse office_implementation_openoffice && use office_implementation_openoffice; then
212 debug-print-function ${FUNCNAME} "$@"
213 debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
216 for i in ${OFFICE_EXTENSIONS[@]}; do
217 office-ext-r1_add_extension "/usr/lib64/openoffice/share/extension/install/${i}"
222 # @FUNCTION: office-ext-r1_pkg_prerm
224 # Remove the extensions from the openoffice.
225 office-ext-r1_pkg_prerm() {
226 if in_iuse office_implementation_openoffice && use office_implementation_openoffice; then
227 debug-print-function ${FUNCNAME} "$@"
228 debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
231 for i in ${OFFICE_EXTENSIONS[@]}; do
232 office-ext-r1_remove_extension "${i}"
237 EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
238 unset OEXT_EXPORTED_FUNCTIONS