# COPR Ligenix's spec file for glpi-plugin-fusioninventory
#
# Copyright (c) 2021 Jean-Marc Liger 
#
# Forked from:
#
# remirepo spec file for glpi-fusioninventory
#
# Copyright (c) 2010-2020 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#
%global pluginname fusioninventory
%global glpi_min   9.5.3
%global glpi_max   9.6

Name:           glpi-plugin-%{pluginname}
Epoch:          1
Version:        9.5+4.2
Release:        3%{?dist}
Summary:        FusionInventory Server embedded as a GLPI plugin
Summary(fr):    Serveur FusionInventory en extension pour GLPI

License:        AGPLv3+
URL:            http://fusioninventory.org/

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

BuildArch:      noarch
BuildRequires:  gettext

# phpcompatinfo for version 9.5+4.2
Requires:       php-simplexml
Requires:       php-ctype
Requires:       php-date
Requires:       php-fileinfo
Requires:       php-filter
Requires:       php-hash
Requires:       php-json
Requires:       php-libxml
Requires:       php-mysqli
Requires:       php-pcre
Requires:       php-session
Requires:       php-spl
Requires:       php-xml
Requires:       php-zip
Requires:       php-zlib
%if 0%{?fedora} || 0%{?rhel} >= 8
Requires:      (glpi >= %{glpi_min} with glpi < %{glpi_max})
%else
Requires:       glpi >= %{glpi_min}
Requires:       glpi <  %{glpi_max}
%endif
Provides:       glpi-%{pluginname} = %{version}-%{release}
Obsoletes:      glpi-%{pluginname} <= 1:9.4+2.4


%description
FusionInventory Server embedded as a plugin into GLPI.


%description -l fr
Serveur FusionInventory embarqué dans une extension GLPI.


%prep
%setup -q -c

grep "define('PLUGIN_FUSIONINVENTORY_GLPI_M" %{pluginname}/setup.php

# remove test files, we do not distribute them in the rpm
rm -r %{pluginname}/.github \
   %{pluginname}/README.tests.md \
   %{pluginname}/phpunit.xml \

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

