# Conditional for release and snapshot builds. Uncomment for release-builds.
%global rel_build 1

# This is needed, because src-url contains branched part of versioning-scheme.
%global branch 1.24

# Settings used for build from snapshots.
%{!?rel_build:%global commit f4611c3411c44e792f729a0780c31b0aa55fe004}
%{!?rel_build:%global commit_date 20131215}
%{!?rel_build:%global shortcommit %(c=%{commit};echo ${c:0:7})}
%{!?rel_build:%global git_ver git%{commit_date}-%{shortcommit}}
%{!?rel_build:%global git_rel .git%{commit_date}.%{shortcommit}}
%{!?rel_build:%global git_tar %{name}-%{version}-%{git_ver}.tar.xz}

Name:          engrampa
Version:       1.24.1
Release:       4
Summary:       MATE Desktop file archiver
License:       GPLv2+ and LGPLv2+
URL:           http://mate-desktop.org

# for downloading the tarball use 'spectool -g -R engrampa.spec'
# Source for release-builds.
%{?rel_build:Source0:     http://pub.mate-desktop.org/releases/%{branch}/%{name}-%{version}.tar.xz}
# Source for snapshot-builds.
%{!?rel_build:Source0:    http://git.mate-desktop.org/%{name}/snapshot/%{name}-%{commit}.tar.xz#/%{git_tar}}

BuildRequires:  mate-common
BuildRequires:  desktop-file-utils
BuildRequires:  file-devel
BuildRequires:  gtk3-devel
BuildRequires:  json-glib-devel
BuildRequires:  caja-devel
BuildRequires:  libSM-devel

Patch1:	 0004-fix-engrampa-Fix-decompress-files-with-garbled-chara.patch
Patch2:  CVE-2023-52138.patch

%description
Mate File Archiver is an application for creating and viewing archives files,
such as zip, xv, bzip2, cab, rar and other compress formats.


%prep
%if 0%{?rel_build}
%autosetup -p1
%else
%autosetup -n %{name}-%{commit} -p1
%endif

%if 0%{?rel_build}
#NOCONFIGURE=1 ./autogen.sh
%else # 0%{?rel_build}
# needed for git snapshots
NOCONFIGURE=1 ./autogen.sh
%endif # 0%{?rel_build}

%build
%configure                 \
   --disable-schemas-compile \
   --disable-static        \
   --enable-caja-actions   \
   --enable-magic          \
   --disable-packagekit

make %{?_smp_mflags} V=1


%install
%{make_install}

desktop-file-install                                \
    --delete-original                               \
    --dir %{buildroot}%{_datadir}/applications      \
%{buildroot}%{_datadir}/applications/engrampa.desktop

find %{buildroot} -name "*.la" -exec rm -f {} ';'

%find_lang %{name} --with-gnome --all-name


%files -f %{name}.lang
%doc README COPYING NEWS AUTHORS
%{_mandir}/man1/*
%{_bindir}/engrampa
%{_libexecdir}/engrampa
%{_libexecdir}/engrampa-server
%{_libdir}/caja/extensions-2.0/libcaja-engrampa.so
%{_datadir}/engrampa
%{_datadir}/metainfo/engrampa.appdata.xml
%{_datadir}/applications/engrampa.desktop
%{_datadir}/caja/extensions/libcaja-engrampa.caja-extension
%{_datadir}/dbus-1/services/org.mate.Engrampa.service
%{_datadir}/icons/hicolor/*/actions/*.png
%{_datadir}/icons/hicolor/*/apps/*.png
%{_datadir}/icons/hicolor/scalable/apps/*.svg
%{_datadir}/glib-2.0/schemas/org.mate.engrampa.gschema.xml


%changelog
* Tue Apr 30 2024 peijiankang <peijiankang@kylinos.cn> - 1.24.1-4
- fix CVE-2023-52138

* Mon Feb 19 2024 yuanxing <yuanxing@kylinsec.com.cn> - 1.24.1-3
- KYOS-F: enable caja-actions with configure.(#30161)

* Thu Jul 20 2023 longcheng <longcheng@kylinos.com.cn> - 1.24.1-2
- fix(engrampa):Fix decompress files with garbled characters under GB18030 encoding

* Wed Sep 02 2020 douyan <douyan@kylinos.cn> - 1.24.1-1
- package init
