Files
gentoo/eclass/office-ext-r1.eclass
Eli Schwartz fe81ea0302 office-ext-r1.eclass: remove totally incorrect use of assert
It should have always been die.

From gentoo-historical-2.git,

```
commit 712cd6740c0bfa9d15dfd33ead7a52d5cdd4f87b
Author:     Tomas Chvatal <scarabeus@gentoo.org>
AuthorDate: Sat Mar 23 06:16:57 2013
Commit:     Tomas Chvatal <scarabeus@gentoo.org>
CommitDate: Sat Mar 23 06:16:57 2013

    Add next version of office-ext eclass. This time we can directly deploy libreoffice exts, but ooo crashes so keep backcompat over crashy uno interface for them (it is oo bug and they should fix it).
```

I have many questions. However, the one which is relevant here is: why
did this new eclass *add* new src_unpack logic to actually unpack files,
which called a single simple command, `unzip`, and then uses assert to
catch pipe errors in it.

Same issue as myspell-r2.eclass in the previous commit.

assert is banned in EAPI 9, so it has to go anyway. Take this
opportunity to perform a 14 year old cleanliness fix.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
2026-03-12 11:21:03 -04:00

144 lines
3.7 KiB
Bash

# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: office-ext-r1.eclass
# @MAINTAINER:
# The office team <office@gentoo.org>
# @AUTHOR:
# Tomáš Chvátal <scarabeus@gentoo.org>
# @SUPPORTED_EAPIS: 7 8
# @BLURB: Eclass for installing libreoffice extensions
# @DESCRIPTION:
# Eclass for easing maintenance of libreoffice extensions.
case ${EAPI} in
7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ -z ${_OFFICE_EXT_R1_ECLASS} ]]; then
_OFFICE_EXT_R1_ECLASS=1
# @ECLASS_VARIABLE: OFFICE_REQ_USE
# @PRE_INHERIT
# @DESCRIPTION:
# Useflags required on office implementation for the extension.
#
# Example:
# @CODE
# OFFICE_REQ_USE="java,jemalloc(-)?"
# @CODE
if [[ ${OFFICE_REQ_USE} ]]; then
# Append the brackets for the depend below
OFFICE_REQ_USE="[${OFFICE_REQ_USE}]"
fi
# @ECLASS_VARIABLE: OFFICE_IMPLEMENTATIONS
# @DESCRIPTION:
# List of implementations supported by the extension.
# Some work only for libreoffice and vice versa.
# Default value is all implementations.
#
# Example:
# @CODE
# OFFICE_IMPLEMENTATIONS=( "libreoffice" )
# @CODE
[[ -z ${OFFICE_IMPLEMENTATIONS} ]] && OFFICE_IMPLEMENTATIONS=( "libreoffice" )
# @ECLASS_VARIABLE: OFFICE_EXTENSIONS
# @PRE_INHERIT
# @REQUIRED
# @DESCRIPTION:
# Array containing list of extensions to install.
#
# Example:
# @CODE
# OFFICE_EXTENSIONS=( ${PN}_${PV}.oxt )
# @CODE
[[ -z ${OFFICE_EXTENSIONS} ]] && die "OFFICE_EXTENSIONS variable is unset."
if [[ "$(declare -p OFFICE_EXTENSIONS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
die "OFFICE_EXTENSIONS variable is not an array."
fi
# @ECLASS_VARIABLE: OFFICE_EXTENSIONS_LOCATION
# @DESCRIPTION:
# Path to the extensions location. Defaults to ${DISTDIR}.
#
# Example:
# @CODE
# OFFICE_EXTENSIONS_LOCATION="${S}/unpacked/"
# @CODE
: "${OFFICE_EXTENSIONS_LOCATION:=${DISTDIR}}"
# Most projects actually do not provide any relevant sourcedir as they are oxt.
S="${WORKDIR}"
IUSE="$(printf 'office_implementation_%s ' ${OFFICE_IMPLEMENTATIONS[@]})"
REQUIRED_USE="|| ( $(printf 'office_implementation_%s ' ${OFFICE_IMPLEMENTATIONS[@]}) )"
for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
if [[ ${i} == "libreoffice" ]]; then
RDEPEND+="
office_implementation_${i}? (
|| (
app-office/${i}${OFFICE_REQ_USE}
app-office/${i}-bin${OFFICE_REQ_USE}
)
)
"
fi
done
BDEPEND="app-arch/unzip"
# @FUNCTION: office-ext-r1_src_unpack
# @DESCRIPTION:
# Flush the cache after removal of an extension.
office-ext-r1_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
local i
default
for i in ${OFFICE_EXTENSIONS[@]}; do
# Unpack the extensions where required and add case for oxt
# which should be most common case for the extensions.
if [[ -f ${OFFICE_EXTENSIONS_LOCATION}/${i} ]] ; then
case ${i} in
*.oxt)
mkdir -p "${WORKDIR}/${i}/" || die
pushd "${WORKDIR}/${i}/" > /dev/null || die
einfo "Unpacking "${OFFICE_EXTENSIONS_LOCATION}/${i}" to ${PWD}"
unzip -qo ${OFFICE_EXTENSIONS_LOCATION}/${i} || die "failed unpacking ${OFFICE_EXTENSIONS_LOCATION}/${i}"
popd > /dev/null || die
;;
*) unpack ${i} ;;
esac
fi
done
}
# @FUNCTION: office-ext-r1_src_install
# @DESCRIPTION:
# Install the extension source to the proper location.
office-ext-r1_src_install() {
debug-print-function ${FUNCNAME} "$@"
debug-print "Extensions: ${OFFICE_EXTENSIONS[@]}"
local i j
for i in ${OFFICE_IMPLEMENTATIONS[@]}; do
if use office_implementation_${i}; then
for j in ${OFFICE_EXTENSIONS[@]}; do
pushd "${WORKDIR}/${j}/" > /dev/null || die
insinto /usr/$(get_libdir)/${i}/share/extensions/${j/.oxt/}
doins -r .
popd > /dev/null || die
done
fi
done
}
fi
EXPORT_FUNCTIONS src_unpack src_install