# dos2unix to avoid rpmlint warnings
for doc in docs/* ; do
    sed -i -e 's/\r//' $doc
done

# fix rpmlint warnings
find %{pluginname}/lib \(\
    -name .travis.yml \
    -o -name .npmignore \
    -o -name .gitignore \
    -o -name .gitmodules \
    -o -name .jshintrc \
    \) -exec rm -f {} \;
iconv -f ISO-8859-1 -t UTF-8 docs/CHANGES >a && mv a docs/CHANGES

# .htaccess replaced by a httpd config file
rm %{pluginname}/install/mysql/.htaccess \
   %{pluginname}/scripts/.htaccess

# protect install files
cat >httpd <<EOF
<Directory /usr/share/glpi/plugins/%{pluginname}/install/mysql>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order Allow,Deny
        Deny from all
    </IfModule>
</Directory>

<Directory /usr/share/glpi/plugins/%{pluginname}/scripts>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order Allow,Deny
        Deny from all
    </IfModule>
</Directory>
EOF

# override PHP configuration for php-fpm
cat >php <<EOF
allow_url_fopen=On
EOF

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


%build
# regenerate the locales
for po in %{pluginname}/locales/*.po
do
   msgfmt $po -o $(dirname $po)/$(basename $po .po).mo
done


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

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

# apache
install -p -D -m 644 httpd %{buildroot}%{_sysconfdir}/httpd/conf.d/%{name}.conf

# php
install -p -D -m 644 php %{buildroot}/%{_datadir}/glpi/plugins/%{pluginname}/.user.ini

# locales
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/*
%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
%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}/*.js
%{_datadir}/glpi/plugins/%{pluginname}/ajax
%{_datadir}/glpi/plugins/%{pluginname}/b
%{_datadir}/glpi/plugins/%{pluginname}/css
%{_datadir}/glpi/plugins/%{pluginname}/front
%{_datadir}/glpi/plugins/%{pluginname}/inc
%{_datadir}/glpi/plugins/%{pluginname}/install
%{_datadir}/glpi/plugins/%{pluginname}/js
%{_datadir}/glpi/plugins/%{pluginname}/lib
%{_datadir}/glpi/plugins/%{pluginname}/pics
%{_datadir}/glpi/plugins/%{pluginname}/report
%{_datadir}/glpi/plugins/%{pluginname}/scripts
%{_datadir}/glpi/plugins/%{pluginname}/.user.ini
# data
%attr(750,apache,root) %{_localstatedir}/lib/glpi/files/_plugins/%{pluginname}


%changelog
* Thu May 18 2023 Jean-Marc Liger <ligenix@iscp.fr> - 1:9.5+4.2-3
- Internalize php conf file

* Thu Oct 27 2022 Jean-Marc Liger <ligenix@iscp.fr> - 1:9.5+4.2-2
- Update apache conf file

* Mon Jul 18 2022 Jean-Marc Liger <ligenix@iscp.fr> - 1:9.5+4.2-1
- update to 9.5+4.2

* Wed Apr 13 2022 Jean-Marc Liger <ligenix@iscp.fr> - 1:9.5+4.0-1
- update to 9.5+4.0 for GLPI >= 9.5.3

* Mon May 17 2021 Jean-Marc Liger <ligenix@iscp.fr> - 1:9.5+3.0-2
- update spec file's copyright, thanks again to Remy Collet!

* Mon Apr 12 2021 Jean-Marc Liger <ligenix@iscp.fr> - 1:9.5+3.0-1
- rename to glpi-plugin-fusioninventory
- update to 9.5+3.0 for GLPI >= 9.5.4

* Tue Jan 21 2020 Remi Collet <remi@remirepo.net> - 1:9.4+2.4-1
- update to 9.4+2.4 for GLPI 9.4

* Tue Dec 10 2019 Remi Collet <remi@remirepo.net> - 1:9.4+2.3-1
- update to 9.4+2.3 for GLPI 9.4

* Sun Dec  1 2019 Remi Collet <remi@remirepo.net> - 1:9.4+2.2-1
- update to 9.4+2.2 for GLPI 9.4

* Tue Nov 12 2019 Remi Collet <remi@remirepo.net> - 1:9.4+2.1-1
- update to 9.4+2.1 for GLPI 9.4

* Mon Nov  4 2019 Remi Collet <remi@remirepo.net> - 1:9.4+2.0-1
- update to 9.4+2.0 for GLPI 9.4

* Fri Mar 29 2019 Remi Collet <remi@remirepo.net> - 1:9.4+1.1-1
- update to 9.4+1.1 for GLPI 9.4

* Tue Feb 12 2019 Remi Collet <remi@remirepo.net> - 1:9.4.0+1.0-1
- update to 9.4.0+1.0 for GLPI 9.4

* Wed Nov 28 2018 Remi Collet <remi@remirepo.net> - 1:9.3+1.3-1
- update to 9.3+1.3 for GLPI 9.3.2

* Fri Nov  2 2018 Remi Collet <remi@remirepo.net> - 1:9.3+1.2-1
- update to 9.3+1.2 for GLPI 9.3.2

* Mon Jul  9 2018 Remi Collet <remi@remirepo.net> - 1:9.3.0.1.1-1
- update to 9.3+1.1 for GLPI 9.3

* Thu Jun 28 2018 Remi Collet <remi@remirepo.net> - 1:9.3.0.1.0-1
- update to 9.3+1.0 for GLPI 9.3

* Tue Jun 12 2018 Remi Collet <remi@remirepo.net> - 1:9.2.0.2.0-1
- update to 9.2+2.0

* Mon Dec 18 2017 Remi Collet <remi@fedoraproject.org> - 1:9.2.0.1.0-2
- fix apache configuration when mod_php is not used

* Tue Sep 26 2017 Remi Collet <remi@fedoraproject.org> - 1:9.2.0.1.0-1
- update to 9.2+1.0

* Mon Dec 19 2016 Remi Collet <remi@fedoraproject.org> - 1:9.1.0.1.1-1
- update to 9.1+1.1

* Tue Nov 22 2016 Remi Collet <remi@fedoraproject.org> - 1:9.1.0.1.0-1
- update to 9.1+1.0

* Thu Jul 28 2016 Remi Collet <remi@fedoraproject.org> - 1:0.90.0.1.4-1
- update to 0.90+1.4

* Fri Jul 08 2016 Johan Cwiklinski <jcwiklinski AT teclib DOT com> - 1:0.90.0.1.3-2
- Add plugin data dir

* Wed May 18 2016 Remi Collet <remi@fedoraproject.org> - 1:0.90.0.1.3-1
- update to 0.90+1.3

* Fri Mar 25 2016 Remi Collet <remi@fedoraproject.org> - 1:0.90.0.1.2-1
- update to 0.90+1.2

* Wed Feb 24 2016 Remi Collet <remi@fedoraproject.org> - 1:0.90.0.1.1-1
- update to 0.90+1.1

* Thu Oct  8 2015 Remi Collet <remi@fedoraproject.org> - 1:0.90.0.1.0-1
- update to 0.90+1.0 for GLPI 0.90

* Tue Oct  6 2015 Remi Collet <remi@fedoraproject.org> - 1:0.85.0.1.3-1
- update to 0.85+1.3 for GLPI 0.85
  http://forge.fusioninventory.org/versions/217

* Sat Jul 25 2015 Remi Collet <remi@fedoraproject.org> - 1:0.85.0.1.2-1
- update to 0.85+1.2 for GLPI 0.85
  http://forge.fusioninventory.org/versions/213

* Sun Mar  1 2015 Remi Collet <remi@fedoraproject.org> - 1:0.85.0.1.1-1
- update to 0.85+1.1 for GLPI 0.85
  http://forge.fusioninventory.org/versions/208

* Tue Dec 23 2014 Remi Collet <remi@fedoraproject.org> - 1:0.85.0.1.0-1
- update to 0.85+1.0 for GLPI 0.85
  http://forge.fusioninventory.org/versions/97

* Wed Dec 17 2014 Remi Collet <remi@fedoraproject.org> - 1:0.85.0.1.0-0.1.BETA1
- update to 0.85+1.0-BETA1 for GLPI 0.85
  http://forge.fusioninventory.org/versions/97

* Mon Oct 27 2014 Remi Collet <remi@fedoraproject.org> - 1:0.84.0.3.5-1
- update to 0.84+3.5 for GLPI 0.84
  http://forge.fusioninventory.org/versions/204

* Fri Oct 17 2014 Remi Collet <remi@fedoraproject.org> - 1:0.84.0.3.4-1
- update to 0.84+3.4 for GLPI 0.84
  http://forge.fusioninventory.org/versions/198

* Thu Sep 11 2014 Remi Collet <remi@fedoraproject.org> - 1:0.84.0.3.3-1
- update to 0.84+3.3 for GLPI 0.84
  http://forge.fusioninventory.org/versions/196

* Wed Aug 20 2014 Remi Collet <remi@fedoraproject.org> - 1:0.84.0.3.2-1
- update to 0.84+3.2 for GLPI 0.84
  0.84+3.2: http://forge.fusioninventory.org/versions/191

* Mon Aug 18 2014 Remi Collet <remi@fedoraproject.org> - 1:0.84.0.3.1-1
- update to 0.84+3.1 for GLPI 0.84
  0.84+3.1: http://forge.fusioninventory.org/versions/189
  0.84+3.1: http://forge.fusioninventory.org/versions/181

* Tue Mar 25 2014 Remi Collet <remi@fedoraproject.org> - 1:0.84.0.2.2-1
- update to 0.84+2.2 for GLPI 0.84
  0.84+2.1: http://forge.fusioninventory.org/versions/172
  0.84+2.2: http://forge.fusioninventory.org/versions/178

* Wed Jan 15 2014 Remi Collet <remi@fedoraproject.org> - 1:0.84.0.2.0-1
- update to 0.84+2.0 for GLPI 0.84
- set allow_url_fopen=On in config

* Fri Aug 03 2012 Remi Collet <remi@fedoraproject.org> - 1:0.84.0.1.2-1
- update to 0.84+1.2 for GLPI 0.84
- add explicit dependency on required extensions

* Fri Aug 03 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.83.3.1.0-1
- update to 0.83+1.0 (finale)
  http://forge.fusioninventory.org/versions/67

* Fri Jul 27 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.83.3.1.0-0.2.RC3
- update to 0.83+1.0-RC3

* Thu Jul 12 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.83.3.1.0-0.1.RC2
- update to 0.83+1.0-RC2

* Fri Jun 08 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.83.0.1.0-0.4.beta4
- update to 0.83+1.0-beta4

* Thu May 03 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.83.0.1.0-0.4.beta3
- spec cleanups

* Thu May 03 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.83.0.1.0-0.3.beta3
- add missing fusinvdeploy

* Mon Apr 23 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.83.0.1.0-0.2.beta3
- update to 0.83+1.0-beta3

* Sun Feb 26 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.83.0.1.0-0.1.beta2
- update to 0.83+1.0-beta2 for glpi 0.83 RC

* Tue Jan 10 2012 Remi Collet <RPMS@FamilleCollet.com> - 1:0.80.0.1.1
- update to 0.80+1.1 (new version scheme)
  http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/versions/105
- switch from GPLv2+ to AGPLv3+

* Sun Sep 18 2011 Remi Collet <RPMS@FamilleCollet.com> - 2.4.0-1
- update to 2.4.0 finale

* Mon Aug 29 2011 Remi Collet <RPMS@FamilleCollet.com> - 2.4.0-0.4.RC3
- update to 2.4.0RC3

* Tue Aug 09 2011 Remi Collet <RPMS@FamilleCollet.com> - 2.4.0-0.3.RC2
- update to 2.4.0RC2

* Tue Jul 26 2011 Remi Collet <RPMS@FamilleCollet.com> - 2.4.0-0.2.RC1
- update to 2.4.0RC1

* Tue Jun 28 2011 Remi Collet <RPMS@FamilleCollet.com> - 2.4.0-0.1.beta2
- update to 2.4.0 Beta2 for GLPI 0.80

* Sun Jun 26 2011 Remi Collet <RPMS@FamilleCollet.com> - 2.3.5-1
- update to 2.3.5
  http://fusioninventory.org/wordpress/2011/06/26/fusioninventory-for-glpi-2-3-5-is-available/

* Sat Jun 11 2011 Remi Collet <RPMS@FamilleCollet.com> - 2.3.4-1
- update to 2.3.4 for GLPI 0.78

* Wed Aug 25 2010 Remi Collet <RPMS@FamilleCollet.com> - 2.2.2-1
- update to 2.2.2
  Changes : http://forge.fusioninventory.org/news/11

* Fri May 21 2010 Remi Collet <RPMS@FamilleCollet.com> - 2.2.1-1
- update to 2.2.1

* Tue May 18 2010 Remi Collet <RPMS@FamilleCollet.com> - 2.2.0-1
- Initial RPM