diff --git a/.gitignore b/.gitignore index 46f4fe2..7566d02 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ glpi-0.72.4-11497.tar.gz /glpi-0.90.3.tar.gz /glpi-0.90.4.tar.gz /glpi-0.90.5.tar.gz +/glpi-9.1-06a1bce.tar.gz diff --git a/glpi-0.90-autoload.patch b/glpi-0.90-autoload.patch deleted file mode 100644 index 898b286..0000000 --- a/glpi-0.90-autoload.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff -up inc/autoload.function.php.old inc/autoload.function.php ---- inc/autoload.function.php.old 2016-02-18 14:45:41.167015090 +0100 -+++ inc/autoload.function.php 2016-02-18 14:47:19.277404208 +0100 -@@ -332,10 +332,14 @@ function glpi_autoload($classname) { - // Use spl autoload to allow stackable autoload. - spl_autoload_register('glpi_autoload'); - -+if (file_exists(GLPI_ZEND_PATH . '/autoload.php')) { -+ require_once (GLPI_ZEND_PATH . '/autoload.php'); -+} else { - require_once (GLPI_ZEND_PATH . '/Loader/StandardAutoloader.php'); - $option = array(Zend\Loader\StandardAutoloader::LOAD_NS => array('Zend' => GLPI_ZEND_PATH)); - $loader = new Zend\Loader\StandardAutoloader($option); - $loader->register(); -+} - - // SimplePie autoloader - spl_autoload_register(array(new SimplePie_Autoloader(), 'autoload')); diff --git a/glpi-0.90-config_path.php b/glpi-0.90-config_path.php deleted file mode 100644 index 39802b0..0000000 --- a/glpi-0.90-config_path.php +++ /dev/null @@ -1,34 +0,0 @@ -queryOrDie($query, "4203"); -+ -+ // RPM provides a good system cron -+ $query = "UPDATE `glpi_crontasks` SET `mode`=2 WHERE `name`!='watcher' AND (`allowmode` & 2)"; -+ $DB->queryOrDie($query, "4203"); - } - - //Check if the port is in url -diff -up install/update.php.rpm install/update.php ---- install/update.php.rpm 2014-12-11 14:16:55.000000000 +0100 -+++ install/update.php 2014-12-17 13:36:22.420558338 +0100 -@@ -830,6 +830,10 @@ function updateDbUpTo031() { - $plugin = new Plugin(); - $plugin->unactivateAll(); - -+ // RPM provides a good system cron -+ $query = "UPDATE `glpi_crontasks` SET `mode`=2 WHERE `name`!='watcher' AND (`allowmode` & 2)"; -+ $DB->queryOrDie($query); -+ - DBmysql::optimize_tables($migration); - - return $ret; diff --git a/glpi-0.90-upstream.patch b/glpi-0.90-upstream.patch deleted file mode 100644 index 213f8e2..0000000 --- a/glpi-0.90-upstream.patch +++ /dev/null @@ -1,36 +0,0 @@ -Adapted for 0.90 from: - - -From efdec2554b4b65e72de049ea9897ddab5a2b7971 Mon Sep 17 00:00:00 2001 -From: Remi Collet -Date: Tue, 19 Apr 2016 11:30:16 +0200 -Subject: [PATCH] Drop Zend\Version usage - -This component is no more relevant as it reports its -own version, not the one of the framework. ---- - inc/config.class.php | 3 +- - lib/Zend/Version/README.md | 15 --- - lib/Zend/Version/Version.php | 226 ----------------------------------------- - lib/Zend/Version/composer.json | 32 ------ - tools/composer.json | 1 - - 5 files changed, 1 insertion(+), 276 deletions(-) - delete mode 100644 lib/Zend/Version/README.md - delete mode 100644 lib/Zend/Version/Version.php - delete mode 100644 lib/Zend/Version/composer.json - -diff --git a/inc/config.class.php b/inc/config.class.php -index 477ded2..f1008db 100644 ---- a/inc/config.class.php -+++ b/inc/config.class.php -@@ -1553,8 +1553,7 @@ static function showLibrariesInformation() { - "): ".(class_exists('ezcGraph') ? 'OK' : 'KO'). "\n"; - - // Zend -- $zv = new Zend\Version\Version; -- echo "Zend Framework version " . $zv::VERSION . " in (" . realpath(GLPI_ZEND_PATH) . ")\n"; -+ echo "Zend Framework in (" . realpath(GLPI_ZEND_PATH) . ")\n"; - - // SimplePie : - $sp = new SimplePie(); - diff --git a/glpi-9.1-config_path.php b/glpi-9.1-config_path.php new file mode 100644 index 0000000..37a3cd8 --- /dev/null +++ b/glpi-9.1-config_path.php @@ -0,0 +1,30 @@ + +Date: Mon, 26 Sep 2016 08:45:22 +0200 +Subject: [PATCH] ensure GLPI autoloader always first in the stack + +--- + inc/autoload.function.php | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/inc/autoload.function.php b/inc/autoload.function.php +index 12fc186..3fce416 100644 +--- a/inc/autoload.function.php ++++ b/inc/autoload.function.php +@@ -336,12 +336,12 @@ function glpi_autoload($classname) { + } + } + +-// Use spl autoload to allow stackable autoload. +-spl_autoload_register('glpi_autoload'); +- + // composer autoload + $autoload = dirname(__DIR__) . '/vendor/autoload.php'; + if (!file_exists($autoload)) { + die('Run "composer install --no-dev" in the glpi tree'); + } + require_once $autoload; ++ ++// Use spl autoload to allow stackable autoload. ++spl_autoload_register('glpi_autoload', false, true); +\ No newline at end of file diff --git a/glpi-9.1-pr1058.patch b/glpi-9.1-pr1058.patch new file mode 100644 index 0000000..e81cced --- /dev/null +++ b/glpi-9.1-pr1058.patch @@ -0,0 +1,67 @@ +From ef8e4cb98cbd0e2c59b0059141559178e840b882 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 26 Sep 2016 11:07:53 +0200 +Subject: [PATCH] fix 1057, ensure tests use correct configuration + +--- + .travis.yml | 3 +-- + phpunit.xml.dist | 1 + + tests/bootstrap.php | 8 ++++---- + tests/router.php | 4 ++++ + 4 files changed, 10 insertions(+), 6 deletions(-) + create mode 100644 tests/router.php + +diff --git a/.travis.yml b/.travis.yml +index a4401e8..ffdef3a 100644 +--- a/.travis.yml ++++ b/.travis.yml +@@ -8,8 +8,7 @@ before_script: + - composer install --no-dev + - mysql -u root -e 'create database glpitest;' + - php tools/cliinstall.php --lang=en_US --db=glpitest --user=root --tests +- - cp tests/config_db.php config/ +- - php -S localhost:8088 > /dev/null 2>&1 & ++ - php -S localhost:8088 tests/router.php &>/dev/null & + + script: + - mysql -u root -e 'select version();' +diff --git a/phpunit.xml.dist b/phpunit.xml.dist +index a25f179..e7d33da 100644 +--- a/phpunit.xml.dist ++++ b/phpunit.xml.dist +@@ -16,5 +16,6 @@ + + + ++ + + +diff --git a/tests/bootstrap.php b/tests/bootstrap.php +index bfbe957..c4dbf3f 100644 +--- a/tests/bootstrap.php ++++ b/tests/bootstrap.php +@@ -137,10 +137,10 @@ function loadDataset() { + $CFG_GLPI['root_doc'] = '/glpi'; + + // need to set theses in DB, because tests for API use http call and this bootstrap file is not called +- Config::setConfigurationValues('core', ['url_base' => 'http://localhost:8088', +- 'url_base_api' => 'http://localhost:8088/apirest.php']); +- $CFG_GLPI['url_base'] = 'http://localhost:8088'; +- $CFG_GLPI['url_base_api'] = 'http://localhost:8088/apirest.php'; ++ Config::setConfigurationValues('core', ['url_base' => GLPI_URI, ++ 'url_base_api' => GLPI_URI . '/apirest.php']); ++ $CFG_GLPI['url_base'] = GLPI_URI; ++ $CFG_GLPI['url_base_api'] = GLPI_URI . '/apirest.php'; + + @mkdir(GLPI_LOG_DIR, 0755, true); + +diff --git a/tests/router.php b/tests/router.php +new file mode 100644 +index 0000000..8b39e8c +--- /dev/null ++++ b/tests/router.php +@@ -0,0 +1,4 @@ ++ useless for php >= 5.5 +//require_once $vendor . '/password_compat/password.php'; +// "jasig/phpcas" +require_once '##DATADIR##/pear/CAS/Autoload.php'; +// "iamcal/lib_autolink" +require_once $vendor . '/php-iamcal-lib-autolink/autoload.php'; +// "phpmailer/phpmailer" +require_once $vendor . '/PHPMailer/PHPMailerAutoload.php'; +// "sabre/vobject" +require_once $vendor . '/Sabre/VObject/autoload.php'; +// "simplepie/simplepie" +require_once $vendor . '/php-simplepie/autoloader.php'; +// "tecnickcom/tcpdf" +require_once $vendor . '/tcpdf/tcpdf.php'; +// "zendframework/zend-cache" +// "zendframework/zend-i18n" +// "zendframework/zend-loader" +require_once $vendor . '/Zend/autoload.php'; +// "zetacomponents/graph" +require_once $vendor . '/ezc/Graph/autoloader.php'; +// "ramsey/array_column" +// => useless for php >= 5.5 +// "michelf/php-markdown" +require_once $vendor . '/Michelf/markdown-autoload.php'; +// "true/punycode" +if (file_exists($vendor . '/TrueBV/autoload.php')) { + require_once $vendor . '/TrueBV/autoload.php'; +} else { + require_once $vendor . '/TrueBV/Punycode.php'; +} diff --git a/glpi.spec b/glpi.spec index 12f1b2e..623c968 100644 --- a/glpi.spec +++ b/glpi.spec @@ -7,6 +7,13 @@ # Please, preserve the changelog entries # +%global gh_commit 06a1bceddbd0b635e7c35c87406b529be1f38a46 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +#global gh_date 20160923 +%global gh_owner glpi-project +%global gh_project glpi + + %if 0%{?fedora} < 20 # See https://bugzilla.redhat.com/1033025 # selinux-policy : Please include policy for GLPI @@ -25,9 +32,10 @@ %global with_nginx 0 %global with_httpd 0 %endif +%global with_tests 0%{!?_without_tests:1} -Name: glpi -Version: 0.90.5 +Name: %{gh_project} +Version: 9.1 Release: 1%{?dist} Summary: Free IT asset management software Summary(fr): Gestion Libre de Parc Informatique @@ -36,22 +44,46 @@ Group: Applications/Internet License: GPLv2+ and GPLv3+ URL: http://www.glpi-project.org/ # Upstream sources (not the github auto-generated archive) -Source0: https://github.com/glpi-project/%{name}/releases/download/%{version}%{?prever}/glpi-%{version}%{?prever}.tar.gz +Source0: https://github.com/%{gh_owner}/%{name}/archive/%{gh_commit}/%{name}-%{version}-%{gh_short}.tar.gz -Source1: glpi-httpd.conf -Source2: glpi-0.90-config_path.php -Source3: glpi-logrotate -Source4: glpi-nginx.conf +Source1: %{name}-httpd.conf +Source2: %{name}-9.1-config_path.php +Source12: %{name}-9.1-config_path_test.php +Source3: %{name}-logrotate +Source4: %{name}-nginx.conf +Source5: %{name}-fedora-autoloader.php -# Switch all internal cron tasks to system -Patch0: glpi-0.90-cron.patch -# Fix autoloader -Patch1: glpi-0.90-autoload.patch -# Upstream patches -Patch2: glpi-0.90-upstream.patch +Patch1: %{name}-9.1-pr1056.patch +Patch2: %{name}-9.1-pr1058.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch BuildRequires: gettext +%if %{with_tests} +BuildRequires: php-cli +BuildRequires: %{_bindir}/phpunit +BuildRequires: mariadb-server +#PHP libs +BuildRequires: php-htmLawed +BuildRequires: php-composer(zendframework/zend-cache) >= 2.4 +BuildRequires: php-composer(zendframework/zend-i18n) >= 2.4 +BuildRequires: php-composer(zendframework/zend-loader) >= 2.4 +BuildRequires: php-composer(guzzlehttp/guzzle) >= 5 +BuildRequires: php-composer(guzzlehttp/guzzle) < 6 +BuildRequires: php-composer(jasig/phpcas) >= 1.3 +BuildRequires: php-composer(iamcal/lib_autolink) >= 1.7 +BuildRequires: php-composer(sabre/vobject) >= 3.4 +BuildRequires: php-composer(michelf/php-markdown) >= 1.6 +BuildRequires: php-composer(true/punycode) >= 2 +# See https://bugzilla.redhat.com/1353451 +BuildRequires: php-simplepie +#Requires: php-composer(simplepie/simplepie) >= 1.4 +BuildRequires: php-composer(phpmailer/phpmailer) >= 5.2 +BuildRequires: php-composer(tecnickcom/tcpdf) >= 6.2 +BuildRequires: php-mysqli +BuildRequires: php-xmlrpc +BuildRequires: php-composer(zetacomponents/graph) +%endif %if %{with_nginx} Requires: nginx-filesystem @@ -65,10 +97,14 @@ Requires: php(httpd) %else Requires: httpd, mod_php %endif -Requires: php(language) >= 5.4 +# use 5.5+ to avoid dependency on ircmaxell/password-compat and ramsey/array_column +Requires: php(language) >= 5.5 +Requires: php-ctype +Requires: php-curl Requires: php-date -Requires: php-gd +Requires: php-exif Requires: php-fileinfo +Requires: php-gd Requires: php-imap Requires: php-json Requires: php-ldap @@ -76,16 +112,28 @@ Requires: php-mbstring Requires: php-mysqli Requires: php-pcre Requires: php-session -Requires: php-xml -Requires: php-PHPMailer -Requires: php-tcpdf -Requires: php-pear-CAS >= 1.2.0 +Requires: php-simplexml +Requires: php-wddx +Requires: php-xmlrpc +Requires: php-zlib Requires: php-htmLawed +Requires: php-composer(zendframework/zend-cache) >= 2.4 +Requires: php-composer(zendframework/zend-i18n) >= 2.4 +Requires: php-composer(zendframework/zend-loader) >= 2.4 +Requires: php-composer(guzzlehttp/guzzle) >= 5 +Requires: php-composer(guzzlehttp/guzzle) < 6 +Requires: php-composer(jasig/phpcas) >= 1.3 +Requires: php-composer(iamcal/lib_autolink) >= 1.7 +Requires: php-composer(sabre/vobject) >= 3.4 +Requires: php-composer(michelf/php-markdown) >= 1.6 +# upstream ask 2.1, compatibility with 2.0 ensure by autoloader +Requires: php-composer(true/punycode) >= 2.1 +# See https://bugzilla.redhat.com/1353451 Requires: php-simplepie -Requires: php-composer(zendframework/zend-cache) -Requires: php-composer(zendframework/zend-i18n) -Requires: php-composer(zendframework/zend-loader) -Requires: php-composer(ircmaxell/password-compat) +#Requires: php-composer(simplepie/simplepie) >= 1.4 +Requires: php-composer(phpmailer/phpmailer) >= 5.2 +Requires: php-composer(tecnickcom/tcpdf) >= 6.2 + Requires: php-composer(zetacomponents/graph) Requires: gnu-free-sans-fonts Requires: %{_sysconfdir}/logrotate.d @@ -122,40 +170,34 @@ techniciens grâce à une maintenance plus cohérente. %prep -%setup -q -n glpi - -grep %{version} config/define.php +%setup -q -n %{name}-%{gh_commit} -%patch0 -p0 -%patch1 -p0 +%patch1 -p1 %patch2 -p1 +grep %{version} config/define.php + find . -name \*.orig -exec rm {} \; -print # Drop bundled Flash files find lib -name \*.swf -exec rm {} \; -print # Use system lib -rm -rf lib/phpmailer -rm -rf lib/phpcas rm -rf lib/htmlawed -rm -rf lib/Zend -rm -rf lib/simplepie -rm -rf lib/tcpdf -rm -rf lib/password_compat -rm -rf lib/zeta -rm -rf lib/FreeSans.ttf : bundled JS libraries ls lib cp %{SOURCE2} config/config_path.php +mkdir vendor +sed -e "s,##DATADIR##,%{_datadir}," \ + %{SOURCE5} > vendor/autoload.php + mv lib/tiny_mce/license.txt LICENSE.tiny_mce -mv lib/icalcreator/lgpl.txt LICENSE.icalcreator rm scripts/glpi_cron_*.sh sed -i -e 's/\r//' LICENSE.tiny_mce -for fic in LISEZMOI.txt README.txt +for fic in LISEZMOI.txt do iconv -f ISO-8859-15 -t UTF-8 $fic >a && mv a $fic done @@ -176,11 +218,13 @@ done %install +rm -rf %{buildroot} + # ===== application ===== mkdir -p %{buildroot}/%{_datadir}/%{name} cp -a COPYING.txt *.php *.js %{buildroot}/%{_datadir}/%{name}/ -for i in ajax css front inc install lib locales pics plugins scripts +for i in ajax css front inc install lib locales pics plugins scripts vendor do cp -ar $i %{buildroot}/%{_datadir}/%{name}/$i done @@ -233,6 +277,69 @@ do done >%{name}.lang +%check +%if %{with_tests} +RET=0 + +: Running a PHP server +sed -e 's/localhost:8088/127.0.0.1:8089/' phpunit.xml.dist >phpunit.xml + +%{_bindir}/php -S 127.0.0.1:8089 tests/router.php &>/dev/null & + +PHPPID=$! + +: Running a MariaDB server +MYSQL_TEST_HOST=127.0.0.1 +MYSQL_TEST_PORT=3308 +MYSQL_TEST_SOCKET=$PWD/mysql.sock +MYSQL_PID_FILE=$PWD/mysql.pid + +rm -rf data +mkdir data +%{_bindir}/mysql_install_db \ + --datadir=$PWD/data + +%{_libexecdir}/mysqld \ + --socket=$MYSQL_TEST_SOCKET \ + --log-error=$PWD/mysql.log \ + --pid-file=$MYSQL_PID_FILE \ + --port=$MYSQL_TEST_PORT \ + --datadir=$PWD/data & + +n=15 +while [ $n -gt 0 ]; do + RESPONSE=$(%{_bindir}/mysqladmin --no-defaults --socket="$MYSQL_TEST_SOCKET" --user=root ping 2>&1 || :) + if [ "$RESPONSE" == "mysqld is alive" ]; then + break + fi + n=$(expr $n - 1) + sleep 1 +done + +: Set tests configuration +cp %{SOURCE12} config/config_path.php + +: Run upstream test suite +php tools/cliinstall.php --host=127.0.0.1:3308 --db=glpitest --user=root --tests --force --lang=en_US || RET=1 + +%{_bindir}/phpunit --verbose || RET=1 + +: Cleanup +if [ -s $MYSQL_PID_FILE ]; then + kill $(cat $MYSQL_PID_FILE) +fi +kill $PHPPID + +exit $RET +%else +: Test disabled +%endif + + +%clean +rm -rf %{buildroot} + + %post %if %{useselinux} ( @@ -269,7 +376,7 @@ fi %files -f %{name}.lang %doc *.txt LICENSE.* -%attr(770,root,apache) %dir %{_sysconfdir}/%{name} +%attr(2770,root,apache) %dir %{_sysconfdir}/%{name} %ghost %config(noreplace,missingok) %{_sysconfdir}/%{name}/config_db.php %config(noreplace) %{_sysconfdir}/httpd/conf.d/glpi.conf %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} @@ -280,7 +387,7 @@ fi # This folder can contain private information (sessions, docs, ...) %dir %_localstatedir/lib/%{name} -%attr(770,root,apache) %{_localstatedir}/lib/%{name}/files +%attr(2770,root,apache) %{_localstatedir}/lib/%{name}/files %dir %{_datadir}/%{name} %{_datadir}/%{name}/*.php @@ -297,11 +404,25 @@ fi %{_datadir}/%{name}/pics %{_datadir}/%{name}/plugins %{_datadir}/%{name}/scripts -%attr(770,root,apache) %dir %{_localstatedir}/log/%{name} +%{_datadir}/%{name}/vendor +%attr(2770,root,apache) %dir %{_localstatedir}/log/%{name} %dir %{_datadir}/%{name}/locales %changelog +* Mon Sep 26 2016 Remi Collet - 9.1-1 +- update to 9.1 + https://github.com/glpi-project/glpi/milestone/2?closed=1 +- add patch to ensure correct autolading + open https://github.com/glpi-project/glpi/pull/1056 +- add patch to ensure test suite use local server + open https://github.com/glpi-project/glpi/pull/1058 + +* Fri Sep 23 2016 Johan Cwiklinski - 9.1-0.1.20160922gitf4143e3 +- First pre-build for 9.1 series +- Drop upstream patches +- Add unit tests + * Wed Jul 27 2016 Remi Collet - 0.90.5-1 - update to 0.90.5 https://github.com/glpi-project/glpi/issues?q=milestone:0.90.5 diff --git a/mktar.sh b/mktar.sh deleted file mode 100755 index cf62020..0000000 --- a/mktar.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [ "$1" = "" ]; then - echo mising rev number - exit 1 -fi - -svn export -r $1 https://forge.indepnet.net/svn/glpi/branches/0.83-bugfixes glpi -rm -rf glpi/tools -mv glpi/install/mysql/glpi-0.83-empty.sql . -rm -f glpi/install/mysql/*.sql -mv glpi-0.83-empty.sql glpi/install/mysql/ -tar czf glpi-0.83-$1.tar.gz glpi && echo glpi-0.83-$1.tar.gz created -rm -rf glpi - diff --git a/sources b/sources index 9fd0f06..36f76d0 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -beaa3d1295d14c6b8b793b2944cfd1e1 glpi-0.90.5.tar.gz +fcfd638684d5264e9d33e41970ca9301 glpi-9.1-06a1bce.tar.gz