| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2012 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/office-ext.eclass,v 1.1 2011/09/05 08:25:58 scarabeus Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/office-ext.eclass,v 1.7 2012/09/27 16:35:41 axs Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: office-ext.eclass |
5 | # @ECLASS: office-ext.eclass |
|
|
6 | # @MAINTAINER: |
|
|
7 | # The office team <openoffice@gentoo.org> |
| 6 | # @AUTHOR: |
8 | # @AUTHOR: |
| 7 | # Tomáš Chvátal <scarabeus@gentoo.org> |
9 | # Tomáš Chvátal <scarabeus@gentoo.org> |
| 8 | # @MAINTAINER: |
|
|
| 9 | # The office team <openoffice@gentoo.org> |
|
|
| 10 | # @BLURB: Eclass for installing libreoffice/openoffice extensions |
10 | # @BLURB: Eclass for installing libreoffice/openoffice extensions |
| 11 | # @DESCRIPTION: |
11 | # @DESCRIPTION: |
| 12 | # Eclass for easing maitenance of libreoffice/openoffice extensions. |
12 | # Eclass for easing maitenance of libreoffice/openoffice extensions. |
| 13 | |
13 | |
| 14 | case "${EAPI:-0}" in |
14 | case "${EAPI:-0}" in |
| 15 | 4) OEXT_EXPORTED_FUNCTIONS="src_install pkg_postinst pkg_prerm" ;; |
15 | 4|5) OEXT_EXPORTED_FUNCTIONS="src_unpack src_install pkg_postinst pkg_prerm" ;; |
| 16 | *) die "EAPI=${EAPI} is not supported" ;; |
16 | *) die "EAPI=${EAPI} is not supported" ;; |
| 17 | esac |
17 | esac |
| 18 | |
|
|
| 19 | EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS} |
|
|
| 20 | unset OEXT_EXPORTED_FUNCTIONS |
|
|
| 21 | |
18 | |
| 22 | inherit eutils multilib |
19 | inherit eutils multilib |
| 23 | |
20 | |
| 24 | UNOPKG_BINARY="${EPREFIX}/usr/bin/unopkg" |
21 | UNOPKG_BINARY="${EPREFIX}/usr/bin/unopkg" |
| 25 | |
22 | |
| … | |
… | |
| 32 | die "OO_EXTENSIONS variable is not an array." |
29 | die "OO_EXTENSIONS variable is not an array." |
| 33 | fi |
30 | fi |
| 34 | |
31 | |
| 35 | DEPEND="virtual/ooo" |
32 | DEPEND="virtual/ooo" |
| 36 | RDEPEND="virtual/ooo" |
33 | RDEPEND="virtual/ooo" |
|
|
34 | |
|
|
35 | # 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 | # 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 | done |
|
|
56 | } |
| 37 | |
57 | |
| 38 | # @FUNCTION: office-ext_flush_unopkg_cache |
58 | # @FUNCTION: office-ext_flush_unopkg_cache |
| 39 | # @DESCRIPTION: |
59 | # @DESCRIPTION: |
| 40 | # Flush the cache after removal of an extension. |
60 | # Flush the cache after removal of an extension. |
| 41 | office-ext_flush_unopkg_cache() { |
61 | office-ext_flush_unopkg_cache() { |
| … | |
… | |
| 74 | debug-print-function ${FUNCNAME} "$@" |
94 | debug-print-function ${FUNCNAME} "$@" |
| 75 | local ext=$1 |
95 | local ext=$1 |
| 76 | local tmpdir=$(mktemp -d --tmpdir="${T}") |
96 | local tmpdir=$(mktemp -d --tmpdir="${T}") |
| 77 | |
97 | |
| 78 | debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\"" |
98 | debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\"" |
| 79 | ebegin "Adding extension: \"${ext}\"" |
99 | ebegin "Adding office extension: \"${ext}\"" |
| 80 | ${UNOPKG_BINARY} add --shared "${ext}" \ |
100 | ${UNOPKG_BINARY} add --suppress-license \ |
|
|
101 | --shared "${ext}" \ |
| 81 | "-env:UserInstallation=file:///${tmpdir}" \ |
102 | "-env:UserInstallation=file:///${tmpdir}" \ |
| 82 | "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1" |
103 | "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1" |
| 83 | eend $? |
104 | eend $? |
| 84 | rm -rf "${tmpdir}" |
105 | rm -rf "${tmpdir}" |
| 85 | } |
106 | } |
| … | |
… | |
| 91 | debug-print-function ${FUNCNAME} "$@" |
112 | debug-print-function ${FUNCNAME} "$@" |
| 92 | local ext=$1 |
113 | local ext=$1 |
| 93 | local tmpdir=$(mktemp -d --tmpdir="${T}") |
114 | local tmpdir=$(mktemp -d --tmpdir="${T}") |
| 94 | |
115 | |
| 95 | debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\"" |
116 | debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\"" |
| 96 | ebegin "Removing extension: \"${ext}\"" |
117 | ebegin "Removing office extension: \"${ext}\"" |
| 97 | ${UNOPKG_BINARY} remove --shared "${ext}" \ |
118 | ${UNOPKG_BINARY} remove --suppress-license \ |
|
|
119 | --shared "${ext}" \ |
| 98 | "-env:UserInstallation=file:///${tmpdir}" \ |
120 | "-env:UserInstallation=file:///${tmpdir}" \ |
| 99 | "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1" |
121 | "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1" |
| 100 | eend $? |
122 | eend $? |
| 101 | flush_unopkg_cache |
123 | office-ext_flush_unopkg_cache |
| 102 | rm -rf "${tmpdir}" |
124 | rm -rf "${tmpdir}" |
| 103 | } |
125 | } |
| 104 | |
126 | |
| 105 | # @FUNCTION: office-ext_src_install |
127 | # @FUNCTION: office-ext_src_install |
| 106 | # @DESCRIPTION: |
128 | # @DESCRIPTION: |
| 107 | # Install the extension source to the proper location. |
129 | # Install the extension source to the proper location. |
| 108 | office-ext_src_install() { |
130 | office-ext_src_install() { |
| 109 | debug-print-function ${FUNCNAME} "$@" |
131 | debug-print-function ${FUNCNAME} "$@" |
|
|
132 | debug-print "Extensions: ${OO_EXTENSIONS[@]}" |
| 110 | local i |
133 | local i |
| 111 | |
134 | |
| 112 | # subshell to not pollute rest of the env with the insinto redefinition |
135 | # subshell to not pollute rest of the env with the insinto redefinition |
| 113 | ( |
136 | ( |
|
|
137 | dodir $(office-ext_get_implementation)/share/extension/install/ |
| 114 | insinto $(openoffice-ext_get_implementation)/share/extension/install/ |
138 | insinto $(office-ext_get_implementation)/share/extension/install/ |
| 115 | for i in "${OO_EXTENSIONS[@]}"; do |
139 | for i in ${OO_EXTENSIONS[@]}; do |
| 116 | doins "${i}" |
140 | doins "${i}" |
| 117 | done |
141 | done |
| 118 | ) |
142 | ) |
| 119 | |
143 | |
| 120 | einfo "Remember that if you replace your office implementation," |
144 | einfo "Remember that if you replace your office implementation," |
| 121 | einfo "you need to recompile all the extensions." |
145 | einfo "you need to recompile all the extensions." |
| 122 | einfo "Your current implementation location is: " |
146 | einfo "Your current implementation location is: " |
| 123 | einfo " $(openoffice-ext_get_implementation)" |
147 | einfo " $(office-ext_get_implementation)" |
| 124 | } |
148 | } |
| 125 | |
149 | |
| 126 | # @FUNCTION: office-ext_pkg_postinst |
150 | # @FUNCTION: office-ext_pkg_postinst |
| 127 | # @DESCRIPTION: |
151 | # @DESCRIPTION: |
| 128 | # Add the extensions to the libreoffice/openoffice. |
152 | # Add the extensions to the libreoffice/openoffice. |
| 129 | office-ext_pkg_postinst() { |
153 | office-ext_pkg_postinst() { |
| 130 | debug-print-function ${FUNCNAME} "$@" |
154 | debug-print-function ${FUNCNAME} "$@" |
|
|
155 | debug-print "Extensions: ${OO_EXTENSIONS[@]}" |
| 131 | local i |
156 | local i |
| 132 | |
157 | |
| 133 | for i in "${OO_EXTENSIONS[$@]}"; do |
158 | for i in ${OO_EXTENSIONS[@]}; do |
| 134 | openoffice-ext_add_extension "${i}" |
159 | office-ext_add_extension "$(office-ext_get_implementation)/share/extension/install/${i}" |
| 135 | done |
160 | done |
| 136 | |
161 | |
| 137 | } |
162 | } |
| 138 | |
163 | |
| 139 | # @FUNCTION: office-ext_pkg_prerm |
164 | # @FUNCTION: office-ext_pkg_prerm |
| 140 | # @DESCRIPTION: |
165 | # @DESCRIPTION: |
| 141 | # Remove the extensions from the libreoffice/openoffice. |
166 | # Remove the extensions from the libreoffice/openoffice. |
| 142 | office-ext_pkg_prerm() { |
167 | office-ext_pkg_prerm() { |
| 143 | debug-print-function ${FUNCNAME} "$@" |
168 | debug-print-function ${FUNCNAME} "$@" |
|
|
169 | debug-print "Extensions: ${OO_EXTENSIONS[@]}" |
| 144 | local i |
170 | local i |
| 145 | |
171 | |
| 146 | for i in "${OO_EXTENSIONS[@]}"; do |
172 | for i in ${OO_EXTENSIONS[@]}; do |
| 147 | openoffice-ext_remove_extension "${i}" |
173 | office-ext_remove_extension "${i}" |
| 148 | done |
174 | done |
| 149 | } |
175 | } |
|
|
176 | |
|
|
177 | EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS} |
|
|
178 | unset OEXT_EXPORTED_FUNCTIONS |