Hi,
Please see the attached eclass that allows us installation of plugins for libre(open)office with some easy manner.

Any suggestions and improvements welcome.

Cheers

Tom
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: openoffice.eclass
# @MAINTAINER:
# The openoffice team <openoff...@gentoo.org>
# @BLURB: Eclass for installing openoffice extensions
# @DESCRIPTION:
# Eclass for easing maitenance of openoffice extensions.

case "${EAPI:-0}" in
        4) OOEXT_EXPORTED_FUNCTIONS="src_install pkg_postinst pkg_prerm" ;;
        *) die "EAPI=${EAPI} is not supported" ;;
esac

EXPORT_FUNCTIONS ${OOEXT_EXPORTED_FUNCTIONS}

inherit eutils multilib

UNOPKG_BINARY="${EPREFIX}/usr/bin/unopkg"

# @ECLASS-VARIABLE: OOO_EXTENSIONS
# @REQUIRED
# @DEFAULT_UNSET
# @DESCRIPTION:
# Space separated list of extensions to install.
[[ -z ${OOO_EXTENSIONS} ]] && die "OOO_EXTENSIONS variable is unset"

DEPEND="virtual/ooo"
RDEPEND="virtual/ooo"

# @FUNCTION: openoffice-ext_flush_unopkg_cache
# @DESCRIPTION:
# Flush the cache after removal of an extension.
openoffice-ext_flush_unopkg_cache() {
        debug-print-function ${FUNCNAME} "$@"

        debug-print "${FUNCNAME}: ${UNOPKG_BINARY} list --shared > /dev/null"
        ${UNOPKG_BINARY} list --shared > /dev/null
}

# @FUNCTION: openoffice-ext_get_implementation
# @DESCRIPTION:
# Determine the implementation we are building against.
openoffice-ext_get_implementation() {
        debug-print-function ${FUNCNAME} "$@"
        local implementations="libreoffice openoffice"
        local i

        for i in ${implementations}; do
                if [[ -d "${EPREFIX}/usr/$(get_libdir)/${i}" ]]; then
                        debug-print "${FUNCNAME}: Determined implementation is: 
\"${EPREFIX}/usr/$(get_libdir)/${i}\""
                        echo "${EPREFIX}/usr/$(get_libdir)/${i}"
                        return
                fi
        done

        die "Could not determine office implementation!"
}

# @FUNCTION: openoffice-ext_add_extension
# @DESCRIPTION:
# Install the extension into the office suite.
openoffice-ext_add_extension() {
        debug-print-function ${FUNCNAME} "$@"
        local ext=$1
        local tmpdir=$(mktemp -d --tmpdir=${T})

        debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared ${ext}"
        ebegin "Adding extension: \"${ext}\""
        ${UNOPKG_BINARY} add --shared ${ext} \
                "-env:UserInstallation=file:///${tmpdir}" \
                "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
        eend $?
        rm -rf ${tmpdir}
}

# @FUNCTION: openoffice-ext_remove_extension
# @DESCRIPTION:
# Remove the extension from the office suite.
openoffice-ext_remove_extension() {
        debug-print-function ${FUNCNAME} "$@"
        local ext=$1
        local tmpdir=$(mktemp -d --tmpdir=${T})

        debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared ${ext}"
        ebegin "Removing extension: \"${ext}\""
        ${UNOPKG_BINARY} remove --shared ${ext} \
                "-env:UserInstallation=file:///${tmpdir}" \
                "-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
        eend $?
        flush_unopkg_cache
        rm -rf ${tmpdir}
}

# @FUNCTION: openoffice-ext_src_install
# @DESCRIPTION:
# Install the extension source to the proper location.
openoffice-ext_src_install() {
        debug-print-function ${FUNCNAME} "$@"
        local i

        insinto $(openoffice-ext_get_implementation)/share/extension/install/
        for i in ${OOO_EXTENSIONS}; do
                doins ${i}
        done

        einfo "Remember that if you replace your office implementation,"
        einfo "you need to recompile all the extensions."
        einfo "Your current implementation location is: "
        einfo "    $(openoffice-ext_get_implementation)"
}

# @FUNCTION: openoffice-ext_pkg_postinst
# @DESCRIPTION:
# Add the extensions to the libreoffice.
openoffice-ext_pkg_postinst() {
        debug-print-function ${FUNCNAME} "$@"
        local i

        for i in ${OOO_EXTENSIONS}; do
                openoffice-ext_add_extension ${i}
        done

}

# @FUNCTION: openoffice-ext_pkg_prerm
# @DESCRIPTION:
# Remove the extensions from the libreoffice.
openoffice-ext_pkg_prerm() {
        debug-print-function ${FUNCNAME} "$@"
        local i

        for i in ${OOO_EXTENSIONS} do
                openoffice-ext_remove_extension ${i}
        done
}

Reply via email to