# COPR Ligenix's spec file for glpi-plugin-appliances
#
# Copyright (c) 2021-2022 Jean-Marc Liger 
#
# Forked from:
#
# spec file for glpi-appliances
#
# 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 appliances
%global glpi_min   10.0.0
%global glpi_max   10.1.0


Name:           glpi-plugin-%{pluginname}
Version:        3.2.0
Release:        1%{?dist}
Summary:        GLPI Plugin to manage appliances
Summary(fr):    Extension GLPI de gestion des applicatifs

License:        AGPLv3+
URL:            https://github.com/yllen/%{pluginname}
  
Source0:        https://github.com/yllen/%{pluginname}/releases/download/v%{version}/glpi-%{pluginname}-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  gettext

%if 0%{?fedora} || 0%{?rhel} >= 8
Requires:      (glpi >= %{glpi_min} with glpi < %{glpi_max})
%else
Requires:       glpi >= %{glpi_min}
Requires:       glpi <  %{glpi_max}
Requires:       glpi-plugin-pdf
%endif
Provides:       glpi-%{pluginname} = %{version}-%{release}
Obsoletes:      glpi-%{pluginname} <= 2.5.1


%description
This plugin add appliances management to GLPI
* Appliances creation (composed by various inventory item)
* Direct management from items
* Integrated with Helpdesk


%description -l fr
Cette extension permet la gestion des applicatifs dans GLPI
* Création d’applicatifs composé de plusieurs items
* Gestion directe à partir de l’item
* Intégration avec l'assistance


%prep
%setup -q -c 

# update forge URL
find -type f -name "*.php" -exec sed -i 's/forge.glpi-project.org\/projects/github.com\/yllen/g' {} +

# remove unused files
rm %{pluginname}/%{pluginname}.xml

cat >httpd <<EOF
<Directory /usr/share/glpi/plugins/%{pluginname}/sql>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order Allow,Deny
        Deny from all
    </IfModule>
</Directory>
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
mkdir -p %{buildroot}/%{_datadir}/glpi/plugins
cp -ar %{pluginname} %{buildroot}/%{_datadir}/glpi/plugins/%{pluginname}

# ===== apache =====
rm -f %{buildroot}/%{_datadir}/glpi/plugins/%{pluginname}/sql/.htaccess
mkdir -p %{buildroot}/%{_sysconfdir}/httpd/conf.d/
install --mode 644 httpd %{buildroot}/%{_sysconfdir}/httpd/conf.d/%{name}.conf

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
%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}/%{pluginname}.png
%{_datadir}/glpi/plugins/%{pluginname}/*.php
%{_datadir}/glpi/plugins/%{pluginname}/ajax
%{_datadir}/glpi/plugins/%{pluginname}/front
%{_datadir}/glpi/plugins/%{pluginname}/inc
%{_datadir}/glpi/plugins/%{pluginname}/sql


%changelog
* Tue Oct 11 2022 Jean-Marc Liger <ligenix@iscp.fr> - 3.2.0-1
- version 3.2.0 for GLPI 10.0.x
- switch from GPLv2+ to AGPLv3+
- update forge URL

* Fri Jul 29 2022 Jean-Marc Liger <ligenix@iscp.fr> - 3.1.1-3
- new github source
  https://github.com/yllen/appliances/wiki

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

* Thu Apr 15 2021 Jean-Marc Liger <ligenix@iscp.fr> - 3.1.1-1
- rename to glpi-plugin-appliances
- version 3.1.1 for GLPI >= 9.5.2
  https://forge.glpi-project.org/versions/1319

* Tue Feb  4 2020 Remi Collet <remi@remirepo.net> - 2.5.1-1
- version 2.5.1 for GLPI 9.4
  https://forge.glpi-project.org/versions/1293

* Thu Mar 28 2019 Remi Collet <remi@remirepo.net> - 2.5.0-1
- version 2.5.0 for GLPI 9.4
  https://forge.glpi-project.org/versions/1292

* Fri Oct 12 2018 Remi Collet <remi@remirepo.net> - 2.4.1-1
- version 2.4.1 for GLPI 9.3
  https://forge.glpi-project.org/versions/1282

* Fri Sep 14 2018 Remi Collet <remi@remirepo.net> - 2.4.0-1
- version 2.4.0 for GLPI 9.3
  https://forge.glpi-project.org/versions/1276

* Fri Sep 14 2018 Remi Collet <remi@remirepo.net> - 2.3.3-1
- version 2.3.3 for GLPI 9.2
  https://forge.glpi-project.org/versions/1275

* Fri Mar 16 2018 Remi Collet <remi@remirepo.net> - 2.3.2-1
- version 2.3.2 for GLPI 9.2
  https://forge.glpi-project.org/versions/1262

* Mon Jan 15 2018 Remi Collet <remi@remirepo.net> - 2.3.1
- version 2.3.1 for GLPI 9.2
  https://forge.glpi-project.org/versions/1253

* Tue Oct 10 2017 Remi Collet <remi@remirepo.net> - 2.3.0
- version 2.3.0 for GLPI 9.2
  https://forge.glpi-project.org/versions/1244

* Mon Jan  9 2017 Remi Collet <remi@fedoraproject.org> - 2.2.1
- version 2.2.1
  https://forge.glpi-project.org/versions/1203

* Tue Jun 28 2016 Johan Cwiklinski <jcwiklinski AT teclib DOT com> - 2.1-1
- Last upstream release
- Clean rpmlint mixed tabs and spaces warning

* Tue Jun 28 2016 Johan Cwiklinski <jcwiklinski AT teclib DOT com> - 1.9.1-1.1
- Change URL and Source

* Sun Jun  8 2014 Remi Collet <remi@fedoraproject.org> - 1.9.1-1
- version 1.9.1
  https://forge.indepnet.net/versions/1002

* Mon Sep 30 2013 Remi Collet <remi@fedoraproject.org> - 1.9.0-1
- version 1.9.0 for GLPI 0.84.2

* Thu Jul 12 2012 Remi Collet <Fedora@FamilleCollet.com> - 1.8.1-1
- version 1.8.1 for GLPI 0.83.3
  https://forge.indepnet.net/projects/appliances/versions/747

* Fri Apr 06 2012 Remi Collet <Fedora@FamilleCollet.com> - 1.8.0-1
- version 1.8.0
  https://forge.indepnet.net/projects/appliances/versions/614
- fix config for httpd 2.4
- add 2 patches from SVN (php 5.4.0 + missing tab)

* Sun Feb 26 2012 Remi Collet <Fedora@FamilleCollet.com> - 1.8.0-0.1.svn184
- version 1.8.0 for glpi 0.83RC (svn snapshot)

* Thu Jun 30 2011 Remi Collet <Fedora@FamilleCollet.com> - 1.7.0-1
- version 1.7.0 released

* Tue Jun 28 2011 Remi Collet <Fedora@FamilleCollet.com> - 1.7.0-0.1.svn136
- version 1.7.0 for glpi 0.80 (svn snapshot)

* Tue Oct 12 2010 Remi Collet <Fedora@FamilleCollet.com> - 1.6.0-1
- version 1.6.0 and GLPI 0.78 released

* Wed Aug 25 2010 Remi Collet <Fedora@FamilleCollet.com> - 1.6.0-0.1.svn114
- new svn snapshot

* Sun Jun 20 2010 Remi Collet <Fedora@FamilleCollet.com> - 1.6.0-0.1.svn110
- version 1.6.0 for glpi 0.78 RC (svn snapshot)
- initial RPM