/[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.2 - (hide annotations) (download)
Sat Mar 23 10:19:39 2013 UTC (20 months ago) by scarabeus
Branch: MAIN
Changes since 1.1: +2 -2 lines
Fix stupid copy&paste.

1 scarabeus 1.1 # Copyright 1999-2013 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 scarabeus 1.2 # $Header: /var/cvsroot/gentoo-x86/eclass/office-ext-r1.eclass,v 1.1 2013/03/23 10:16:57 scarabeus Exp $
4 scarabeus 1.1
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 scarabeus 1.2 OFFICE_REQ_USE="[${OFFICE_REQ_USE}]"
32 scarabeus 1.1 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     IUSE=""
61     RDEPEND=""
62    
63     for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
64     # Set default on for the libreoffice implementation.
65     # Or if we have just one impl set it also on enabled.
66     if [[ ${i} == libreoffice || ${#OFFICE_IMPLEMENTATIONS[@]} == 1 ]]; then
67     IUSE+=" +office_implementation_${i}"
68     else
69     IUSE+=" office_implementation_${i}"
70     fi
71     RDEPEND+="
72     office_implementation_${i}? (
73     || (
74     app-office/${i}${OFFICE_REQ_USE}
75     app-office/${i}-bin${OFFICE_REQ_USE}
76     )
77     )
78     "
79     done
80    
81     REQUIRED_USE="|| ( "
82     for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
83     REQUIRED_USE+=" office_implementation_${i} "
84     done
85     REQUIRED_USE+=" )"
86    
87     DEPEND="${RDEPEND}
88     app-arch/unzip
89     "
90    
91     # Most projects actually do not provide any relevant sourcedir as they are oxt.
92     S="${WORKDIR}"
93    
94     # @FUNCTION: office-ext-r1_src_unpack
95     # @DESCRIPTION:
96     # Flush the cache after removal of an extension.
97     office-ext-r1_src_unpack() {
98     debug-print-function ${FUNCNAME} "$@"
99     local i
100    
101     default
102    
103     for i in ${OFFICE_EXTENSIONS[@]}; do
104     # Unpack the extensions where required and add case for oxt
105     # which should be most common case for the extensions.
106     if [[ -f "${DISTDIR}/${i}" ]] ; then
107     case ${i} in
108     *.oxt)
109     echo ">>> Unpacking "${DISTDIR}/${i}" to ${PWD}"
110     unzip -qo ${DISTDIR}/${i}
111     assert "failed unpacking ${DISTDIR}/${i}"
112     ;;
113     *) unpack ${i} ;;
114     esac
115     fi
116     done
117     }
118    
119     # @FUNCTION: office-ext-r1_src_install
120     # @DESCRIPTION:
121     # Install the extension source to the proper location.
122     office-ext-r1_src_install() {
123     debug-print-function ${FUNCNAME} "$@"
124     debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
125    
126     local i j
127    
128     for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
129     if use office_implementation_${i}; then
130     if [[ ${i} == openoffice ]]; then
131     # OOO needs to use uno because direct deployment segfaults.
132     # This is bug by their side, but i don't want to waste time
133     # fixing it myself.
134     insinto /usr/$(get_libdir)/${i}/share/extension/install
135     for j in ${OFFICE_EXTENSIONS[@]}; do
136     doins ${DISTDIR}/${j}
137     done
138     else
139     insinto /usr/$(get_libdir)/${i}/share/extensions/${PN}
140     doins -r *
141     fi
142     fi
143     done
144     }
145    
146     #### OPENOFFICE COMPAT CODE
147    
148     UNOPKG_BINARY="/usr/lib64/openoffice/program/unopkg"
149    
150     # @FUNCTION: office-ext-r1_add_extension
151     # @DESCRIPTION:
152     # Install the extension into the libreoffice/openoffice.
153     office-ext-r1_add_extension() {
154     debug-print-function ${FUNCNAME} "$@"
155     local ext=$1
156     local tmpdir=$(mktemp -d --tmpdir="${T}")
157    
158     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
159     ebegin "Adding office extension: \"${ext}\""
160     ${UNOPKG_BINARY} add --suppress-license \
161     --shared "${ext}" \
162     "-env:UserInstallation=file:///${tmpdir}" \
163     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
164     eend $?
165     ${UNOPKG_BINARY} list --shared > /dev/null
166     rm -rf "${tmpdir}"
167     }
168    
169     # @FUNCTION: office-ext-r1_remove_extension
170     # @DESCRIPTION:
171     # Remove the extension from the libreoffice/openoffice.
172     office-ext-r1_remove_extension() {
173     debug-print-function ${FUNCNAME} "$@"
174     local ext=$1
175     local tmpdir=$(mktemp -d --tmpdir="${T}")
176    
177     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
178     ebegin "Removing office extension: \"${ext}\""
179     ${UNOPKG_BINARY} remove --suppress-license \
180     --shared "${ext}" \
181     "-env:UserInstallation=file:///${tmpdir}" \
182     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
183     eend $?
184     ${UNOPKG_BINARY} list --shared > /dev/null
185     rm -rf "${tmpdir}"
186     }
187    
188     # @FUNCTION: office-ext-r1_pkg_postinst
189     # @DESCRIPTION:
190     # Add the extensions to the openoffice.
191     office-ext-r1_pkg_postinst() {
192     if in_iuse office_implementation_openoffice && use office_implementation_openoffice; then
193     debug-print-function ${FUNCNAME} "$@"
194     debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
195     local i
196    
197     for i in ${OFFICE_EXTENSIONS[@]}; do
198     office-ext-r1_add_extension "/usr/lib64/openoffice/share/extension/install/${i}"
199     done
200     fi
201     }
202    
203     # @FUNCTION: office-ext-r1_pkg_prerm
204     # @DESCRIPTION:
205     # Remove the extensions from the openoffice.
206     office-ext-r1_pkg_prerm() {
207     if in_iuse office_implementation_openoffice && use office_implementation_openoffice; then
208     debug-print-function ${FUNCNAME} "$@"
209     debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
210     local i
211    
212     for i in ${OFFICE_EXTENSIONS[@]}; do
213     office-ext-r1_remove_extension "${i}"
214     done
215     fi
216     }
217    
218     EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
219     unset OEXT_EXPORTED_FUNCTIONS

  ViewVC Help
Powered by ViewVC 1.1.20