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

Contents of /eclass/office-ext.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Fri May 17 11:27:25 2013 UTC (19 months ago) by scarabeus
Branch: MAIN
Changes since 1.7: +3 -2 lines
Mark eclass as dead to be removed in 30 days.

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.eclass,v 1.7 2012/09/27 16:35:41 axs Exp $
4
5 # @DEAD
6 # @ECLASS: office-ext.eclass
7 # @MAINTAINER:
8 # The office team <openoffice@gentoo.org>
9 # @AUTHOR:
10 # Tomáš Chvátal <scarabeus@gentoo.org>
11 # @BLURB: Eclass for installing libreoffice/openoffice extensions
12 # @DESCRIPTION:
13 # Eclass for easing maitenance of libreoffice/openoffice extensions.
14
15 case "${EAPI:-0}" in
16 4|5) OEXT_EXPORTED_FUNCTIONS="src_unpack src_install pkg_postinst pkg_prerm" ;;
17 *) die "EAPI=${EAPI} is not supported" ;;
18 esac
19
20 inherit eutils multilib
21
22 UNOPKG_BINARY="${EPREFIX}/usr/bin/unopkg"
23
24 # @ECLASS-VARIABLE: OO_EXTENSIONS
25 # @REQUIRED
26 # @DESCRIPTION:
27 # Array containing list of extensions to install.
28 [[ -z ${OO_EXTENSIONS} ]] && die "OO_EXTENSIONS variable is unset."
29 if [[ "$(declare -p OO_EXTENSIONS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
30 die "OO_EXTENSIONS variable is not an array."
31 fi
32
33 DEPEND="virtual/ooo"
34 RDEPEND="virtual/ooo"
35
36 # Most projects actually do not provide any workdir and we do not unpack the
37 # .oxt file at all.
38 S="${WORKDIR}"
39
40 # @FUNCTION: office-ext_src_unpack
41 # @DESCRIPTION:
42 # Flush the cache after removal of an extension.
43 office-ext_src_unpack() {
44 debug-print-function ${FUNCNAME} "$@"
45 local i
46
47 default
48
49 for i in ${OO_EXTENSIONS[@]}; do
50 # Copy only if the oxt is present, sometimes they are in tarballs
51 # so we want to fail only when we do need to do the cp.
52 if [[ -f "${DISTDIR}/${i}" ]] ; then
53 debug-print "${FUNCNAME}: cp -v \"${DISTDIR}/${i}\" \"${S}\""
54 cp -v "${DISTDIR}/${i}" "${S}" || die
55 fi
56 done
57 }
58
59 # @FUNCTION: office-ext_flush_unopkg_cache
60 # @DESCRIPTION:
61 # Flush the cache after removal of an extension.
62 office-ext_flush_unopkg_cache() {
63 debug-print-function ${FUNCNAME} "$@"
64
65 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} list --shared > /dev/null"
66 ${UNOPKG_BINARY} list --shared > /dev/null
67 }
68
69 # @FUNCTION: office-ext_get_implementation
70 # @DESCRIPTION:
71 # Determine the implementation we are building against.
72 office-ext_get_implementation() {
73 debug-print-function ${FUNCNAME} "$@"
74 local implementations=(
75 "libreoffice"
76 "openoffice"
77 )
78 local i
79
80 for i in "${implementations[@]}"; do
81 if [[ -d "${EPREFIX}/usr/$(get_libdir)/${i}" ]]; then
82 debug-print "${FUNCNAME}: Determined implementation is: \"${EPREFIX}/usr/$(get_libdir)/${i}\""
83 echo "${EPREFIX}/usr/$(get_libdir)/${i}"
84 return
85 fi
86 done
87
88 die "Unable to determine libreoffice/openoffice implementation!"
89 }
90
91 # @FUNCTION: office-ext_add_extension
92 # @DESCRIPTION:
93 # Install the extension into the libreoffice/openoffice.
94 office-ext_add_extension() {
95 debug-print-function ${FUNCNAME} "$@"
96 local ext=$1
97 local tmpdir=$(mktemp -d --tmpdir="${T}")
98
99 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
100 ebegin "Adding office extension: \"${ext}\""
101 ${UNOPKG_BINARY} add --suppress-license \
102 --shared "${ext}" \
103 "-env:UserInstallation=file:///${tmpdir}" \
104 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
105 eend $?
106 rm -rf "${tmpdir}"
107 }
108
109 # @FUNCTION: office-ext_remove_extension
110 # @DESCRIPTION:
111 # Remove the extension from the libreoffice/openoffice.
112 office-ext_remove_extension() {
113 debug-print-function ${FUNCNAME} "$@"
114 local ext=$1
115 local tmpdir=$(mktemp -d --tmpdir="${T}")
116
117 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
118 ebegin "Removing office extension: \"${ext}\""
119 ${UNOPKG_BINARY} remove --suppress-license \
120 --shared "${ext}" \
121 "-env:UserInstallation=file:///${tmpdir}" \
122 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
123 eend $?
124 office-ext_flush_unopkg_cache
125 rm -rf "${tmpdir}"
126 }
127
128 # @FUNCTION: office-ext_src_install
129 # @DESCRIPTION:
130 # Install the extension source to the proper location.
131 office-ext_src_install() {
132 debug-print-function ${FUNCNAME} "$@"
133 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
134 local i
135
136 # subshell to not pollute rest of the env with the insinto redefinition
137 (
138 dodir $(office-ext_get_implementation)/share/extension/install/
139 insinto $(office-ext_get_implementation)/share/extension/install/
140 for i in ${OO_EXTENSIONS[@]}; do
141 doins "${i}"
142 done
143 )
144
145 einfo "Remember that if you replace your office implementation,"
146 einfo "you need to recompile all the extensions."
147 einfo "Your current implementation location is: "
148 einfo " $(office-ext_get_implementation)"
149 }
150
151 # @FUNCTION: office-ext_pkg_postinst
152 # @DESCRIPTION:
153 # Add the extensions to the libreoffice/openoffice.
154 office-ext_pkg_postinst() {
155 debug-print-function ${FUNCNAME} "$@"
156 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
157 local i
158
159 for i in ${OO_EXTENSIONS[@]}; do
160 office-ext_add_extension "$(office-ext_get_implementation)/share/extension/install/${i}"
161 done
162
163 }
164
165 # @FUNCTION: office-ext_pkg_prerm
166 # @DESCRIPTION:
167 # Remove the extensions from the libreoffice/openoffice.
168 office-ext_pkg_prerm() {
169 debug-print-function ${FUNCNAME} "$@"
170 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
171 local i
172
173 for i in ${OO_EXTENSIONS[@]}; do
174 office-ext_remove_extension "${i}"
175 done
176 }
177
178 EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
179 unset OEXT_EXPORTED_FUNCTIONS

  ViewVC Help
Powered by ViewVC 1.1.20