File teams-for-linux.spec of Package teams-for-linux

%global icon_sizes 1024x1024 512x512 256x256 128x128 96x96 64x64 48x48 32x32 24x24 16x16

%define _name_archive teams-for-linux-main
%define _version 2.0.14


Summary: Unofficial Microsoft Teams for Linux client
Name: teams-for-linux
Version: 2.0.14
Release: 0
License: GPL-3.0-or-later
Group: Productivity/Networking/Instant Messenger
URL: https://github.com/IsmaelMartinez/teams-for-linux
Source:  %{_name_archive}-%{version}.tar.xz
Source1: %{name}.desktop.in
BuildArch: noarch
BuildRequires:	nodejs
BuildRequires:  asar
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
Requires: nodejs-electron
%{?nodejs_requires}

%description
%{summary}

%prep
%setup -n %{_name_archive}-%{version}
# keep:
# app.asar
# ressources/assets
# appstream data

# remove bundled copy of electron
# rm -r %{name} \
#   chrome-sandbox \
#   chrome_crashpad_handler \
#   chrome_100_percent.pak \
#   chrome_200_percent.pak \
#   resources.pak \
#   icudtl.dat \
#   libEGL.so \
#   libGLESv2.so \
#   libffmpeg.so \
#   libvulkan.so.1 \
#   libvk_swiftshader.so \
#   snapshot_blob.bin \
#   v8_context_snapshot.bin \
#   locales \
#   vk_swiftshader_icd.json \
#   LICENSE.electron.txt \
#   LICENSES.chromium.html

asar e resources/app.asar resources
rm resources/app.asar

pushd resources

# Remove packaged package contents that are unused
rm node_modules/mkdirp/bin/cmd.js \
   node_modules/http-proxy/.auto-changelog \
   node_modules/@homebridge/dbus-native/bin/dbus2js.js \
   node_modules/conf/node_modules/semver/bin/semver.js \
   node_modules/he/bin/he \
   node_modules/hexy/bin/hexy_cmd.js \
   node_modules/http-server/bin/http-server \
   node_modules/http-server/lib/core/index.js \
   node_modules/http-server/node_modules/mime/src/build.js \
   node_modules/opener/bin/opener-bin.js \
   node_modules/url-join/bin/changelog \
   node_modules/http-server/node_modules/mime/cli.js

#Remove development garbage
find -name '*.orig' -type f -print -delete
find -name '*.bak' -type f -print -delete
find -name '*~' -type f -print -delete
find -name '.*.el' -type f -print -delete
find -name '.eslint*' -type f -print -delete
find -name '.editorconfig' -type f -print -delete
find -name '.gitmodules' -type f -print -delete
find -name '.npmignore' -type f -print -delete
find -name '.tm_properties' -type f -print -delete
find -name '.travis.yml' -type f -print -delete
find -name '.yarn-integrity' -type f -print -delete
find -name '.jshintrc' -type f -print -delete
find -name '.nycrc' -type f -print -delete
find -name '.github' -print0 |xargs -r0 -- rm -rvf
find -name '.vscode' -print0 |xargs -r0 -- rm -rvf
find -name '.npmrc' -print0 |xargs -r0 -- rm -rvf
find -name '.nvmrc' -print0 |xargs -r0 -- rm -rvf
find -name '.anylint' -print0 |xargs -r0 -- rm -rvf
find -name '.tonic_example.js' -type f -print -delete
find -name '.runkit_example.js' -type f -print -delete
popd

%build
# empty

%install
install -dm755 "%{buildroot}%{_datadir}/%{_name_archive}" \
        "%{buildroot}%{_bindir}"
cp -dr --no-preserve=ownership resources/* \
   "%{buildroot}%{_datadir}/%{_name_archive}"

find "%{buildroot}%{_datadir}/%{_name_archive}/node_modules" \
     -type f -exec chmod 644 {} \;

install -Dm644 resources/com.github.IsmaelMartinez.teams_for_linux.appdata.xml \
        %{buildroot}%{_datadir}/metainfo/com.github.IsmaelMartinez.teams_for_linux.appdata.xml

install -Dm644 %{_sourcedir}/"%{name}.desktop.in" \
        "%{buildroot}/usr/share/applications/%{name}.desktop"
for size in 1024x1024 512x512 256x256 128x128 96x96 64x64 48x48 32x32 24x24 16x16; do
    install -Dm644 "%{_sourcedir}/build/icons/${size}.png" \
            "%{buildroot}/usr/share/icons/hicolor/${size}/apps/%{name}.png"
done
cat > "%{buildroot}%{_bindir}/%{_name_archive}" <<EOF
#!/bin/sh

exec electron "%{_datadir}/%{_name_archive}"  \"\$@\"
EOF
chmod 755 "%{buildroot}%{_bindir}/%{name}"

%if 0%{?suse_version}
# Fdupes doesn't work correctly on Fedora right now
# fdupes: could not chdir to %1
%{fdupes} %{buildroot}%{_prefix}
%endif

# packaged with rm %%{doc}
rm %{buildroot}%{_datadir}/%{name}/README.md
rm %{buildroot}%{_datadir}/%{name}/HISTORY.md
rm %{buildroot}%{_datadir}/%{name}/KNOWN_ISSUES.md
rm %{buildroot}%{_datadir}/%{name}/CONTRIBUTING.md
rm %{buildroot}%{_datadir}/%{name}/CODE_OF_CONDUCT.md
rm %{buildroot}%{_datadir}/%{name}/LICENSE.md

%files
%defattr(-,root,root,-)
%doc resources/README.md
%doc resources/HISTORY.md
%doc resources/KNOWN_ISSUES.md
%doc resources/CONTRIBUTING.md
%doc resources/CODE_OF_CONDUCT.md
%license resources/LICENSE.md
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/metainfo/com.github.IsmaelMartinez.teams_for_linux.appdata.xml
%{_datadir}/icons/hicolor/1024x1024/apps/%{name}.png
%{_datadir}/icons/hicolor/128x128/apps/%{name}.png
%{_datadir}/icons/hicolor/16x16/apps/%{name}.png
%{_datadir}/icons/hicolor/24x24/apps/%{name}.png
%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
%{_datadir}/icons/hicolor/32x32/apps/%{name}.png
%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
%{_datadir}/icons/hicolor/512x512/apps/%{name}.png
%{_datadir}/icons/hicolor/64x64/apps/%{name}.png
%{_datadir}/icons/hicolor/96x96/apps/%{name}.png
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*

%changelog
openSUSE Build Service is sponsored by