Skip to content

Commit

Permalink
Add phpenv revision to version and use original rbenv version, modify…
Browse files Browse the repository at this point in the history
… docu to include both phpenv and rbenv, some comment/minor text changes
  • Loading branch information
DennisBirkholz committed Sep 11, 2014
1 parent 37facfe commit 95e7852
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions bin/phpenv-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@

set -e

RBENV_REPO="https://github.com/sstephenson/rbenv.git"
RBENV_REPO="https://github.com/sstephenson/rbenv"
PHPENV_REPO="https://github.com/chh/phpenv"

phpenv_script() {
local root="$1"

cat <<SH
#!/usr/bin/env bash
export PHPENV_ROOT=\${PHPENV_ROOT:-'$root'}
export RBENV_ROOT="\$PHPENV_ROOT"
exec "\$RBENV_ROOT/libexec/rbenv" "\$@"
exec "\$RBENV_ROOT/libexec/phpenv" "\$@"
SH
}

create_phpenv_bin() {
local install_location="$1"

phpenv_script "$install_location" > "$install_location/bin/phpenv"
chmod +x "$install_location/bin/phpenv"
}
Expand All @@ -61,13 +62,30 @@ clone_rbenv() {
phpenvify() {
local install_location="$1"
local cwd=$(pwd)

rev="$(cd "$(dirname "$0")" && git rev-parse --short HEAD)"

cd "$install_location"

for f in bin/rbenv* completions/rbenv* libexec/rbenv*; do
cp -va "$f" "${f/rbenv/phpenv}"
rm -f bin/rbenv bin/ruby-local-exec

# Create file phpenv prefixed copies of the original rbenv files
for f in completions/rbenv* libexec/rbenv*; do
cp -a "$f" "${f/rbenv/phpenv}"
done

sed --in-place -e 's/rbenv/phpenv/g' -e 's/RBENV/PHPENV/g' -e 's/Ruby/PHP/g' bin/phpenv* completions/phpenv* libexec/phpenv*
# Remove all rbenv/Ruby from phpenv prefixed files
sed --in-place -e 's/rbenv/phpenv/g' -e 's/RBENV/PHPENV/g' -e 's/Ruby/PHP/g' completions/phpenv* libexec/phpenv*

# Fix the version
cat <<SH > libexec/phpenv---version
#!/bin/sh
echo "phpenv $rev - based on \`$PHPENV_ROOT/libexec/rbenv---version\`"
SH
chmod a+x libexec/phpenv---version

# Fix link in help text:
sed --in-place -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

cd "$cwd"
}
Expand All @@ -87,17 +105,21 @@ else
echo "Installing phpenv in $PHPENV_ROOT"
if [ "$CHECKOUT" = "yes" ]; then
clone_rbenv "$PHPENV_ROOT"
phpenvify "$PHPENV_ROOT"
fi
fi

phpenvify "$PHPENV_ROOT"
create_phpenv_bin "$PHPENV_ROOT"

echo "Success."
echo
echo "export PATH=\"${PHPENV_ROOT}/bin:"'$PATH"'
echo 'eval "$(phpenv init -)"'
echo
echo "Add above line at the end of your ~/.bashrc \
echo "Add above lines at the end of your ~/.bashrc \
and restart your shell to use phpenv."
echo
echo "For bash completion support, also include the following line:"
echo
echo "source \"${PHPENV_ROOT}/completion/phpenv.bash\""
echo

0 comments on commit 95e7852

Please sign in to comment.