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

Contents of /eclass/office-ext.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Wed May 9 20:33:16 2012 UTC (2 years, 11 months ago) by scarabeus
Branch: MAIN
Changes since 1.3: +7 -3 lines
Update the default unpack to detect cases when oxt is packed elsewhere.

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 scarabeus 1.4 # $Header: /var/cvsroot/gentoo-x86/eclass/office-ext.eclass,v 1.3 2012/05/09 16:12:16 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 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.1 ${UNOPKG_BINARY} add --shared "${ext}" \
101     "-env:UserInstallation=file:///${tmpdir}" \
102     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
103     eend $?
104     rm -rf "${tmpdir}"
105     }
106    
107     # @FUNCTION: office-ext_remove_extension
108     # @DESCRIPTION:
109     # Remove the extension from the libreoffice/openoffice.
110     office-ext_remove_extension() {
111     debug-print-function ${FUNCNAME} "$@"
112     local ext=$1
113     local tmpdir=$(mktemp -d --tmpdir="${T}")
114    
115     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
116 scarabeus 1.2 ebegin "Removing office extension: \"${ext}\""
117 scarabeus 1.1 ${UNOPKG_BINARY} remove --shared "${ext}" \
118     "-env:UserInstallation=file:///${tmpdir}" \
119     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
120     eend $?
121 scarabeus 1.2 office-ext_flush_unopkg_cache
122 scarabeus 1.1 rm -rf "${tmpdir}"
123     }
124    
125     # @FUNCTION: office-ext_src_install
126     # @DESCRIPTION:
127     # Install the extension source to the proper location.
128     office-ext_src_install() {
129     debug-print-function ${FUNCNAME} "$@"
130 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
131 scarabeus 1.1 local i
132    
133     # subshell to not pollute rest of the env with the insinto redefinition
134     (
135 scarabeus 1.2 dodir $(office-ext_get_implementation)/share/extension/install/
136     insinto $(office-ext_get_implementation)/share/extension/install/
137     for i in ${OO_EXTENSIONS[@]}; do
138 scarabeus 1.1 doins "${i}"
139     done
140     )
141    
142     einfo "Remember that if you replace your office implementation,"
143     einfo "you need to recompile all the extensions."
144     einfo "Your current implementation location is: "
145 scarabeus 1.2 einfo " $(office-ext_get_implementation)"
146 scarabeus 1.1 }
147    
148     # @FUNCTION: office-ext_pkg_postinst
149     # @DESCRIPTION:
150     # Add the extensions to the libreoffice/openoffice.
151     office-ext_pkg_postinst() {
152     debug-print-function ${FUNCNAME} "$@"
153 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
154 scarabeus 1.1 local i
155    
156 scarabeus 1.2 for i in ${OO_EXTENSIONS[@]}; do
157     office-ext_add_extension "$(office-ext_get_implementation)/share/extension/install/${i}"
158 scarabeus 1.1 done
159    
160     }
161    
162     # @FUNCTION: office-ext_pkg_prerm
163     # @DESCRIPTION:
164     # Remove the extensions from the libreoffice/openoffice.
165     office-ext_pkg_prerm() {
166     debug-print-function ${FUNCNAME} "$@"
167 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
168 scarabeus 1.1 local i
169    
170 scarabeus 1.2 for i in ${OO_EXTENSIONS[@]}; do
171     office-ext_remove_extension "${i}"
172 scarabeus 1.1 done
173     }
174 scarabeus 1.2
175     EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
176     unset OEXT_EXPORTED_FUNCTIONS

  ViewVC Help
Powered by ViewVC 1.1.20