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

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

Summary: Unofficial Microsoft Teams for Linux client
Name: teams-for-linux
Version: 1.0.45
Release: 0
License: GPL-3.0-or-later
Group: Productivity/Networking/Instant Messenger
URL: https://github.com/IsmaelMartinez/teams-for-linux
Source0: https://github.com/IsmaelMartinez/teams-for-linux/releases/download/v%{version}/teams-for-linux-%{version}.tar.gz
Source1: %{name}.desktop.in
Source2: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/1024x1024.png
Source3: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/512x512.png
Source4: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/256x256.png
Source5: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/128x128.png
Source6: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/96x96.png
Source7: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/64x64.png
Source8: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/48x48.png
Source9: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/32x32.png
Source10: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/24x24.png
Source11: https://raw.githubusercontent.com/IsmaelMartinez/%{name}/develop/build/icons/16x16.png
BuildArch: noarch
BuildRequires:	nodejs
BuildRequires:  asar
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
Requires: nodejs-electron
%{?nodejs_requires}

%description
%{summary}

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

# remove bundled copy of electron
rm %{name}
rm chrome-sandbox
rm chrome_100_percent.pak
rm chrome_200_percent.pak
rm resources.pak
rm icudtl.dat
rm libEGL.so
rm libGLESv2.so
rm libffmpeg.so
rm libvk_swiftshader.so
rm snapshot_blob.bin
rm v8_context_snapshot.bin
rm -rf locales
rm -rf swiftshader
rm vk_swiftshader_icd.json

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

pushd resources

# Remove packaged package contents that are unused
rm node_modules/ajv/.tonic_example.js
rm node_modules/conf/node_modules/ajv/.runkit_example.js
rm node_modules/semver/bin/semver.js
rm node_modules/mkdirp/bin/cmd.js
rm -rf node_modules/ajv/scripts/

#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
popd



%build
# empty


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

find "%{buildroot}%{_datadir}/%{name}/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}/${size}.png" \
            "%{buildroot}/usr/share/icons/hicolor/${size}/apps/%{name}.png"
done
cat > "%{buildroot}%{_bindir}/%{name}" <<EOF
#!/bin/sh

exec electron "%{_datadir}/%{name}"  \"\$@\"
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