[packages/phpenv] add phpenv system-php plugin: detect system php packages and create their
glen
glen at pld-linux.org
Sun Nov 30 21:48:15 CET 2014
commit 89c77ea687143649b079b8a57f996eb27419d6ab
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Sun Nov 30 22:47:22 2014 +0200
add phpenv system-php plugin: detect system php packages and create their
phpenv-system-php | 37 +++++++++++++++++++++++++++++++++++++
phpenv.spec | 5 +++++
2 files changed, 42 insertions(+)
---
diff --git a/phpenv.spec b/phpenv.spec
index ed13433..cb02ada 100644
--- a/phpenv.spec
+++ b/phpenv.spec
@@ -2,6 +2,7 @@
# - use similar recipe as done by CHH (https://github.com/CHH/phpenv)
# however, make it more rbenv compatible: code in /usr/share, env files in ~/.phpenv
# - actually don't need code from CHH/phpenv as all is inlined in this .spec
+# - adds phpenv system-php to add php versions from installed system (may be renamed if better name provided)
Summary: Thin Wrapper around rbenv for PHP version managment
Name: phpenv
Version: 0.4.0
@@ -10,6 +11,7 @@ License: MIT
Group: Development/Languages/PHP
Source0: https://github.com/sstephenson/rbenv/archive/v%{version}/rbenv-%{version}.tar.gz
# Source0-md5: c4a15a4dccf3dc1d28d08e87fb7c7789
+Source1: phpenv-system-php
URL: https://github.com/CHH/phpenv
Requires: bash
BuildArch: noarch
@@ -75,6 +77,9 @@ rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT{%{_bindir},%{_appdir}/hooks}
cp -a libexec completions $RPM_BUILD_ROOT%{_appdir}
+# phpenv system-php: detect system php packages and create their versions
+install -p %{SOURCE1} $RPM_BUILD_ROOT%{_appdir}/libexec
+
ln -s %{_appdir}/libexec/%{name} $RPM_BUILD_ROOT%{_bindir}/%{name}
%clean
diff --git a/phpenv-system-php b/phpenv-system-php
new file mode 100755
index 0000000..fdb74a4
--- /dev/null
+++ b/phpenv-system-php
@@ -0,0 +1,37 @@
+#!/bin/sh
+# detect system php packages and create their versions
+# inspired by rbenv-alternatives:
+# https://github.com/terceiro/rbenv-alternatives
+# Author: Elan Ruusamäe <glen at pld-linux.org>
+# Date: 2014-11-30
+
+set -e
+[ -n "$PHPENV_DEBUG" ] && set -x
+
+if [ "$1" = '--version' ]; then
+ echo '0.4.0'
+ exit 0
+fi
+
+if ! which rpm >/dev/null; then
+ echo "Sorry, it seems like you do not have rpm available on your PATH."
+ echo "Are you sure this is a RPM based system?"
+ exit 1
+fi
+
+for php in /usr/bin/php??; do
+ pkg=$(rpm -qf $php) || continue
+ version=$(rpm -q --qf '%{VERSION}' $pkg)
+ # use php-X.Y only for version selection
+ version=${version%.${version#*.*.}}-pld
+ echo "* Found $php (via $pkg) using $version as version"
+
+ if [ -d "${PHPENV_ROOT}/versions/$version" ]; then
+ echo "Skipping $version, it already exists"
+ else
+ rm -rf "${PHPENV_ROOT}/versions/$version"
+ mkdir -p "${PHPENV_ROOT}/versions/$version/bin"
+ ln -s "$php" "${PHPENV_ROOT}/versions/$version/bin/php"
+ echo "Added $version"
+ fi
+done
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/phpenv.git/commitdiff/89c77ea687143649b079b8a57f996eb27419d6ab
More information about the pld-cvs-commit
mailing list