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

Name:           glpi-plugin-%{pluginname}
Version:        1.5.3.5
Release:        1%{?dist}
Summary:        Plugin to make PDF reports with user inventory

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

Source0:        https://github.com/CanMik/%{pluginname}/releases/download/%{version}/%{pluginname}-%{version}.tar.gz

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
Requires:       php >= 8.0.15

Provides:       bundled(php-dompdf)

%description
Plugin to make PDF reports with user inventory

Features:
- Making PDFs with all or selected user inventory
- Saving protocols in GLPI Documents
- Possibility to create different protocol templates
- Templates have configurable name, font, orientation, logo image, city, content and footer
- Possibility to make comments to any selected item
- Showing Manufacturer (only first word to be clearly) and Model of item
- Showing serial number or inventory number in one or two columns
- Possibility to add custom rows
- Possibility to add notes to export


%prep
%setup -q -c
mv %{pluginname}{-%{version},}

# remove unused files
find %{pluginname} -name \*.xml* -delete -print
find %{pluginname} -name \*.yml* -delete -print
find %{pluginname} -name composer.json -delete -print
find %{pluginname} -name composer.lock -delete -print
find %{pluginname} -name .git* -exec rm -rf '{}' + -print

# dos2unix to avoid rpmlint warnings
find %{pluginname} -type d -exec chmod 0755 '{}' +
find %{pluginname} -type f -exec chmod 0644 '{}' +
for f in $(find %{pluginname} -type f -exec file '{}' + | grep CRLF | cut -d":" -f1); do
   sed -i 's/\r//' $f
done

# move doc files
mkdir docs
mv %{pluginname}/docs/        docs/
mv %{pluginname}/README.md    docs/
mv %{pluginname}/screenshots/ docs/


%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
%doc docs/*
%dir %{_datadir}/glpi/plugins/%{pluginname}
%dir %{_datadir}/glpi/plugins/%{pluginname}/locales
%{_datadir}/glpi/plugins/%{pluginname}/*.png
%{_datadir}/glpi/plugins/%{pluginname}/*.php
%{_datadir}/glpi/plugins/%{pluginname}/css
%{_datadir}/glpi/plugins/%{pluginname}/dompdf
%{_datadir}/glpi/plugins/%{pluginname}/front
%{_datadir}/glpi/plugins/%{pluginname}/img
%{_datadir}/glpi/plugins/%{pluginname}/inc
# Data
%attr(750,apache,:oot) %{_localstatedir}/lib/glpi/files/_plugins/%{pluginname}


%changelog
* Sat Jul 01 2023 Jean-Marc Liger <ligenix@iscp.fr> - 1.5.3.5-1
- Version 1.5.3.5

* Thu May 04 2023 Jean-Marc Liger <ligenix@iscp.fr> - 1.5.3.2-2
- Move screenshots to docs

* Mon May 01 2023 Jean-Marc Liger <ligenix@iscp.fr> - 1.5.3.2-1
- Version 1.5.3.2

* Sat Jul 30 2022 Jean-Marc Liger <ligenix@iscp.fr> - 1.5.2.2-2
- Add php >= 8.0.15 dependency

* Sat Jul 30 2022 Jean-Marc Liger <ligenix@iscp.fr> - 1.5.2.2-1
- Version 1.5.2.2 for GLPI 10.0.x
- New github source https://github.com/CanMik/protocolsmanager
  fork from stopped https://github.com/mateusznitka/protocolsmanager

* Fri May 21 2021 Jean-Marc Liger <ligenix@iscp.fr> - 1.4.2-2
- dos2unix

* Mon May 17 2021 Jean-Marc Liger <ligenix@iscp.fr> - 1.4.2-1
- Initial RPM based on Remi Collet previous GLPI plugins spec files