# COPR Ligenix's spec file for glpi-plugin-order
#
# Copyright (c) 2023-2023 Jean-Marc Liger
#
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#
%global pluginname order
%global glpi_min   9.5
%global glpi_max   9.6

Name:           glpi-plugin-%{pluginname}
Version:        2.10.3
Release:        1%{?dist}
Summary:        GLPI Plugin to manage order management
Summary(fr):    Extension GLPI pour gérer le processus de commande de matériels

License:        GPLv3
URL:            https://github.com/pluginsGLPI/%{pluginname}

Source0:        https://github.com/pluginsGLPI/%{pluginname}/releases/download/%{version}/glpi-%{pluginname}-%{version}.tar.bz2

BuildArch:      noarch

%if 0%{?fedora} || 0%{?rhel} >= 8
Requires:      (glpi >= %{glpi_min} with glpi < %{glpi_max})
%else
Requires:       glpi >= %{glpi_min}
Requires:       glpi <  %{glpi_max}
%endif


%description
This plugin allows you to manage order management within GLPI :
- Products references management
- Order management (with approval workflow)
- Budgets management


%description -l fr
Cette extension vous permet de gérer le processus de commande de matériels à l'intérieur de GLPI :
- Gestion des références produits
- Gestion des commandes (avec workflow de soumission)
- Gestion des budgets


%prep
%setup -q -c

grep 'define("PLUGIN_ORDER_M.._GLPI' %{pluginname}/setup.php
 
# remove unused files
rm %{pluginname}/plugin.xml
rm %{pluginname}/composer.json

# move doc files
mkdir docs
mv %{pluginname}/*.md              docs/
mv %{pluginname}/screenshots/      docs/
mv %{pluginname}/%{pluginname}.png docs/
mv %{pluginname}/glpi_network.png  docs/

# fix rpmlint warnings
find %{pluginname}/vendor \(\
    -name .gitignore \
    \) -exec rm -f {} \;

# Create link to LICENSE for standard doc folder
ln -s %{_datadir}/glpi/plugins/%{pluginname}/LICENSE LICENSE


%build
# empty build


%install
mkdir -p %{buildroot}%{_localstatedir}/lib/glpi/files/_plugins/%{pluginname}

mkdir -p %{buildroot}/%{_datadir}/glpi/plugins
cp -ar %{pluginname} %{buildroot}/%{_datadir}/glpi/plugins/%{pluginname}

for i in %{buildroot}/%{_datadir}/glpi/plugins/%{pluginname}/locales/*
do
  lang=$(basename $i)
  echo "%lang(${lang:0:2}) %{_datadir}/glpi/plugins/%{pluginname}/locales/${lang}"
done | tee %{name}.lang


%files -f %{name}.lang
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc docs/*
%dir %{_datadir}/glpi/plugins/%{pluginname}
%dir %{_datadir}/glpi/plugins/%{pluginname}/locales
# LICENSE file required by installation process
%{_datadir}/glpi/plugins/%{pluginname}/LICENSE
%{_datadir}/glpi/plugins/%{pluginname}/*.php
%{_datadir}/glpi/plugins/%{pluginname}/*.css
%{_datadir}/glpi/plugins/%{pluginname}/ajax
%{_datadir}/glpi/plugins/%{pluginname}/front
%{_datadir}/glpi/plugins/%{pluginname}/generate
%{_datadir}/glpi/plugins/%{pluginname}/inc
%{_datadir}/glpi/plugins/%{pluginname}/logo
%{_datadir}/glpi/plugins/%{pluginname}/pics
%{_datadir}/glpi/plugins/%{pluginname}/report
%{_datadir}/glpi/plugins/%{pluginname}/templates
%{_datadir}/glpi/plugins/%{pluginname}/vendor
# data
%attr(750,apache,root) %{_localstatedir}/lib/glpi/files/_plugins/%{pluginname}


%changelog
* Thu May 04 2023 Jean-Marc Liger <ligenix@iscp.fr> - 2.10.3-1
- Version 2.10.3 for GLPI 10.0.x

* Thu May 04 2023 Jean-Marc Liger <ligenix@iscp.fr> - 2.7.7-1
- Version 2.7.7 for GLPI 9.5.x
- Initial RPM based on Remi Collet previous GLPI plugins spec files