Permalink
Browse files

Support a "main version".

The first entry in default-versions.txt is used as the main version.
That is, links to it are created in the shared bin/ folder without any
version suffix.
Changing the main version is as simple as swapping the order of lines in
default-versions.txt.

This is an attempt at fixing http://sourceforge.net/p/phpfarm/tickets/6/.
  • Loading branch information...
fpoirotte committed Nov 6, 2011
1 parent 48974d5 commit e76871d6acafa23d6e4b0014b9f194be73abe1b1
Showing with 32 additions and 0 deletions.
  1. +7 −0 README.rst
  2. +10 −0 src/compile.sh
  3. +9 −0 src/main.sh
  4. +6 −0 src/pyrus.sh
View
@@ -102,6 +102,13 @@ It generally looks somewhat like this::
# required for production during the post-install step.
5.3.1-prod
+Last but now least, when using a ``custom/default-versions.txt`` file,
+the first version in this file will be marked as your "main version",
+creating links to this version's tools without any suffix.
+So, if phpfarm's ``inst/bin`` directory is in your ``$PATH`` and there
+is no ``php`` executable installed globally on your system, calling
+``php`` will actually execute your main version's ``php``.
+
Caveats
-------
View
@@ -222,6 +222,16 @@ if [ -e "$instdir/bin/phar.phar" ]; then
ln -fs "$instdir/bin/phar.phar" "$shbindir/phar-$version"
fi
+# Use as main version if necessary.
+if [ "$version" = "$PHPFARM_MAIN_VERSION" ]; then
+ for prog in php php-cgi php-config phpize pear peardev pecl phar; do
+ if [ -e "$shbindir/${prog}-$version" ]; then
+ echo "Marking ${prog}-$version as the main version of $prog."
+ ln -fs "$shbindir/${prog}-$version" "$shbindir/$prog"
+ fi
+ done
+fi
+
cd "$basedir"
./pyrus.sh "$version" "$instdir"
View
@@ -37,12 +37,18 @@ for arg; do
fi
done
+main_version=
if [ $# -eq 0 ]; then
default_versions="$basedir/custom/default-versions.txt"
if [ -e "$default_versions" ]; then
while read arg; do
if [ "x$arg" != "x" -a "${arg:0:1}" != "#" ]; then
versions[${#versions[@]}]="$arg"
+
+ # The first entry in this file is the main version.
+ if [ -z "$main_version" ]; then
+ main_version="$arg"
+ fi
fi
done < "$default_versions"
fi
@@ -53,6 +59,9 @@ if [ ${#versions[@]} -eq 0 ]; then
exit 1
fi
+# Export information about the main version to subprocesses.
+PHPFARM_MAIN_VERSION="$main_version"
+export PHPFARM_MAIN_VERSION
for version in "${versions[@]}"; do
./compile.sh "$version"
done
View
@@ -55,5 +55,11 @@ chmod +x "$pyrusbin"
#symlink
ln -sf "$pyrusbin" "$instdir/../bin/pyrus-$version"
+# Use as main version if necessary.
+if [ "$version" = "$PHPFARM_MAIN_VERSION" ]; then
+ echo "Marking pyrus-$version as the main version of pyrus."
+ ln -sf "$instdir/../bin/pyrus-$version" "$instdir/../bin/pyrus"
+fi
+
echo "include_path=\".:$instdir/pear/\"" >> "$instdir/etc/php.ini"
exit 0

0 comments on commit e76871d

Please sign in to comment.