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

Contents of /eclass/office-ext.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Mon Sep 5 08:25:58 2011 UTC (3 years, 3 months ago) by scarabeus
Branch: MAIN
initial commit of office-ext.eclass that will allow us to package {libre,open}office plugins via portage rather than per-user.

1 scarabeus 1.1 # Copyright 1999-2011 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3     # $Header: $
4    
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     EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
20     unset OEXT_EXPORTED_FUNCTIONS
21    
22     inherit eutils multilib
23    
24     UNOPKG_BINARY="${EPREFIX}/usr/bin/unopkg"
25    
26     # @ECLASS-VARIABLE: OO_EXTENSIONS
27     # @REQUIRED
28     # @DESCRIPTION:
29     # Array containing list of extensions to install.
30     [[ -z ${OO_EXTENSIONS} ]] && die "OO_EXTENSIONS variable is unset."
31     if [[ "$(declare -p OO_EXTENSIONS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
32     die "OO_EXTENSIONS variable is not an array."
33     fi
34    
35     DEPEND="virtual/ooo"
36     RDEPEND="virtual/ooo"
37    
38     # @FUNCTION: office-ext_flush_unopkg_cache
39     # @DESCRIPTION:
40     # Flush the cache after removal of an extension.
41     office-ext_flush_unopkg_cache() {
42     debug-print-function ${FUNCNAME} "$@"
43    
44     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} list --shared > /dev/null"
45     ${UNOPKG_BINARY} list --shared > /dev/null
46     }
47    
48     # @FUNCTION: office-ext_get_implementation
49     # @DESCRIPTION:
50     # Determine the implementation we are building against.
51     office-ext_get_implementation() {
52     debug-print-function ${FUNCNAME} "$@"
53     local implementations=(
54     "libreoffice"
55     "openoffice"
56     )
57     local i
58    
59     for i in "${implementations[@]}"; do
60     if [[ -d "${EPREFIX}/usr/$(get_libdir)/${i}" ]]; then
61     debug-print "${FUNCNAME}: Determined implementation is: \"${EPREFIX}/usr/$(get_libdir)/${i}\""
62     echo "${EPREFIX}/usr/$(get_libdir)/${i}"
63     return
64     fi
65     done
66    
67     die "Unable to determine libreoffice/openoffice implementation!"
68     }
69    
70     # @FUNCTION: office-ext_add_extension
71     # @DESCRIPTION:
72     # Install the extension into the libreoffice/openoffice.
73     office-ext_add_extension() {
74     debug-print-function ${FUNCNAME} "$@"
75     local ext=$1
76     local tmpdir=$(mktemp -d --tmpdir="${T}")
77    
78     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
79     ebegin "Adding extension: \"${ext}\""
80     ${UNOPKG_BINARY} add --shared "${ext}" \
81     "-env:UserInstallation=file:///${tmpdir}" \
82     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
83     eend $?
84     rm -rf "${tmpdir}"
85     }
86    
87     # @FUNCTION: office-ext_remove_extension
88     # @DESCRIPTION:
89     # Remove the extension from the libreoffice/openoffice.
90     office-ext_remove_extension() {
91     debug-print-function ${FUNCNAME} "$@"
92     local ext=$1
93     local tmpdir=$(mktemp -d --tmpdir="${T}")
94    
95     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
96     ebegin "Removing extension: \"${ext}\""
97     ${UNOPKG_BINARY} remove --shared "${ext}" \
98     "-env:UserInstallation=file:///${tmpdir}" \
99     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
100     eend $?
101     flush_unopkg_cache
102     rm -rf "${tmpdir}"
103     }
104    
105     # @FUNCTION: office-ext_src_install
106     # @DESCRIPTION:
107     # Install the extension source to the proper location.
108     office-ext_src_install() {
109     debug-print-function ${FUNCNAME} "$@"
110     local i
111    
112     # subshell to not pollute rest of the env with the insinto redefinition
113     (
114     insinto $(openoffice-ext_get_implementation)/share/extension/install/
115     for i in "${OO_EXTENSIONS[@]}"; do
116     doins "${i}"
117     done
118     )
119    
120     einfo "Remember that if you replace your office implementation,"
121     einfo "you need to recompile all the extensions."
122     einfo "Your current implementation location is: "
123     einfo " $(openoffice-ext_get_implementation)"
124     }
125    
126     # @FUNCTION: office-ext_pkg_postinst
127     # @DESCRIPTION:
128     # Add the extensions to the libreoffice/openoffice.
129     office-ext_pkg_postinst() {
130     debug-print-function ${FUNCNAME} "$@"
131     local i
132    
133     for i in "${OO_EXTENSIONS[$@]}"; do
134     openoffice-ext_add_extension "${i}"
135     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     local i
145    
146     for i in "${OO_EXTENSIONS[@]}"; do
147     openoffice-ext_remove_extension "${i}"
148     done
149     }

  ViewVC Help
Powered by ViewVC 1.1.20