void-packages/srcpkgs/element-desktop/template

113 lines
3.7 KiB
Bash

# Template file for 'element-desktop'
pkgname=element-desktop
version=1.11.20
revision=1
create_wrksrc=yes
conf_files="/etc/${pkgname}/config.json"
hostmakedepends="git yarn nodejs rust cargo python3 curl
sqlcipher-devel libappindicator-devel libnotify-devel pkg-config
app-builder jq moreutils"
makedepends="libsecret-devel"
depends="c-ares ffmpeg gtk+3 http-parser libevent
libxslt minizip nss re2 snappy sqlcipher electron19"
short_desc="Glossy Matrix collaboration client, desktop version"
maintainer="Jan Christian Grünhage <jan.christian@gruenhage.xyz>"
license="Apache-2.0"
homepage="https://element.io"
changelog="https://raw.githubusercontent.com/vector-im/element-desktop/develop/CHANGELOG.md"
distfiles="https://github.com/vector-im/element-desktop/archive/v${version}.tar.gz>element-desktop-v${version}.tar.gz
https://github.com/vector-im/element-web/archive/v${version}.tar.gz>element-web-v${version}.tar.gz"
checksum="6f38aad3c28401a16d3a00830a309334ed4d64920a7d7feaf651b64c213c5d73
2c47aaf91de56cd2d0a488a0efe66b09e9d0ba472af2a506a87ce33eced0d662"
export USE_SYSTEM_APP_BUILDER=true
post_extract() {
mv ${pkgname}-${version} ${pkgname}
mv ${pkgname/desktop/web}-${version} ${pkgname/desktop/web}
}
pre_patch() {
for patch in ${pkgname}_*.patch; do
ln -s ../${patch} ${pkgname}
done
for patch in ${pkgname/desktop/web}_*.patch; do
ln -s ../${patch} ${pkgname/desktop/web}
done
}
post_patch() {
cd ${pkgname/desktop/web}
# Disable auto-updating
jq '.update_base_url = ""' element.io/app/config.json | sponge element.io/app/config.json
cd ../${pkgname}
jq '.build.linux.target = ["dir"]' package.json | sponge package.json
}
pre_build() {
# since element 1.8.x it's necessary to force the npm arch
# to x86, otherwise it will fail in electron js stuff on
# platforms officially unsupported by electron (ppc64le...)
local carch=x64
case "$XBPS_TARGET_MACHINE" in
i686*) carch=ia32 ;;
esac
cd ${pkgname/desktop/web}
# Build dependencies for element-web
npm_config_arch=$carch yarn install
# Build dependencies and alterations for element-desktop
cd ../${pkgname}
npm_config_arch=$carch yarn install
}
do_build() {
cd ${pkgname/desktop/web}
yarn build
cd ../${pkgname}
if [ "$CROSS_BUILD" ]; then
yarn run build:native --target ${XBPS_CROSS_RUST_TARGET}
else
yarn run build:native
fi
# normally just "yarn run build" would be okay, but at least on ppc64
# we need to force x86_64 arch as electron-builder does not support
# ppc64 and fails on arch detection; ARM is supported so just use build
case "$XBPS_TARGET_MACHINE" in
x86_64*|ppc64*) yarn run build:64 ;;
i686*) yarn run build:32 ;;
*) yarn run build ;;
esac
}
do_install() {
cd ${pkgname/desktop/web}
vmkdir usr/lib/element-desktop
vmkdir etc/element-desktop
case "$XBPS_TARGET_MACHINE" in
i686*) vcopy ../element-desktop/dist/linux-ia32-unpacked/resources /usr/lib/element-desktop/resources;;
*) vcopy ../element-desktop/dist/linux-unpacked/resources /usr/lib/element-desktop/resources
esac
vinstall config.sample.json 644 /etc/element-desktop/ config.json
vcopy webapp /usr/lib/element-desktop/resources
ln -s /etc/element-desktop/config.json $DESTDIR/usr/lib/element-desktop/resources/webapp/config.json
vbin ${FILESDIR}/element-desktop
ln -s element-desktop $DESTDIR/usr/bin/riot-desktop
vinstall ${FILESDIR}/element-desktop.desktop 644 /usr/share/applications/ element-desktop.desktop
vinstall webapp/themes/element/img/logos/element-logo.svg 644 /usr/share/icons/hicolor/scalable/apps/ element.svg
for i in 16 24 48 64 96 128 256 512; do
vinstall ../element-desktop/build/icons/${i}x${i}.png 644 /usr/share/icons/hicolor/${i}x${i}/apps/ element.png
done
}
riot-desktop_package() {
depends="element-desktop"
short_desc+=" (transitional dummy package)"
build_style=meta
}