/[gentoo-x86]/eclass/office-ext-r1.eclass
Gentoo

Contents of /eclass/office-ext-r1.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Fri Mar 29 10:02:23 2013 UTC (15 months, 1 week ago) by scarabeus
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +25 -8 lines
Allow specification of directory where the extensions are. Also allow one package providing multiple oxts correctly. Wrt bug#463536.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/office-ext-r1.eclass,v 1.3 2013/03/23 10:24:42 scarabeus Exp $
4
5 # @ECLASS: office-ext-r1.eclass
6 # @MAINTAINER:
7 # The office team <openoffice@gentoo.org>
8 # @AUTHOR:
9 # Tomáš Chvátal <scarabeus@gentoo.org>
10 # @BLURB: Eclass for installing libreoffice/openoffice extensions
11 # @DESCRIPTION:
12 # Eclass for easing maitenance of libreoffice/openoffice extensions.
13
14 case "${EAPI:-0}" in
15 5) OEXT_EXPORTED_FUNCTIONS="src_unpack src_install pkg_postinst pkg_prerm" ;;
16 *) die "EAPI=${EAPI} is not supported" ;;
17 esac
18
19 inherit eutils multilib
20
21 # @ECLASS-VARIABLE: OFFICE_REQ_USE
22 # @DESCRIPTION:
23 # Useflags required on office implementation for the extension.
24 #
25 # Example:
26 # @CODE
27 # OFFICE_REQ_USE="java,jemalloc(-)?"
28 # @CODE
29 if [[ ${OFFICE_REQ_USE} ]]; then
30 # Append the brackets for the depend bellow
31 OFFICE_REQ_USE="[${OFFICE_REQ_USE}]"
32 fi
33
34 # @ECLASS-VARIABLE: OFFICE_IMPLEMENTATIONS
35 # @DESCRIPTION:
36 # List of implementations supported by the extension.
37 # Some work only for libreoffice and vice versa.
38 # Default value is all implementations.
39 #
40 # Example:
41 # @CODE
42 # OFFICE_IMPLEMENTATIONS=( "libreoffice" "openoffice" )
43 # @CODE
44 [[ -z ${OFFICE_IMPLEMENTATIONS} ]] && OFFICE_IMPLEMENTATIONS=( "libreoffice" "openoffice" )
45
46 # @ECLASS-VARIABLE: OFFICE_EXTENSIONS
47 # @REQUIRED
48 # @DESCRIPTION:
49 # Array containing list of extensions to install.
50 #
51 # Example:
52 # @CODE
53 # OFFICE_EXTENSIONS=( ${PN}_${PV}.oxt )
54 # @CODE
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."
58 fi
59
60 # @ECLASS-VARIABLE: OFFICE_EXTENSIONS_LOCATION
61 # @DESCRIPTION:
62 # Path to the extensions location. Defaults to ${DISTDIR}.
63 #
64 # Example:
65 # @CODE
66 # OFFICE_EXTENSIONS_LOCATION="${S}/unpacked/"
67 # @CODE
68 : ${OFFICE_EXTENSIONS_LOCATION:=${DISTDIR}}
69
70 IUSE=""
71 RDEPEND=""
72
73 for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
74 IUSE+=" office_implementation_${i}"
75 RDEPEND+="
76 office_implementation_${i}? (
77 || (
78 app-office/${i}${OFFICE_REQ_USE}
79 app-office/${i}-bin${OFFICE_REQ_USE}
80 )
81 )
82 "
83 done
84
85 REQUIRED_USE="|| ( "
86 for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
87 REQUIRED_USE+=" office_implementation_${i} "
88 done
89 REQUIRED_USE+=" )"
90
91 DEPEND="${RDEPEND}
92 app-arch/unzip
93 "
94
95 # Most projects actually do not provide any relevant sourcedir as they are oxt.
96 S="${WORKDIR}"
97
98 # @FUNCTION: office-ext-r1_src_unpack
99 # @DESCRIPTION:
100 # Flush the cache after removal of an extension.
101 office-ext-r1_src_unpack() {
102 debug-print-function ${FUNCNAME} "$@"
103 local i
104
105 default
106
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
111 case ${i} in
112 *.oxt)
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}"
118 popd > /dev/null
119 ;;
120 *) unpack ${i} ;;
121 esac
122 fi
123 done
124 }
125
126 # @FUNCTION: office-ext-r1_src_install
127 # @DESCRIPTION:
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[@]}"
132
133 local i j
134
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
140 # fixing it myself.
141 insinto /usr/$(get_libdir)/${i}/share/extension/install
142 for j in ${OFFICE_EXTENSIONS[@]}; do
143 doins ${OFFICE_EXTENSIONS_LOCATION}/${j}
144 done
145 else
146 for j in ${OFFICE_EXTENSIONS[@]}; do
147 pushd "${WORKDIR}/${j}/" > /dev/null
148 insinto /usr/$(get_libdir)/${i}/share/extensions/${j/.oxt/}
149 doins -r *
150 popd > /dev/null
151 done
152 fi
153 fi
154 done
155 }
156
157 #### OPENOFFICE COMPAT CODE
158
159 UNOPKG_BINARY="/usr/lib64/openoffice/program/unopkg"
160
161 # @FUNCTION: office-ext-r1_add_extension
162 # @DESCRIPTION:
163 # Install the extension into the libreoffice/openoffice.
164 office-ext-r1_add_extension() {
165 debug-print-function ${FUNCNAME} "$@"
166 local ext=$1
167 local tmpdir=$(mktemp -d --tmpdir="${T}")
168
169 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
170 ebegin "Adding office extension: \"${ext}\""
171 ${UNOPKG_BINARY} add --suppress-license \
172 --shared "${ext}" \
173 "-env:UserInstallation=file:///${tmpdir}" \
174 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
175 eend $?
176 ${UNOPKG_BINARY} list --shared > /dev/null
177 rm -rf "${tmpdir}"
178 }
179
180 # @FUNCTION: office-ext-r1_remove_extension
181 # @DESCRIPTION:
182 # Remove the extension from the libreoffice/openoffice.
183 office-ext-r1_remove_extension() {
184 debug-print-function ${FUNCNAME} "$@"
185 local ext=$1
186 local tmpdir=$(mktemp -d --tmpdir="${T}")
187
188 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
189 ebegin "Removing office extension: \"${ext}\""
190 ${UNOPKG_BINARY} remove --suppress-license \
191 --shared "${ext}" \
192 "-env:UserInstallation=file:///${tmpdir}" \
193 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
194 eend $?
195 ${UNOPKG_BINARY} list --shared > /dev/null
196 rm -rf "${tmpdir}"
197 }
198
199 # @FUNCTION: office-ext-r1_pkg_postinst
200 # @DESCRIPTION:
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[@]}"
206 local i
207
208 for i in ${OFFICE_EXTENSIONS[@]}; do
209 office-ext-r1_add_extension "/usr/lib64/openoffice/share/extension/install/${i}"
210 done
211 fi
212 }
213
214 # @FUNCTION: office-ext-r1_pkg_prerm
215 # @DESCRIPTION:
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[@]}"
221 local i
222
223 for i in ${OFFICE_EXTENSIONS[@]}; do
224 office-ext-r1_remove_extension "${i}"
225 done
226 fi
227 }
228
229 EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
230 unset OEXT_EXPORTED_FUNCTIONS

  ViewVC Help
Powered by ViewVC 1.1.20