]>
Commit | Line | Data |
---|---|---|
10b4395e ER |
1 | # NOTE: |
2 | # - use similar recipe as done by CHH (https://github.com/CHH/phpenv) | |
3 | # however, make it more rbenv compatible: code in /usr/share, env files in ~/.phpenv | |
4 | # - actually don't need code from CHH/phpenv as all is inlined in this .spec | |
89c77ea6 | 5 | # - adds phpenv system-php to add php versions from installed system (may be renamed if better name provided) |
10b4395e ER |
6 | Summary: Thin Wrapper around rbenv for PHP version managment |
7 | Name: phpenv | |
8 | Version: 0.4.0 | |
9 | Release: 1 | |
10 | License: MIT | |
11 | Group: Development/Languages/PHP | |
12 | Source0: https://github.com/sstephenson/rbenv/archive/v%{version}/rbenv-%{version}.tar.gz | |
13 | # Source0-md5: c4a15a4dccf3dc1d28d08e87fb7c7789 | |
89c77ea6 | 14 | Source1: phpenv-system-php |
10b4395e ER |
15 | URL: https://github.com/CHH/phpenv |
16 | Requires: bash | |
17 | BuildArch: noarch | |
18 | # https://github.com/CHH/php-build | |
19 | Suggests: php-build | |
20 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
21 | ||
22 | %define _appdir %{_datadir}/%{name} | |
23 | ||
24 | %description | |
25 | Sets up a separate rbenv environment for PHP | |
26 | ||
27 | This environment is stored in the $HOME/.phpenv directory and contains | |
b4d329b4 | 28 | a phpenv executable which sets the PHPENV_ROOT environment variable to |
10b4395e ER |
29 | $HOME/.phpenv. |
30 | ||
31 | To install PHP versions, just put them to the $HOME/.phpenv/versions | |
32 | directory. | |
33 | ||
34 | %prep | |
35 | %setup -qc | |
36 | mv rbenv-%{version}/* . | |
37 | ||
38 | # deprecated as of rbenv 0.4.0, pointless in phpenv | |
39 | rm bin/ruby-local-exec | |
40 | ||
41 | # fully replace to rbenv -> phpenv | |
42 | # https://github.com/CHH/phpenv/pull/30 | |
43 | # Create file phpenv prefixed copies of the original rbenv files | |
44 | for f in bin/rbenv* completions/rbenv* libexec/rbenv*; do | |
45 | mv "$f" "${f/rbenv/phpenv}" | |
46 | done | |
47 | ||
48 | # Remove all rbenv/Ruby from phpenv prefixed files | |
c0a21694 ER |
49 | sed -i \ |
50 | -e 's/rbenv/phpenv/g' \ | |
51 | -e 's/RBENV/PHPENV/g' \ | |
52 | -e 's/Ruby/PHP/g' \ | |
53 | -e 's/ruby/php/g' \ | |
54 | completions/phpenv* libexec/phpenv* | |
10b4395e ER |
55 | |
56 | # Fix the version | |
57 | cat <<'SH' > libexec/phpenv---version | |
58 | #!/bin/sh | |
59 | echo "phpenv %{version} - based on rbenv %{version}" | |
60 | SH | |
61 | chmod a+x libexec/phpenv---version | |
62 | ||
63 | # Fix link in help text: | |
64 | RBENV_REPO="https://github.com/sstephenson/rbenv" | |
65 | PHPENV_REPO="https://github.com/chh/phpenv" | |
66 | sed -i -e "s|^.*For full documentation.*\$| echo \"For full documentation, see:\"\n echo \" rbenv: ${RBENV_REPO}#readme\"\n echo \" phpenv: ${PHPENV_REPO}#readme\"|" libexec/phpenv-help | |
67 | ||
0dcc60c1 | 68 | # use pld (not debian) version of hooks dir |
8d81f91a | 69 | # https://github.com/sstephenson/rbenv/pull/176 |
0dcc60c1 ER |
70 | sed -i -e 's#/usr/lib/phpenv/hooks#%{_appdir}/hooks#' libexec/phpenv |
71 | ||
8d81f91a ER |
72 | # cleanup backups after patching |
73 | find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f | |
74 | ||
10b4395e ER |
75 | %install |
76 | rm -rf $RPM_BUILD_ROOT | |
0dcc60c1 | 77 | install -d $RPM_BUILD_ROOT{%{_bindir},%{_appdir}/hooks} |
10b4395e ER |
78 | cp -a libexec completions $RPM_BUILD_ROOT%{_appdir} |
79 | ||
89c77ea6 ER |
80 | # phpenv system-php: detect system php packages and create their versions |
81 | install -p %{SOURCE1} $RPM_BUILD_ROOT%{_appdir}/libexec | |
82 | ||
10b4395e ER |
83 | ln -s %{_appdir}/libexec/%{name} $RPM_BUILD_ROOT%{_bindir}/%{name} |
84 | ||
85 | %clean | |
86 | rm -rf $RPM_BUILD_ROOT | |
87 | ||
88 | %files | |
89 | %defattr(644,root,root,755) | |
90 | %doc README.md LICENSE | |
91 | %attr(755,root,root) %{_bindir}/phpenv | |
92 | %dir %{_appdir} | |
93 | %dir %{_appdir}/libexec | |
94 | %attr(755,root,root) %{_appdir}/libexec/%{name}* | |
95 | %{_appdir}/completions | |
0dcc60c1 | 96 | %dir %{_appdir}/hooks |