| 1 |
# Copyright 1999-2012 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/office-ext.eclass,v 1.5 2012/05/10 09:33:59 scarabeus Exp $
|
| 4 |
|
| 5 |
# @ECLASS: office-ext.eclass
|
| 6 |
# @MAINTAINER:
|
| 7 |
# The office team <openoffice@gentoo.org>
|
| 8 |
# @AUTHOR:
|
| 9 |
# Tomáš Chvátal <scarabeus@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_unpack 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 |
# 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 |
}
|
| 57 |
|
| 58 |
# @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 |
ebegin "Adding office extension: \"${ext}\""
|
| 100 |
${UNOPKG_BINARY} add --suppress-license \
|
| 101 |
--shared "${ext}" \
|
| 102 |
"-env:UserInstallation=file:///${tmpdir}" \
|
| 103 |
"-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
|
| 104 |
eend $?
|
| 105 |
rm -rf "${tmpdir}"
|
| 106 |
}
|
| 107 |
|
| 108 |
# @FUNCTION: office-ext_remove_extension
|
| 109 |
# @DESCRIPTION:
|
| 110 |
# Remove the extension from the libreoffice/openoffice.
|
| 111 |
office-ext_remove_extension() {
|
| 112 |
debug-print-function ${FUNCNAME} "$@"
|
| 113 |
local ext=$1
|
| 114 |
local tmpdir=$(mktemp -d --tmpdir="${T}")
|
| 115 |
|
| 116 |
debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
|
| 117 |
ebegin "Removing office extension: \"${ext}\""
|
| 118 |
${UNOPKG_BINARY} remove --suppress-license \
|
| 119 |
--shared "${ext}" \
|
| 120 |
"-env:UserInstallation=file:///${tmpdir}" \
|
| 121 |
"-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
|
| 122 |
eend $?
|
| 123 |
office-ext_flush_unopkg_cache
|
| 124 |
rm -rf "${tmpdir}"
|
| 125 |
}
|
| 126 |
|
| 127 |
# @FUNCTION: office-ext_src_install
|
| 128 |
# @DESCRIPTION:
|
| 129 |
# Install the extension source to the proper location.
|
| 130 |
office-ext_src_install() {
|
| 131 |
debug-print-function ${FUNCNAME} "$@"
|
| 132 |
debug-print "Extensions: ${OO_EXTENSIONS[@]}"
|
| 133 |
local i
|
| 134 |
|
| 135 |
# subshell to not pollute rest of the env with the insinto redefinition
|
| 136 |
(
|
| 137 |
dodir $(office-ext_get_implementation)/share/extension/install/
|
| 138 |
insinto $(office-ext_get_implementation)/share/extension/install/
|
| 139 |
for i in ${OO_EXTENSIONS[@]}; do
|
| 140 |
doins "${i}"
|
| 141 |
done
|
| 142 |
)
|
| 143 |
|
| 144 |
einfo "Remember that if you replace your office implementation,"
|
| 145 |
einfo "you need to recompile all the extensions."
|
| 146 |
einfo "Your current implementation location is: "
|
| 147 |
einfo " $(office-ext_get_implementation)"
|
| 148 |
}
|
| 149 |
|
| 150 |
# @FUNCTION: office-ext_pkg_postinst
|
| 151 |
# @DESCRIPTION:
|
| 152 |
# Add the extensions to the libreoffice/openoffice.
|
| 153 |
office-ext_pkg_postinst() {
|
| 154 |
debug-print-function ${FUNCNAME} "$@"
|
| 155 |
debug-print "Extensions: ${OO_EXTENSIONS[@]}"
|
| 156 |
local i
|
| 157 |
|
| 158 |
for i in ${OO_EXTENSIONS[@]}; do
|
| 159 |
office-ext_add_extension "$(office-ext_get_implementation)/share/extension/install/${i}"
|
| 160 |
done
|
| 161 |
|
| 162 |
}
|
| 163 |
|
| 164 |
# @FUNCTION: office-ext_pkg_prerm
|
| 165 |
# @DESCRIPTION:
|
| 166 |
# Remove the extensions from the libreoffice/openoffice.
|
| 167 |
office-ext_pkg_prerm() {
|
| 168 |
debug-print-function ${FUNCNAME} "$@"
|
| 169 |
debug-print "Extensions: ${OO_EXTENSIONS[@]}"
|
| 170 |
local i
|
| 171 |
|
| 172 |
for i in ${OO_EXTENSIONS[@]}; do
|
| 173 |
office-ext_remove_extension "${i}"
|
| 174 |
done
|
| 175 |
}
|
| 176 |
|
| 177 |
EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
|
| 178 |
unset OEXT_EXPORTED_FUNCTIONS
|