collabora-online-server-nod.../PKGBUILD

268 lines
8.7 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Maintainer: Yves G. <theYinYeti@yalis.fr>
# Choose which language(s) to package (in addition to “en-us”)
# This is a “full-line” extended regular-expression, eg.: 'pt' if you want “pt” but not “pt-br” or “pt-pt”
_I18N_EREGEX='.*'
_pkgname=collabora-online-server-nodocker
# taking version of coolwsd:
pkgver=21.11.0.3
pkgrel=1
arch=('x86_64')
url="https://www.collaboraoffice.com/code/"
license=('MPL')
makedepends=(curl fontconfig libcap)
# ↑ excluding base (bzip2 coreutils gawk grep gzip sed systemd tar util-linux xz)
optdepends=(
'hunspell: Use with language-specific hunspell dictionaries for LibreOffice spell-check'
'hyphen: Use with language-specific hyphen rules for LibreOffice hyphenation'
)
depends=()
source=(
'https://www.collaboraoffice.com/repos/CollaboraOnline/CODE/Packages'
install
mkcert_example.sh
sysusers
tmpfiles
)
sha1sums=(
'SKIP'
'69c3f1ee98aa44aae759c011fcfac6502676535e'
'3fe2db88f4f7ee203520c59760582103d3e41210'
'b44b1ddaa362c6fdf65a0899beaa40dada3b232e'
'aeb478d352c89acb43d651de75fb9951f47e8556'
)
# From debs conffiles
backup=(
# new:
etc/apache2/conf-available/coolwsd.conf
etc/coolwsd/coolkitconfig.xcu
etc/coolwsd/coolwsd.xml
etc/nginx/snippets/coolwsd.conf
# old:
etc/apache2/conf-available/loolwsd.conf
etc/loolwsd/loolkitconfig.xcu
etc/loolwsd/loolwsd.xml
etc/nginx/snippets/loolwsd.conf
etc/sysconfig/loolwsd
)
# From debs pre/post scripts
install=install
# From Dockerfile (https://github.com/CollaboraOnline/online/tree/master/docker), minus i18n files
_upstream_deps=(coolwsd code-brand)
# DEBIANARCHLINUX EQUIVALENCES
#
# In case of a new upstream release:
#
# 1. Move all lines from $_upstream_equiv to $_upstream_equiv_OLD.
#
# 2. Run `makepkg -s` iteratively:
# * Each time a dependency is missing, move it back from $_upstream_equiv_OLD to $_upstream_equiv.
# * If a dependency is new, add a new line in $_upstream_equiv with nothing after the “=” sign.
#
# 3. When the package is done, in a terminal run: ./missing-deps.sh
#
# 4. For each “not found” line:
# * If the missing file should be provided by a new dependency in $_upstream_equiv,
# then put after the “=” sign the name of an Archlinux package that provides this file;
# you may need to create the package if it does not exist (usually old versions).
# * Else the missing file is probably expected to be present on any Debian/Ubuntu system;
# thus add the missing dependency in the $depends array.
#
# 5. Review files under ./src/_control/* and see if install/upgrade actions have changed.
_upstream_equiv='
adduser =
cpio = cpio
expat = expat
fontconfig = fontconfig
init-system-helpers =
libc6 = gcc-libs
libcap2 = libcap
libcap2-bin = libcap
libgcc1 = gcc-libs
libpam0g = pam
libpng12-0 = libpng12
libssl1.0.0 = openssl-1.0
libstdc++6 = gcc-libs
openssh-client = openssh
systemd = systemd
zlib1g = zlib
'
_upstream_equiv_OLD='
locales-all = glibc
'
_main_debs=
_i18n_debs=
declare -A __main_debs __i18n_debs
# >>>> START OF DYNAMIC ADAPTATION OF PKGBUILD
_upstream_handle_dep() {
local dep="$2"
local eqv="$(grep "^[[:blank:]]*$(sed 's/[.]/\\\0/g' <<<"$dep")[[:blank:]]*=" <<<"$_upstream_equiv")"
local meta="$(awk -F$'\n' -vRS= "/^Package:[[:blank:]]*$(sed 's/[.]/\\\0/g' <<<"$dep")\\n/{print}" Packages)"
local seen depurl
if [ -n "$eqv" ]; then
dep="$(sed 's/.*=[[:blank:]]*//' <<<"$eqv")"
[ -n "$dep" ] || return
for seen in "${depends[@]}"; do
[ "$seen" == "$dep" ] && return
done
depends+=("$dep")
elif [ -n "$meta" ]; then
depurl="$(sed -rn "s#^Filename:[[:blank:]]*(.*/)?#${source[0]%Packages}#p" <<<"$meta")"
for seen in "${source[@]}"; do
[ "$seen" == "$depurl" ] && return
done
# when a new .DEB is needed, put it in the right array of dependencies
[ $1 == main ] && __main_debs[$dep]="$depurl" || __i18n_debs[$dep]="$depurl"
source+=("$depurl")
sha1sums+=("$(sed -rn "s#^SHA1:[[:blank:]]*##p" <<<"$meta")")
while read dep; do if [ -n "$dep" ]; then
_upstream_handle_dep "$1" "$dep"
fi; done < <(
sed -rn "s#^Depends:[[:blank:]]*##p" <<<"$meta" \
| sed 's#([^)]*)##g; s#[[:blank:]]*,[[:blank:]]*#\n#g'
)
else
echo "Unknown dependency: $dep" >&2; exit 1
fi
}
if [ ${#source[*]} -eq 5 ]; then
curl -s "${source[0]}" >Packages
pkgver=$(
awk -F$'\n' -vRS= '/^Package:[[:blank:]]*coolwsd\n/{print}' Packages \
| sed -n 's/^Version:[[:blank:]]*\(.*\)-.*/\1/p'
)
# first register each .DEB as an unconfirmed main (i.e. not i18n) dependency
for d in "${_upstream_deps[@]}"; do __main_debs[$d]=_pending_; done
if [ -z "$_I18N_EREGEX" ]; then
# go with that if no i18n has been requested
pkgname=$_pkgname
eval 'package() { _main_package; }'
else
# else register the function for building the main package, and dynamically discover i18n packages
pkgname=($_pkgname)
eval "package_$_pkgname() { _main_package; }"
for p in $( \
sed -nr 's#^Package:[[:blank:]]*((collaboraoffice-dict|collaboraofficebasis)-[a-z]{2}(-[a-z]+)?)$#\1#p' Packages \
| grep -ve '-en-us$' \
| grep -E "(dict|basis)-($_I18N_EREGEX)\$")
do
# for each .DEB file found that matches the requested i18n regex, register that .DEB as a i18n one
__i18n_debs[$p]=_pending_
done
while read l; do
# and register the function for building each of the i18n packages
pkgname+=(${_pkgname}_${l})
eval "package_${_pkgname}_${l}() { _i18n_package $l; }"
done < <( \
sed -nr 's#^Package:[[:blank:]]*(collaboraoffice-dict-|collaboraofficebasis-)([a-z]{2}(-[a-z]+)?)$#\2#p' Packages \
| grep -vxF en-us \
| sort -u \
| grep -Exe "$_I18N_EREGEX")
fi
for dep in "${!__main_debs[@]}"; do
# recursive dependencies for the main package
_upstream_handle_dep main "$dep"
done
for dep in "${!__i18n_debs[@]}"; do
# recursive dependencies for the i18n packages
_upstream_handle_dep i18n "$dep"
done
_main_debs="$(IFS='|'; echo "${__main_debs[*]}")"
_i18n_debs="$(IFS='|'; echo "${__i18n_debs[*]}")"
fi
# some debug:
echo "MAIN DEBs: $_main_debs" >&2
echo "I18N DEBs: $_i18n_debs" >&2
unset _upstream_handle_dep _upstream_equiv _upstream_deps __main_debs __i18n_debs
# <<<< END OF DYNAMIC ADAPTATION OF PKGBUILD
_unpack_deb_file() {
local target="$1"
local deb="$2"
local archive="$3"
local data="$(ar t "$deb" | grep "^${archive}\.")"
if [ -n "$data" ]; then
[ -d "$target" ] || mkdir -p "$target"
case "$data" in
*.bz2) ar p "$deb" "$data" | tar -C "$target" -xjf - ;;
*.gz) ar p "$deb" "$data" | tar -C "$target" -xzf - ;;
*.xz) ar p "$deb" "$data" | tar -C "$target" -xJf - ;;
*) echo "Unknown file format: $data" >&2; exit 1 ;;
esac
fi
}
_i18n_package() {
depends=()
backup=()
install=
pkgdesc="Language ${1} internationalization files for Collabora CODE (LibreOffice Online)"
local data f
cd "$pkgdir"
while read f; do
[[ "$f" =~ (dict|basis)-$1 ]] || continue
f="$srcdir/$(basename "$f")"
_unpack_deb_file "$pkgdir" "$f" data
done < <(tr '|' '\n' <<<"$_i18n_debs")
chown -R $(id -nu):$(id -ng) .
}
_main_package() {
pkgdesc="Collabora CODE (LibreOffice Online) server for Nextcloud or ownCloud, without Docker"
local data f
cd "$pkgdir"
while read f; do
f="$srcdir/$(basename "$f")"
_unpack_deb_file "$pkgdir" "$f" data
_unpack_deb_file "$srcdir/_control/$(basename "$f")" "$f" control
done < <(tr '|' '\n' <<<"$_main_debs")
find "$srcdir/_control" -type f \( -name control -o -name copyright -o -name md5sums \) -exec rm -f {} +
find "$srcdir/_control" -depth -empty -exec rm -rf {} \;
chown -R $(id -nu):$(id -ng) .
# /lib is deprecated
mv {lib,usr/lib}
# use systemd for user allocation
install -Dm0644 "$srcdir"/sysusers usr/lib/sysusers.d/$_pkgname.conf
# replace cron with systemd
rm -rf etc/cron.d
install -Dm0644 "$srcdir"/tmpfiles usr/lib/tmpfiles.d/$_pkgname.conf
# add dependency on systemd
sed -i '/^\[Unit\]/ a \
After=systemd-tmpfiles-setup.service' usr/lib/systemd/system/coolwsd.service
# keep the cert-making script from the Dockerfile for reference
install -Dm0755 "$srcdir"/mkcert_example.sh usr/share/doc/coolwsd/example.mkcert.sh
# do not provide libreoffice for the desktop (seems broken…)
rm -rf opt/collaboraoffice/share/xdg
# fix lib + desktop files permissions
chmod a+x opt/collaboraoffice/program/lib*.so
# https://github.com/CollaboraOnline/Docker-CODE/issues/32
[ -d etc/sysconfig ] || mkdir etc/sysconfig
echo 'SLEEPFORDEBUGGER=0' >>etc/sysconfig/coolwsd
}