File deltachat-desktop.spec of Package deltachat-desktop

#
# spec file for package deltachat-desktop
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           deltachat-desktop
Version:        1.58.2
Release:        0
Summary:        DeltaChat Client
License:        GPL-3.0-only
URL:            https://github.com/deltachat/deltachat-desktop
Source0:        https://codeload.github.com/deltachat/deltachat-desktop/tar.gz/refs/tags/v%{version}#/deltachat-desktop-%{version}.tar.gz
Source1:        vendor.tar.xz
Source2:        prepare.sh
Source3:        %{name}.desktop
#BuildRequires:  deltachat-message-parser
BuildRequires:  deltachat-rpc-server
BuildRequires:  nodejs-electron
BuildRequires:  pnpm
BuildRequires:  npm22
BuildRequires:  rsync
Requires:       deltachat-rpc-server
BuildArch:      noarch

%description
DeltaChat client.

%prep
%autosetup -a1
#rsync -aP --delete /usr/lib/node_modules/message_parser_wasm/ ./node_modules/.pnpm/@deltachat+message_parser_wasm@*/node_modules/@deltachat/message_parser_wasm/

%build
#pnpm install --frozen-lockfile --ignore-scripts
cd packages/target-electron
export VERSION_INFO_GIT_REF=%{version}
pnpm build
pnpm run pack:generate_config
pnpm run pack:patch-node-modules
pnpm exec electron-builder --linux --dir -c.electronDist=/usr/lib64/electron/


%install
mkdir -p "%{buildroot}%{_prefix}/lib/%{name}/"
cp -rv packages/target-electron/dist/linux-unpacked/resources/* "%{buildroot}%{_prefix}/lib/%{name}/"
pushd %{buildroot}%{_prefix}/lib/deltachat-desktop/app.asar.unpacked/node_modules/@deltachat/stdio-rpc-server-linux-*/
rm deltachat-rpc-server
ln -s %{_bindir}/deltachat-rpc-server
popd

mkdir -p %{buildroot}%{_bindir}
cat <<EOF > %{buildroot}%{_bindir}/%{name}
#!/bin/sh

exec electron %{_prefix}/lib/%{name}/app.asar "$@"
EOF
chmod +x %{buildroot}%{_bindir}/%{name}

mkdir -p %{buildroot}%{_datadir}/applications/
cp %{SOURCE3} %{buildroot}%{_datadir}/applications/

%files
%license LICENSE
%doc README.md
%{_prefix}/lib/%{name}
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop

%changelog
openSUSE Build Service is sponsored by