]> git.pld-linux.org Git - SPECS.git/blob - phpenv.spec
SPECS updated Wed 28 Jul 14:48:01 CEST 2021
[SPECS.git] / phpenv.spec
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
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
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
14 Source1:        %{name}-system-php
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
28 a phpenv executable which sets the PHPENV_ROOT environment variable to
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
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*
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
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
71
72 # cleanup backups after patching
73 find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
74
75 %install
76 rm -rf $RPM_BUILD_ROOT
77 install -d $RPM_BUILD_ROOT{%{_bindir},%{_appdir}/hooks}
78 cp -a libexec completions $RPM_BUILD_ROOT%{_appdir}
79
80 # phpenv system-php: detect system php packages and create their versions
81 install -p %{SOURCE1} $RPM_BUILD_ROOT%{_appdir}/libexec
82
83 ln -s %{_appdir}/libexec/%{name} $RPM_BUILD_ROOT%{_bindir}/%{name}
84
85 %clean
86 rm -rf $RPM_BUILD_ROOT
87
88 %post
89 %banner %{name} -e -o <<'EOF'
90 You probably want to execute the following line to add phpenv to your shell:
91
92 echo 'eval "$(phpenv init -)"' >> ~/.bash_profile
93 EOF
94
95
96 %files
97 %defattr(644,root,root,755)
98 %doc README.md LICENSE
99 %attr(755,root,root) %{_bindir}/phpenv
100 %dir %{_appdir}
101 %dir %{_appdir}/libexec
102 %attr(755,root,root) %{_appdir}/libexec/%{name}*
103 %{_appdir}/completions
104 %dir %{_appdir}/hooks
This page took 0.769237 seconds and 3 git commands to generate.