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
5 # - adds phpenv system-php to add php versions from installed system (may be renamed if better name provided)
6 Summary: Thin Wrapper around rbenv for PHP version managment
11 Group: Development/Languages/PHP
12 Source0: https://github.com/sstephenson/rbenv/archive/v%{version}/rbenv-%{version}.tar.gz
13 # Source0-md5: c4a15a4dccf3dc1d28d08e87fb7c7789
14 Source1: %{name}-system-php
15 URL: https://github.com/CHH/phpenv
18 # https://github.com/CHH/php-build
20 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
22 %define _appdir %{_datadir}/%{name}
25 Sets up a separate rbenv environment for PHP
27 This environment is stored in the $HOME/.phpenv directory and contains
28 a phpenv executable which sets the PHPENV_ROOT environment variable to
31 To install PHP versions, just put them to the $HOME/.phpenv/versions
36 mv rbenv-%{version}/* .
38 # deprecated as of rbenv 0.4.0, pointless in phpenv
39 rm bin/ruby-local-exec
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}"
48 # Remove all rbenv/Ruby from phpenv prefixed files
50 -e 's/rbenv/phpenv/g' \
51 -e 's/RBENV/PHPENV/g' \
54 completions/phpenv* libexec/phpenv*
57 cat <<'SH' > libexec/phpenv---version
59 echo "phpenv %{version} - based on rbenv %{version}"
61 chmod a+x libexec/phpenv---version
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
68 # use pld (not debian) version of hooks dir
69 # https://github.com/sstephenson/rbenv/pull/176
70 sed -i -e 's#/usr/lib/phpenv/hooks#%{_appdir}/hooks#' libexec/phpenv
72 # cleanup backups after patching
73 find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
76 rm -rf $RPM_BUILD_ROOT
77 install -d $RPM_BUILD_ROOT{%{_bindir},%{_appdir}/hooks}
78 cp -a libexec completions $RPM_BUILD_ROOT%{_appdir}
80 # phpenv system-php: detect system php packages and create their versions
81 install -p %{SOURCE1} $RPM_BUILD_ROOT%{_appdir}/libexec
83 ln -s %{_appdir}/libexec/%{name} $RPM_BUILD_ROOT%{_bindir}/%{name}
86 rm -rf $RPM_BUILD_ROOT
89 %banner %{name} -e -o <<'EOF'
90 You probably want to execute the following line to add phpenv to your shell:
92 echo 'eval "$(phpenv init -)"' >> ~/.bash_profile
97 %defattr(644,root,root,755)
98 %doc README.md LICENSE
99 %attr(755,root,root) %{_bindir}/phpenv
101 %dir %{_appdir}/libexec
102 %attr(755,root,root) %{_appdir}/libexec/%{name}*
103 %{_appdir}/completions
104 %dir %{_appdir}/hooks