# 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.22

# Settings used for build from snapshots.
%{!?rel_build:%global commit c1ca209172a8b3a0751ac0a1e2dbec33c1894290}
%{!?rel_build:%global commit_date 20140712}
%{!?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}

Summary:  Text editor for the MATE desktop
Name:     pluma
Version:  %{branch}.2
Release:  2

License:  GPLv2+ and LGPLv2+
URL:      http://mate-desktop.org

# for downloading the tarball use 'spectool -g -R pluma.spec'
# Source for release-builds.
Source0:     http://pub.mate-desktop.org/releases/%{branch}/%{name}-%{version}.tar.xz


# https://github.com/mate-desktop/pluma/commit/e88a2ea
Patch1:        pluma_0001-Reindent-all-Python-sources-to-ts-4.-Strip-trailing-1.22.patch
# https://github.com/mate-desktop/pluma/pull/433
Patch2:        pluma_0001-quickopen-plugin-change-code-for-Python-2-3-compatib.patch
# https://github.com/mate-desktop/pluma/pull/434
Patch3:        pluma_0001-pythonconsole-plugin-change-source-code-for-Python-2.patch
# https://github.com/mate-desktop/pluma/pull/435
Patch4:        pluma_0001-externaltools-plugin-change-code-for-Python-2-3-comp.patch
# https://github.com/mate-desktop/pluma/pull/436
Patch5:        pluma_0001-snippets-plugin-change-code-for-Python-2-3-compatibi.patch
# https://github.com/mate-desktop/pluma/pull/437
Patch6:        pluma_0001-Switch-to-Python-3.patch

BuildRequires: desktop-file-utils
BuildRequires: enchant-devel
BuildRequires: libpeas-devel
BuildRequires: gtk3-devel
BuildRequires: gtksourceview3-devel
BuildRequires: iso-codes-devel
BuildRequires: libSM-devel
BuildRequires: mate-common
BuildRequires: pygobject3-devel
BuildRequires: python3-devel

Requires: %{name}-data = %{version}-%{release}
# needed to get a gsettings schema, #959607
Requires: mate-desktop-libs
# needed to get a gsettings schema, #959607
# Requires: caja-schemas
# the run-command plugin uses zenity
Requires: zenity

%description
pluma is a small, but powerful text editor designed specifically for
the MATE desktop. It has most standard text editor functions and fully
supports international text in Unicode. Advanced features include syntax
highlighting and automatic indentation of source code, printing and editing
of multiple documents in one window.

pluma is extensible through a plugin system, which currently includes
support for spell checking, comparing files, viewing CVS ChangeLogs, and
adjusting indentation levels.

%package data
Summary:   Data files for pluma
BuildArch: noarch
Requires:  %{name} = %{version}-%{release}

%description data
This package contains shared data needed for pluma.


%package devel
Summary:   Support for developing plugins for the pluma text editor
Requires:  %{name}%{?_isa} = %{version}-%{release}
Requires:  gtksourceview3-devel

%description devel
Development files for pluma


%prep
%autosetup -p1

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

# with python3
sed -i 's|#!\/usr\/bin/\python|#!\/usr\/bin\/python3|g' plugins/externaltools/data/switch-c.tool.in

# Patch 5
NOCONFIGURE=1 ./autogen.sh

# Fix debug permissions with messy hack 
find ./*/* -type f -exec chmod 644 {} \;
find ./*/*/* -type f -exec chmod 644 {} \;

%build
%configure \
        --disable-static          \
        --enable-gtk-doc-html     \
        --enable-gvfs-metadata    \
        --disable-schemas-compile

make %{?_smp_mflags} V=1

%install
%{make_install}

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

# clean up all the static libs for plugins
find %{buildroot} -name '*.la' -exec rm -f {} ';'
find %{buildroot} -name '*.a' -exec rm -f {} ';'

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


%files
%{_bindir}/pluma
%{_libdir}/pluma/
%{_libexecdir}/pluma/
%{_libdir}/girepository-1.0/Pluma-1.0.typelib
%{_datadir}/applications/pluma.desktop
%{_datadir}/metainfo/pluma.appdata.xml
%{_datadir}/glib-2.0/schemas/org.mate.pluma.gschema.xml
%{_datadir}/glib-2.0/schemas/org.mate.pluma.plugins.filebrowser.gschema.xml
%{_datadir}/glib-2.0/schemas/org.mate.pluma.plugins.pythonconsole.gschema.xml
%{_datadir}/glib-2.0/schemas/org.mate.pluma.plugins.time.gschema.xml
%{_datadir}/glib-2.0/schemas/org.mate.pluma.plugins.spell.gschema.xml

%files data -f %{name}.lang
%doc README COPYING AUTHORS
%{_datadir}/pluma/
%{_mandir}/man1/pluma.1.*

%files devel
%{_includedir}/pluma/
%{_libdir}/pkgconfig/pluma.pc
%{_datadir}/gtk-doc/html/pluma/
%{_datadir}/gir-1.0/Pluma-1.0.gir


%changelog
* Fri Dec 11 2020 douyan <douyan@kylinos.cn> - 1.22.2-2
- modify spec file

* Fri Dec 11 2020 douyan <douyan@kylinos.cn> - 1.22.2-1
- package init for openEuler
