1 |
commit: d77e12134dd5df6bf717799d8eeb256094644c60 |
2 |
Author: Brian Evans <grknight <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu May 9 13:57:38 2019 +0000 |
4 |
Commit: Brian Evans <grknight <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu May 9 13:57:38 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d77e1213 |
7 |
|
8 |
dev-php/twig: Remove obsolete extension and use new autoloader |
9 |
|
10 |
The twig extension is no longer necessary as PHP 5.6 is end-of-life |
11 |
|
12 |
Also, use the dev-php/fedora-autoloader to replace Twig's autoloader |
13 |
so that it simulates composer loading with Psr4 and does not throw |
14 |
errors in the logs |
15 |
|
16 |
In addition, the ctype USE on dev-lang/php is now required |
17 |
|
18 |
Package-Manager: Portage-2.3.66, Repoman-2.3.12 |
19 |
Signed-off-by: Brian Evans <grknight <AT> gentoo.org> |
20 |
|
21 |
dev-php/twig/files/Autoloader.php | 18 ++++++++++++++ |
22 |
dev-php/twig/twig-1.40.1-r1.ebuild | 49 ++++++++++++++++++++++++++++++++++++++ |
23 |
2 files changed, 67 insertions(+) |
24 |
|
25 |
diff --git a/dev-php/twig/files/Autoloader.php b/dev-php/twig/files/Autoloader.php |
26 |
new file mode 100644 |
27 |
index 00000000000..e4bef547125 |
28 |
--- /dev/null |
29 |
+++ b/dev-php/twig/files/Autoloader.php |
30 |
@@ -0,0 +1,18 @@ |
31 |
+<?php |
32 |
+/* Autoloader for dev-php/twig */ |
33 |
+ |
34 |
+if (!class_exists('Twig_Autoloader', false)) { |
35 |
+ // polyfill for old code |
36 |
+ class Twig_Autoloader { |
37 |
+ public static function register(){} |
38 |
+ public static function autoload(){} |
39 |
+ } |
40 |
+} |
41 |
+ |
42 |
+if (!class_exists('Fedora\\Autoloader\\Autoload', false)) { |
43 |
+ require_once '/usr/share/php/Fedora/Autoloader/autoload.php'; |
44 |
+} |
45 |
+ |
46 |
+\Fedora\Autoloader\Autoload::addPsr0('Twig_', __DIR__.'/lib'); |
47 |
+\Fedora\Autoloader\Autoload::addPsr4('Twig\\', __DIR__.'/src'); |
48 |
+ |
49 |
|
50 |
diff --git a/dev-php/twig/twig-1.40.1-r1.ebuild b/dev-php/twig/twig-1.40.1-r1.ebuild |
51 |
new file mode 100644 |
52 |
index 00000000000..c06e5c62736 |
53 |
--- /dev/null |
54 |
+++ b/dev-php/twig/twig-1.40.1-r1.ebuild |
55 |
@@ -0,0 +1,49 @@ |
56 |
+# Copyright 1999-2019 Gentoo Authors |
57 |
+# Distributed under the terms of the GNU General Public License v2 |
58 |
+ |
59 |
+EAPI=7 |
60 |
+ |
61 |
+MY_PN="Twig" |
62 |
+S="${WORKDIR}/${MY_PN}-${PV}" |
63 |
+ |
64 |
+DESCRIPTION="PHP templating engine with syntax similar to Django" |
65 |
+HOMEPAGE="http://twig.sensiolabs.org/" |
66 |
+SRC_URI="https://github.com/twigphp/${MY_PN}/archive/v${PV}.tar.gz |
67 |
+ -> ${P}.tar.gz" |
68 |
+LICENSE="BSD" |
69 |
+SLOT="0" |
70 |
+KEYWORDS="~amd64 ~x86" |
71 |
+IUSE="doc test" |
72 |
+ |
73 |
+RDEPEND="dev-lang/php:*[ctype] dev-php/fedora-autoloader" |
74 |
+DEPEND="test? ( dev-php/phpunit ${RDEPEND} )" |
75 |
+# Test fail due to missing Symphony dependencies |
76 |
+RESTRICT="test" |
77 |
+ |
78 |
+src_install(){ |
79 |
+ # The autoloader requires the 'T' in "Twig" capitalized. |
80 |
+ insinto "/usr/share/php/${MY_PN}/lib" |
81 |
+ doins -r lib/"${MY_PN}"/* |
82 |
+ insinto "/usr/share/php/${MY_PN}/src" |
83 |
+ doins -r src/* |
84 |
+ insinto "/usr/share/php/${MY_PN}" |
85 |
+ doins "${FILESDIR}/Autoloader.php" |
86 |
+ |
87 |
+ dodoc README.rst CHANGELOG |
88 |
+ |
89 |
+ # This installs the reStructuredText source documents. There's got |
90 |
+ # to be some way to turn them into HTML using Sphinx, but upstream |
91 |
+ # doesn't provide for it. |
92 |
+ use doc && dodoc -r doc |
93 |
+} |
94 |
+ |
95 |
+src_test(){ |
96 |
+ cp "${FILESDIR}/Autoloader.php" "${S}" || die |
97 |
+ phpunit --bootstrap Autoloader.php || die "test suite failed" |
98 |
+ rm "${S}/Autoloader.php" || die |
99 |
+} |
100 |
+ |
101 |
+pkg_postinst(){ |
102 |
+ elog "${PN} has been installed in /usr/share/php/${MY_PN}/." |
103 |
+ elog "To use it in a script, require('${MY_PN}/Autoloader.php')" |
104 |
+} |