/[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.3 - (hide annotations) (download)
Sat Mar 23 10:24:42 2013 UTC (16 months, 1 week ago) by scarabeus
Branch: MAIN
Changes since 1.2: +2 -8 lines
Do not use-default here as we enable it by profile variable.

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

  ViewVC Help
Powered by ViewVC 1.1.20