%define pkg_name    pspp
%define pkg_version 1.2.0
%define pkg_release 1%{?_dist_release}

Summary:     A program for statistical analysis of sampled data
Summary(ja): データ統計解析用プログラム
Name:        %{pkg_name}
Version:     %{pkg_version}
Release:     %{pkg_release}

License: GPLv3+
Group:   Applications/Edutainment
URL:     http://www.gnu.org/software/pspp/
Source0: http://public.p-knowledge.co.jp/gnu-mirror/pspp/pspp-%{version}.tar.gz

# PATCH-FIX-UPSTREAM CVE-2018-20230.patch bnc#1120061 CVE-2018-20230
Patch0: CVE-2018-20230.patch
# PATCH-FIX-UPSTREAM CVE-2019-9211.patch boo#1127343 CVE-2019-9211
Patch1: CVE-2019-9211.patch
# Fix build with Texinfo 4.13 for openSUSE Leap 42.*
Patch2: avoid_old_Texinfo_4.13.patch

Buildroot: %{_tmppath}/%{name}-%{version}-root

BuildRequires: m4
BuildRequires: gettext
BuildRequires: texinfo
BuildRequires: desktop-file-utils

BuildRequires: gtk3-devel >= 3.14.5
BuildRequires: gtksourceview3-devel
BuildRequires: spread-sheet-widget-devel >= 0.3
BuildRequires: readline-devel
BuildRequires: pango-devel
BuildRequires: cairo-devel
BuildRequires: gsl-devel >= 1.12
BuildRequires: libglade2-devel
BuildRequires: libxml2-devel
BuildRequires: postgresql-devel
BuildRequires: zlib-devel

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t


%description
PSPP is a program for statistical analysis of sampled data.
It is a free replacement for the proprietary program SPSS.

PSPP supports t-tests, ANOVA, GLM, factor analysis, non-parametric tests,
and other statistical features. PSPP produces statistical reports
in plain text, PDF, PostScript, CSV, HTML, SVG, and OpenDocument formats.

PSPP has both text-based and graphical user interfaces.
The PSPP user interface has been translated into a number of languages.


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}
%setup -q

%patch0 -p1
%patch1 -p1
%patch2 -p1

%build
autoreconf -f -i
%configure \
    --disable-relocatable \
    --disable-static \
    --disable-rpath \
    --enable-debug \
    --without-libreadline-prefix \
    --docdir=%{_docdir}/%{name}-%{version}

%{__make} %{?_smp_mflags}

%install
%{make_install}

%{__rm} ${RPM_BUILD_ROOT}%{_libdir}/pspp/*.la
%{__rm} ${RPM_BUILD_ROOT}%{_infodir}/dir

# modify desktop file
%{__perl} -pi -e s/"Education;Science;Math;"/"Education;Science;"/g \
 ${RPM_BUILD_ROOT}%{_datadir}/applications/pspp.desktop

#Config for ld
%{__mkdir_p} %{buildroot}/etc/ld.so.conf.d
cat >${RPM_BUILD_ROOT}/etc/ld.so.conf.d/pspp.conf << EOF
%{_libdir}/pspp
EOF

# localization
%find_lang pspp

# %check
# %%{__make} check || cat ./tests/testsuite.log

%post
for doc in pspp pspp-dev; do
    file=%{_infodir}/${doc}.info.gz
    if [ -e ${file} ]; then
        /sbin/install-info ${file} %{_infodir}/dir 2>/dev/null
    fi
done
%{_syssbindir}/ldconfig

%preun
if [ $1 = 0 ]; then
    for doc in pspp pspp-dev; do
        file=%{_infodir}/${doc}.info.gz
        if [ -e ${file} ]; then
            /sbin/install-info --delete ${file} %{_infodir}/dir 2>/dev/null
        fi
    done
fi

%postun -p %{_syssbindir}/ldconfig


%files -f pspp.lang
%defattr(-,root,root,-)
%doc README COPYING THANKS AUTHORS
# tests/testsuite.log
%config(noreplace) /etc/ld.so.conf.d/pspp.conf
%{_bindir}/pspp
%{_bindir}/psppire
%{_bindir}/pspp-dump-sav
%{_bindir}/pspp-convert
%dir %{_libdir}/pspp
%{_libdir}/pspp/*.so
%{_datadir}/applications/pspp.desktop
%{_datadir}/appdata/pspp.appdata.xml
%{_datadir}/icons/
%dir %{_datadir}/pspp
%{_datadir}/pspp/
%{_infodir}/pspp*
%{_mandir}/man1/
%{_docdir}/


%changelog
* Sun Oct 27 2019 Toshiaki Ara <ara_t@384.jp> 1.2.0-1
- update to 1.2.0

* Mon Jun 04 2018 Toshiaki Ara <ara_t@384.jp> 1.0.1-3
- correct description
- add Packager: ara_t

* Sun Jun 03 2018 Toshiaki Ara <ara_t@384.jp> 1.0.1-2
- rebuild under gsl-2.4

* Sun Oct 15 2017 Toshiaki Ara <ara_t@384.jp> 1.0.1-1
- new package

