Initial commit.
authorEdward Z. Yang <edwardzyang@thewritingpot.com>
Mon, 16 Feb 2009 08:22:58 +0000 (16 03:22 -0500)
committerEdward Z. Yang <edwardzyang@thewritingpot.com>
Mon, 16 Feb 2009 08:22:58 +0000 (16 03:22 -0500)
Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
.gitignore [new file with mode: 0644]
bin/phpv [new file with mode: 0755]
fix-cgi.sh [new file with mode: 0755]
get-url.php [new file with mode: 0644]
install.sh [new file with mode: 0755]
update-all-dev.sh [new file with mode: 0755]
update-dev.sh [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..5eaab81
--- /dev/null
@@ -0,0 +1,2 @@
+versions
+working
diff --git a/bin/phpv b/bin/phpv
new file mode 100755 (executable)
index 0000000..fa8cf42
--- /dev/null
+++ b/bin/phpv
@@ -0,0 +1,9 @@
+#!/bin/bash
+VERSION="$1"
+if [ "$VERSION" = "" ]
+then
+    echo "Usage: phpv version ..."
+    exit
+fi
+shift 1
+"/home/ezyang/Dev/php/versions/$VERSION/bin/php" $@
diff --git a/fix-cgi.sh b/fix-cgi.sh
new file mode 100755 (executable)
index 0000000..ac0620c
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+set -e
+VERSION="$1"
+BIN="versions/$VERSION/bin"
+mv "$BIN/php" "$BIN/php-cgi"
+mv "working/php-$VERSION/sapi/cli/php" "$BIN/php"
+versions/$VERSION/bin/php --version
diff --git a/get-url.php b/get-url.php
new file mode 100644 (file)
index 0000000..a4ef335
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/env php
+<?php
+
+function extract_links($url) {
+    $doc = new DOMDocument();
+    @$doc->loadHTMLFile($url);
+    $xpath = new DOMXPath($doc);
+    return $xpath->query('//a');
+}
+
+if (!isset($_SERVER['argv'][1])) {
+    echo <<<EOF
+Usage: php get-url.php version
+
+EOF;
+    exit(1);
+}
+$install_version = $_SERVER['argv'][1];
+
+$url_mirror = 'http://us2.php.net';
+$url_releases = $url_mirror . '/releases/';
+$url_downloads = $url_mirror . '/downloads.php';
+
+$link_sets = array(extract_links($url_releases), extract_links($url_downloads));
+$index = array();
+
+foreach ($link_sets as $links) {
+    foreach ($links as $link) {
+        $url = $link->getAttribute('href');
+        if (!$url) continue;
+        $result = preg_match('#/php-([^-]+?)\.tar\.gz#', $url, $matches);
+        if (!$result) continue;
+        list($full, $version) = $matches;
+        $url = str_replace('/from/a/mirror', '/from/this/mirror', $url); // make download ready
+        if ($url[0] == '/') $url = $url_mirror . $url; // heuristic assumes absolute paths are used
+        $index[$version] = $url;
+    }
+}
+
+// maybe add qa support
+
+if (!isset($index[$install_version])) {
+    fwrite(STDERR, "Could not find $install_version\n");
+    exit(1);
+}
+
+echo $index[$install_version];
+
diff --git a/install.sh b/install.sh
new file mode 100755 (executable)
index 0000000..42dfd5e
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+set -e
+VERSION="$1"
+URL=$(php get-url.php "$VERSION")
+mkdir "versions/$VERSION"
+cd working
+wget $URL -O "php-$VERSION.tar.gz"
+tar xzf "php-$VERSION.tar.gz"
+cd "php-$VERSION"
+./configure --prefix=/home/ezyang/Dev/php/versions/$VERSION
+make
+make install
+../../versions/$VERSION/bin/php --version
+
diff --git a/update-all-dev.sh b/update-all-dev.sh
new file mode 100755 (executable)
index 0000000..df2eaa3
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+./update-dev.sh 5.2
+./update-dev.sh 5.3
+./update-dev.sh 6.0
diff --git a/update-dev.sh b/update-dev.sh
new file mode 100755 (executable)
index 0000000..a2b5276
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+set -e
+cd "working/$1"
+cvs up
+./config.nice
+make
+make install