Gentoo Archives: gentoo-commits

From: "Tomas Chvatal (scarabeus)" <scarabeus@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: office-ext.eclass
Date: Mon, 05 Sep 2011 08:26:19
Message-Id: 20110905082559.0F80D20051@flycatcher.gentoo.org
1 scarabeus 11/09/05 08:25:59
2
3 Added: office-ext.eclass
4 Log:
5 initial commit of office-ext.eclass that will allow us to package {libre,open}office plugins via portage rather than per-user.
6
7 Revision Changes Path
8 1.1 eclass/office-ext.eclass
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/office-ext.eclass?rev=1.1&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/office-ext.eclass?rev=1.1&content-type=text/plain
12
13 Index: office-ext.eclass
14 ===================================================================
15 # Copyright 1999-2011 Gentoo Foundation
16 # Distributed under the terms of the GNU General Public License v2
17 # $Header: /var/cvsroot/gentoo-x86/eclass/office-ext.eclass,v 1.1 2011/09/05 08:25:58 scarabeus Exp $
18
19 # @ECLASS: office-ext.eclass
20 # @AUTHOR:
21 # Tomáš Chvátal <scarabeus@g.o>
22 # @MAINTAINER:
23 # The office team <openoffice@g.o>
24 # @BLURB: Eclass for installing libreoffice/openoffice extensions
25 # @DESCRIPTION:
26 # Eclass for easing maitenance of libreoffice/openoffice extensions.
27
28 case "${EAPI:-0}" in
29 4) OEXT_EXPORTED_FUNCTIONS="src_install pkg_postinst pkg_prerm" ;;
30 *) die "EAPI=${EAPI} is not supported" ;;
31 esac
32
33 EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
34 unset OEXT_EXPORTED_FUNCTIONS
35
36 inherit eutils multilib
37
38 UNOPKG_BINARY="${EPREFIX}/usr/bin/unopkg"
39
40 # @ECLASS-VARIABLE: OO_EXTENSIONS
41 # @REQUIRED
42 # @DESCRIPTION:
43 # Array containing list of extensions to install.
44 [[ -z ${OO_EXTENSIONS} ]] && die "OO_EXTENSIONS variable is unset."
45 if [[ "$(declare -p OO_EXTENSIONS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
46 die "OO_EXTENSIONS variable is not an array."
47 fi
48
49 DEPEND="virtual/ooo"
50 RDEPEND="virtual/ooo"
51
52 # @FUNCTION: office-ext_flush_unopkg_cache
53 # @DESCRIPTION:
54 # Flush the cache after removal of an extension.
55 office-ext_flush_unopkg_cache() {
56 debug-print-function ${FUNCNAME} "$@"
57
58 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} list --shared > /dev/null"
59 ${UNOPKG_BINARY} list --shared > /dev/null
60 }
61
62 # @FUNCTION: office-ext_get_implementation
63 # @DESCRIPTION:
64 # Determine the implementation we are building against.
65 office-ext_get_implementation() {
66 debug-print-function ${FUNCNAME} "$@"
67 local implementations=(
68 "libreoffice"
69 "openoffice"
70 )
71 local i
72
73 for i in "${implementations[@]}"; do
74 if [[ -d "${EPREFIX}/usr/$(get_libdir)/${i}" ]]; then
75 debug-print "${FUNCNAME}: Determined implementation is: \"${EPREFIX}/usr/$(get_libdir)/${i}\""
76 echo "${EPREFIX}/usr/$(get_libdir)/${i}"
77 return
78 fi
79 done
80
81 die "Unable to determine libreoffice/openoffice implementation!"
82 }
83
84 # @FUNCTION: office-ext_add_extension
85 # @DESCRIPTION:
86 # Install the extension into the libreoffice/openoffice.
87 office-ext_add_extension() {
88 debug-print-function ${FUNCNAME} "$@"
89 local ext=$1
90 local tmpdir=$(mktemp -d --tmpdir="${T}")
91
92 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
93 ebegin "Adding extension: \"${ext}\""
94 ${UNOPKG_BINARY} add --shared "${ext}" \
95 "-env:UserInstallation=file:///${tmpdir}" \
96 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
97 eend $?
98 rm -rf "${tmpdir}"
99 }
100
101 # @FUNCTION: office-ext_remove_extension
102 # @DESCRIPTION:
103 # Remove the extension from the libreoffice/openoffice.
104 office-ext_remove_extension() {
105 debug-print-function ${FUNCNAME} "$@"
106 local ext=$1
107 local tmpdir=$(mktemp -d --tmpdir="${T}")
108
109 debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
110 ebegin "Removing extension: \"${ext}\""
111 ${UNOPKG_BINARY} remove --shared "${ext}" \
112 "-env:UserInstallation=file:///${tmpdir}" \
113 "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
114 eend $?
115 flush_unopkg_cache
116 rm -rf "${tmpdir}"
117 }
118
119 # @FUNCTION: office-ext_src_install
120 # @DESCRIPTION:
121 # Install the extension source to the proper location.
122 office-ext_src_install() {
123 debug-print-function ${FUNCNAME} "$@"
124 local i
125
126 # subshell to not pollute rest of the env with the insinto redefinition
127 (
128 insinto $(openoffice-ext_get_implementation)/share/extension/install/
129 for i in "${OO_EXTENSIONS[@]}"; do
130 doins "${i}"
131 done
132 )
133
134 einfo "Remember that if you replace your office implementation,"
135 einfo "you need to recompile all the extensions."
136 einfo "Your current implementation location is: "
137 einfo " $(openoffice-ext_get_implementation)"
138 }
139
140 # @FUNCTION: office-ext_pkg_postinst
141 # @DESCRIPTION:
142 # Add the extensions to the libreoffice/openoffice.
143 office-ext_pkg_postinst() {
144 debug-print-function ${FUNCNAME} "$@"
145 local i
146
147 for i in "${OO_EXTENSIONS[$@]}"; do
148 openoffice-ext_add_extension "${i}"
149 done
150
151 }
152
153 # @FUNCTION: office-ext_pkg_prerm
154 # @DESCRIPTION:
155 # Remove the extensions from the libreoffice/openoffice.
156 office-ext_pkg_prerm() {
157 debug-print-function ${FUNCNAME} "$@"
158 local i
159
160 for i in "${OO_EXTENSIONS[@]}"; do
161 openoffice-ext_remove_extension "${i}"
162 done
163 }