File telegram.spec of Package telegram

%define name_reverse_notation org.telegram.desktop
Name:           telegram
Version:        0.0.0
Release:        1%{?dist}
Summary:        Fast and secure desktop app, perfectly synced with your mobile phone
License:        GPL-3.0-only
URL:            https://desktop.telegram.org
Source0:        https://github.com/telegramdesktop/tdesktop/releases/download/v%{version}/tsetup.%{version}.tar.xz
Source1:        %{name_reverse_notation}.desktop
Source2:        %{name_reverse_notation}.service
Source3:        telegram-%{version}.tar.zst
BuildRequires:  tar
BuildRequires:  ImageMagick
BuildRequires:  coreutils
BuildRequires:  desktop-file-utils
BuildRequires:  grep
BuildRequires:  findutils
BuildRequires:  fdupes
BuildRequires:  zstd
Requires:       icu
Requires:       hunspell
Requires:       hicolor-icon-theme >= 0.18
Requires:       dbus-1
Provides:       telegram-desktop = %{version}
Conflicts:      telegram-desktop
ExclusiveArch:  x86_64
%global __strip /bin/true
%global _enable_debug_packages 0
%global debug_package %{nil}
%global __os_install_post /usr/lib/rpm/brp-compress %{nil}
%description
Telegram is a non-profit cloud-based instant messaging service.
Users can send messages and exchange photos, videos, stickers, audio and files of any type.
Its client-side code is open-source software but the source code for recent versions is not
always immediately published, whereas its server-side code is closed-source and proprietary.
The service also provides APIs to independent developers.
This is the official binary built by Telegram devs, but the package is unofficial.
%prep
%setup -q -c -a 3
cp -r telegram-%{version}/* .
rm -rf telegram-%{version}

%build

%install
install -D -m755 Telegram/Telegram %{buildroot}%{_bindir}/%{name}
install -D -m644 %{SOURCE1} %{buildroot}%{_datadir}/applications/%{name_reverse_notation}.desktop
install -D -m644 %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/services/%{name_reverse_notation}.service
install -D -m644 changelog.txt -t %{buildroot}/%{_datadir}/doc/packages/%{name}
install -D -m644 LICENSE -t %{buildroot}/%{_datadir}/licenses/%{name}
install -D -m644 LEGAL -t %{buildroot}/%{_datadir}/licenses/%{name}

mkdir -p %{buildroot}%{_datadir}/TelegramDesktop/externalupdater.d
echo %{_bindir}/%{name} > %{buildroot}%{_datadir}/TelegramDesktop/externalupdater.d/config
find %{buildroot}%{_datadir}/TelegramDesktop/externalupdater.d -exec touch -a -m -t 202412071500.00 {} \;

find %{_builddir}/%name-%version -name "icon*.png" -not -name "*round*" | while read icon; do
      if echo "$icon" | grep -q ".*green[^/]*" ;then
            installed_icon_name=telegram-green
      else
            installed_icon_name=telegram
      fi

      icon_ext="${icon##*.}"
      icon_size="$(identify -format "%wx%h\n" "$icon")"

      install -D -m644 "$icon" %{buildroot}%{_datadir}/icons/hicolor/${icon_size}/apps/${installed_icon_name}.${icon_ext}
done

%check

%files
%dir %{_datadir}/TelegramDesktop
%dir %{_datadir}/dbus-1
%dir %{_datadir}/dbus-1/services
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/*
%dir %{_datadir}/icons/hicolor/*/apps

%{_bindir}/%{name}
%{_datadir}/TelegramDesktop/*
%{_datadir}/applications/%{name_reverse_notation}.desktop
%{_datadir}/dbus-1/services/%{name_reverse_notation}.service
%{_datadir}/icons/hicolor/*/apps/telegram.*
%{_datadir}/icons/hicolor/*/apps/telegram-green.*

%license LICENSE LEGAL
%doc changelog.txt

%changelog
* Mon Nov 24 2025 itachi_re <xanbenson99@gmail.com> - 6.3.3-1
- improved packaging for version 6.3.3
openSUSE Build Service is sponsored by