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

Contents of /eclass/office-ext.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Fri Jun 8 03:36:09 2012 UTC (2 years, 2 months ago) by vapier
Branch: MAIN
Changes since 1.5: +3 -3 lines
fix order of eclass doc keywords

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

  ViewVC Help
Powered by ViewVC 1.1.20