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

Contents of /eclass/office-ext.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Wed May 9 16:12:16 2012 UTC (2 years, 2 months ago) by scarabeus
Branch: MAIN
Changes since 1.2: +22 -3 lines
Add the src_unpack phase for office-ext eclass.

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.3 # $Header: /var/cvsroot/gentoo-x86/eclass/office-ext.eclass,v 1.2 2011/11/12 12:03:05 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     debug-print "${FUNCNAME}: cp -v \"${DISTDIR}/${i}\" \"${S}\""
50     cp -v "${DISTDIR}/${i}" "${S}" || die
51     done
52     }
53    
54 scarabeus 1.1 # @FUNCTION: office-ext_flush_unopkg_cache
55     # @DESCRIPTION:
56     # Flush the cache after removal of an extension.
57     office-ext_flush_unopkg_cache() {
58     debug-print-function ${FUNCNAME} "$@"
59    
60     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} list --shared > /dev/null"
61     ${UNOPKG_BINARY} list --shared > /dev/null
62     }
63    
64     # @FUNCTION: office-ext_get_implementation
65     # @DESCRIPTION:
66     # Determine the implementation we are building against.
67     office-ext_get_implementation() {
68     debug-print-function ${FUNCNAME} "$@"
69     local implementations=(
70     "libreoffice"
71     "openoffice"
72     )
73     local i
74    
75     for i in "${implementations[@]}"; do
76     if [[ -d "${EPREFIX}/usr/$(get_libdir)/${i}" ]]; then
77     debug-print "${FUNCNAME}: Determined implementation is: \"${EPREFIX}/usr/$(get_libdir)/${i}\""
78     echo "${EPREFIX}/usr/$(get_libdir)/${i}"
79     return
80     fi
81     done
82    
83     die "Unable to determine libreoffice/openoffice implementation!"
84     }
85    
86     # @FUNCTION: office-ext_add_extension
87     # @DESCRIPTION:
88     # Install the extension into the libreoffice/openoffice.
89     office-ext_add_extension() {
90     debug-print-function ${FUNCNAME} "$@"
91     local ext=$1
92     local tmpdir=$(mktemp -d --tmpdir="${T}")
93    
94     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
95 scarabeus 1.2 ebegin "Adding office extension: \"${ext}\""
96 scarabeus 1.1 ${UNOPKG_BINARY} add --shared "${ext}" \
97     "-env:UserInstallation=file:///${tmpdir}" \
98     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
99     eend $?
100     rm -rf "${tmpdir}"
101     }
102    
103     # @FUNCTION: office-ext_remove_extension
104     # @DESCRIPTION:
105     # Remove the extension from the libreoffice/openoffice.
106     office-ext_remove_extension() {
107     debug-print-function ${FUNCNAME} "$@"
108     local ext=$1
109     local tmpdir=$(mktemp -d --tmpdir="${T}")
110    
111     debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
112 scarabeus 1.2 ebegin "Removing office extension: \"${ext}\""
113 scarabeus 1.1 ${UNOPKG_BINARY} remove --shared "${ext}" \
114     "-env:UserInstallation=file:///${tmpdir}" \
115     "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
116     eend $?
117 scarabeus 1.2 office-ext_flush_unopkg_cache
118 scarabeus 1.1 rm -rf "${tmpdir}"
119     }
120    
121     # @FUNCTION: office-ext_src_install
122     # @DESCRIPTION:
123     # Install the extension source to the proper location.
124     office-ext_src_install() {
125     debug-print-function ${FUNCNAME} "$@"
126 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
127 scarabeus 1.1 local i
128    
129     # subshell to not pollute rest of the env with the insinto redefinition
130     (
131 scarabeus 1.2 dodir $(office-ext_get_implementation)/share/extension/install/
132     insinto $(office-ext_get_implementation)/share/extension/install/
133     for i in ${OO_EXTENSIONS[@]}; do
134 scarabeus 1.1 doins "${i}"
135     done
136     )
137    
138     einfo "Remember that if you replace your office implementation,"
139     einfo "you need to recompile all the extensions."
140     einfo "Your current implementation location is: "
141 scarabeus 1.2 einfo " $(office-ext_get_implementation)"
142 scarabeus 1.1 }
143    
144     # @FUNCTION: office-ext_pkg_postinst
145     # @DESCRIPTION:
146     # Add the extensions to the libreoffice/openoffice.
147     office-ext_pkg_postinst() {
148     debug-print-function ${FUNCNAME} "$@"
149 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
150 scarabeus 1.1 local i
151    
152 scarabeus 1.2 for i in ${OO_EXTENSIONS[@]}; do
153     office-ext_add_extension "$(office-ext_get_implementation)/share/extension/install/${i}"
154 scarabeus 1.1 done
155    
156     }
157    
158     # @FUNCTION: office-ext_pkg_prerm
159     # @DESCRIPTION:
160     # Remove the extensions from the libreoffice/openoffice.
161     office-ext_pkg_prerm() {
162     debug-print-function ${FUNCNAME} "$@"
163 scarabeus 1.2 debug-print "Extensions: ${OO_EXTENSIONS[@]}"
164 scarabeus 1.1 local i
165    
166 scarabeus 1.2 for i in ${OO_EXTENSIONS[@]}; do
167     office-ext_remove_extension "${i}"
168 scarabeus 1.1 done
169     }
170 scarabeus 1.2
171     EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
172     unset OEXT_EXPORTED_FUNCTIONS

  ViewVC Help
Powered by ViewVC 1.1.20