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

Contents of /eclass/office-ext.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sat Nov 12 12:03:05 2011 UTC (6 years ago) by scarabeus
Branch: MAIN
Changes since 1.1: +18 -14 lines
Multiple fixups of array handling.

1 scarabeus 1.1 # Copyright 1999-2011 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.eclass,v 1.1 2011/09/05 08:25:58 scarabeus Exp $
4 scarabeus 1.1
5     # @ECLASS: office-ext.eclass
6     # @AUTHOR:
7     # Tomáš Chvátal <scarabeus@gentoo.org>
8     # @MAINTAINER:
9     # The office team <openoffice@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     4) OEXT_EXPORTED_FUNCTIONS="src_install pkg_postinst pkg_prerm" ;;
16     *) 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     # @FUNCTION: office-ext_flush_unopkg_cache
36     # @DESCRIPTION:
37     # Flush the cache after removal of an extension.
38     office-ext_flush_unopkg_cache() {
39     debug-print-function ${FUNCNAME} "$@"
40    
41     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} list --shared > /dev/null"
42     ${UNOPKG_BINARY} list --shared > /dev/null
43     }
44    
45     # @FUNCTION: office-ext_get_implementation
46     # @DESCRIPTION:
47     # Determine the implementation we are building against.
48     office-ext_get_implementation() {
49     debug-print-function ${FUNCNAME} "$@"
50     local implementations=(
51     "libreoffice"
52     "openoffice"
53     )
54     local i
55    
56     for i in "${implementations[@]}"; do
57     if [[ -d "${EPREFIX}/usr/$(get_libdir)/${i}" ]]; then
58     debug-print "${FUNCNAME}: Determined implementation is: \"${EPREFIX}/usr/$(get_libdir)/${i}\""
59     echo "${EPREFIX}/usr/$(get_libdir)/${i}"
60     return
61     fi
62     done
63    
64     die "Unable to determine libreoffice/openoffice implementation!"
65     }
66    
67     # @FUNCTION: office-ext_add_extension
68     # @DESCRIPTION:
69     # Install the extension into the libreoffice/openoffice.
70     office-ext_add_extension() {
71     debug-print-function ${FUNCNAME} "$@"
72     local ext=$1
73     local tmpdir=$(mktemp -d --tmpdir="${T}")
74    
75     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
76 scarabeus 1.2 ebegin "Adding office extension: \"${ext}\""
77 scarabeus 1.1 ${UNOPKG_BINARY} add --shared "${ext}" \
78     "-env:UserInstallation=file:///${tmpdir}" \
79     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
80     eend $?
81     rm -rf "${tmpdir}"
82     }
83    
84     # @FUNCTION: office-ext_remove_extension
85     # @DESCRIPTION:
86     # Remove the extension from the libreoffice/openoffice.
87     office-ext_remove_extension() {
88     debug-print-function ${FUNCNAME} "$@"
89     local ext=$1
90     local tmpdir=$(mktemp -d --tmpdir="${T}")
91    
92     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
93 scarabeus 1.2 ebegin "Removing office extension: \"${ext}\""
94 scarabeus 1.1 ${UNOPKG_BINARY} remove --shared "${ext}" \
95     "-env:UserInstallation=file:///${tmpdir}" \
96     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
97     eend $?
98 scarabeus 1.2 office-ext_flush_unopkg_cache
99 scarabeus 1.1 rm -rf "${tmpdir}"
100     }
101    
102     # @FUNCTION: office-ext_src_install
103     # @DESCRIPTION:
104     # Install the extension source to the proper location.
105     office-ext_src_install() {
106     debug-print-function ${FUNCNAME} "$@"
107 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
108 scarabeus 1.1 local i
109    
110     # subshell to not pollute rest of the env with the insinto redefinition
111     (
112 scarabeus 1.2 dodir $(office-ext_get_implementation)/share/extension/install/
113     insinto $(office-ext_get_implementation)/share/extension/install/
114     for i in ${OO_EXTENSIONS[@]}; do
115 scarabeus 1.1 doins "${i}"
116     done
117     )
118    
119     einfo "Remember that if you replace your office implementation,"
120     einfo "you need to recompile all the extensions."
121     einfo "Your current implementation location is: "
122 scarabeus 1.2 einfo " $(office-ext_get_implementation)"
123 scarabeus 1.1 }
124    
125     # @FUNCTION: office-ext_pkg_postinst
126     # @DESCRIPTION:
127     # Add the extensions to the libreoffice/openoffice.
128     office-ext_pkg_postinst() {
129     debug-print-function ${FUNCNAME} "$@"
130 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
131 scarabeus 1.1 local i
132    
133 scarabeus 1.2 for i in ${OO_EXTENSIONS[@]}; do
134     office-ext_add_extension "$(office-ext_get_implementation)/share/extension/install/${i}"
135 scarabeus 1.1 done
136    
137     }
138    
139     # @FUNCTION: office-ext_pkg_prerm
140     # @DESCRIPTION:
141     # Remove the extensions from the libreoffice/openoffice.
142     office-ext_pkg_prerm() {
143     debug-print-function ${FUNCNAME} "$@"
144 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
145 scarabeus 1.1 local i
146    
147 scarabeus 1.2 for i in ${OO_EXTENSIONS[@]}; do
148     office-ext_remove_extension "${i}"
149 scarabeus 1.1 done
150     }
151 scarabeus 1.2
152     EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
153     unset OEXT_EXPORTED_FUNCTIONS

  ViewVC Help
Powered by ViewVC 1.1.20