diff options
-rw-r--r-- | development/hhvm/README | 48 | ||||
-rw-r--r-- | development/hhvm/doinst.sh | 20 | ||||
-rw-r--r-- | development/hhvm/etc/php.ini | 1 | ||||
-rw-r--r-- | development/hhvm/etc/rc.hhvm | 160 | ||||
-rw-r--r-- | development/hhvm/etc/server.ini | 9 | ||||
-rw-r--r-- | development/hhvm/hhvm.SlackBuild | 105 | ||||
-rw-r--r-- | development/hhvm/hhvm.info | 12 | ||||
-rw-r--r-- | development/hhvm/slack-desc | 19 |
8 files changed, 374 insertions, 0 deletions
diff --git a/development/hhvm/README b/development/hhvm/README new file mode 100644 index 0000000000..4d72d13f81 --- /dev/null +++ b/development/hhvm/README @@ -0,0 +1,48 @@ +HHVM is an open-source virtual machine designed for executing +programs written in Hack and PHP. HHVM uses a just-in-time (JIT) +compilation approach to achieve superior performance while maintaining +the development flexibility that PHP provides. + +Hack is a programming language for HHVM. Hack reconciles the fast +development cycle of a dynamically typed language with the discipline +provided by static typing, while adding many features commonly found +in other modern programming languages. + +Please note that HHVM is unsupported on 32-bit OSes and there are no +current plans to ever add support. + +In order to start HHVM at boot and stop it properly at shutdown, +make sure rc.hhvm is executable and add the following lines to +the following files: + + /etc/rc.d/rc.local + ================== + # Startup HHVM + if [ -x /etc/rc.d/rc.hhvm ]; then + /etc/rc.d/rc.hhvm start + fi + + /etc/rc.d/rc.local_shutdown + =========================== + # Stop HHVM + if [ -x /etc/rc.d/rc.hhvm ]; then + /etc/rc.d/rc.hhvm stop + fi + +Default HHVM configuration uses Unix sockets. If you don't use Apache make sure that your +web server has write access to the socket file. You can create a new group and add +your web server user to this group or just use the main group of your web server and +start HHVM as following: + hhvm_GROUP=apache /etc/rc.d/rc.hhvm start + +FastCGI must be configured to communicate with HHVM. +A good start point is: https://github.com/facebook/hhvm/wiki/FastCGI + +To start a project you have to configure the type checker as well. +See the official documentation: http://docs.hhvm.com/manual/en/install.hack.bootstrapping.php +Basically you create an empty .hhconfig file in the root directory of your project: + touch .hhconfig +and run: + hh_client + +Happy Hacking! diff --git a/development/hhvm/doinst.sh b/development/hhvm/doinst.sh new file mode 100644 index 0000000000..6979f0cdcf --- /dev/null +++ b/development/hhvm/doinst.sh @@ -0,0 +1,20 @@ +config() { + NEW="$1" + OLD="`dirname $NEW`/`basename $NEW .new`" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} +# Keep same perms on rc.hhvm.new: +if [ -e etc/rc.d/rc.hhvm ]; then + cp -a etc/rc.d/rc.hhvm etc/rc.d/rc.hhvm.new.incoming + cat etc/rc.d/rc.hhvm.new > etc/rc.d/rc.hhvm.new.incoming + mv etc/rc.d/rc.hhvm.new.incoming etc/rc.d/rc.hhvm.new +fi +config etc/rc.d/rc.hhvm.new +config etc/hhvm/server.ini.new +config etc/hhvm/php.ini.new diff --git a/development/hhvm/etc/php.ini b/development/hhvm/etc/php.ini new file mode 100644 index 0000000000..5004b9fb11 --- /dev/null +++ b/development/hhvm/etc/php.ini @@ -0,0 +1 @@ +extension_dir = /usr/lib64/hhvm/extensions diff --git a/development/hhvm/etc/rc.hhvm b/development/hhvm/etc/rc.hhvm new file mode 100644 index 0000000000..1e184ae39c --- /dev/null +++ b/development/hhvm/etc/rc.hhvm @@ -0,0 +1,160 @@ +#!/bin/sh +# +### BEGIN INIT INFO +# Provides: hhvm +# Required-Start: $remote_fs $network +# Required-Stop: $remote_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Description: Starts The HHVM FastCGI Daemon +### END INIT INFO + +DAEMON=/usr/bin/hhvm +PIDFILE=/var/run/hhvm/pid +hhvm_SOCKET=/var/run/hhvm/sock +hhvm_GROUP=${hhvm_GROUP:-apache} +CONFIG_FILE="/etc/hhvm/server.ini" +SYSTEM_CONFIG_FILE="/etc/hhvm/php.ini" + +DAEMON_ARGS="--config ${SYSTEM_CONFIG_FILE} \ + --config ${CONFIG_FILE} \ + -vPidFile=${PIDFILE}" + +do_stop () { + try=0 + + if [ ! -r $2 ]; then + echo "warning, no pid file found - HHVM is not running?" + exit 1 + fi + + PID=`cat $2` + kill $1 $PID + + # Waiting for HHVM to shutdown + while test $try -lt 35 + do + if ps -p $PID | grep -q $PID + then + echo -n . + try=`expr $try + 1` + sleep 1 + else + try='' + break + fi + done + + if [ -n "$try" ] + then + echo " failed. Use force-quit" + exit 1 + else + rm -f $2 + echo " done" + fi +} + +wait_for_pid () { + try=0 + + while test $try -lt 35 + do + if [ -f "$1" ] ; then + try='' + break + fi + + echo -n . + try=`expr $try + 1` + sleep 1 + done + +} + +case "$1" in + start) + echo -n "Starting HHVM " + + if [ -r $PIDFILE ]; then + echo "warning, pid file found - HHVM is already running?" + exit 1 + fi + + echo + $DAEMON --mode daemon $DAEMON_ARGS + if [ "$?" != 0 ] + then + echo "Failed" + exit 1 + fi + + wait_for_pid $PIDFILE + + if [ -n "$try" ] ; then + echo " failed" + exit 1 + fi + + # Set the socket permissions if HHVM uses UDS + if [ -S "$hhvm_SOCKET" ] + then + chgrp $hhvm_GROUP $hhvm_SOCKET + fi + + echo " done" + ;; + + stop) + echo -n "Stopping HHVM " + + do_stop -QUIT $PIDFILE + ;; + + force-quit) + echo -n "Terminating HHVM " + + do_stop -TERM $PIDFILE + ;; + + status) + if [ ! -r $PIDFILE ] + then + echo "HHVM is stopped" + exit 0 + fi + + PID=`cat $PIDFILE` + if ps -p $PID | grep -q $PID + then + echo "HHVM (pid $PID) is running..." + else + echo "HHVM dead but pid file exists" + fi + ;; + + restart) + sh $0 stop + sh $0 start + ;; + + reload) + echo -n "Reload service HHVM " + + if [ ! -r $PIDFILE ] + then + echo "warning, no pid file found - HHVM is not running?" + exit 1 + fi + + kill -USR2 `cat $PIDFILE` + + echo " done" + ;; + + *) + echo "Usage: $0 {start|stop|status|restart|reload|force-quit}" >&2 + exit 1 + ;; + +esac diff --git a/development/hhvm/etc/server.ini b/development/hhvm/etc/server.ini new file mode 100644 index 0000000000..18f4643f3a --- /dev/null +++ b/development/hhvm/etc/server.ini @@ -0,0 +1,9 @@ +pid = /var/run/hhvm/pid + +hhvm.server.file_socket = /var/run/hhvm/sock +;hhvm.server.port = 9000 +hhvm.server.type = fastcgi +hhvm.server.default_document = index.hh +hhvm.log.use_log_file = true +hhvm.log.file = /var/log/hhvm/error.log +hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc diff --git a/development/hhvm/hhvm.SlackBuild b/development/hhvm/hhvm.SlackBuild new file mode 100644 index 0000000000..0a8cd27b08 --- /dev/null +++ b/development/hhvm/hhvm.SlackBuild @@ -0,0 +1,105 @@ +#!/bin/sh + +# Slackware build script for HHVM + +# Copyright 2015 Eugene Wissner, Dachau, Germany +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PRGNAM=hhvm +VERSION=${VERSION:-3.10.1} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +CMAKE3=cmake-3.2.3-Linux-x86_64 + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i486 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + echo "$ARCH is not supported." + exit 1 +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar Jxvf $CWD/$PRGNAM-$VERSION.tar.xz +cd $PRGNAM-$VERSION +tar zxvf $CWD/$CMAKE3.tar.gz +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +#export CMAKE_PREFIX_PATH=`pwd`/.. +./$CMAKE3/bin/cmake \ + -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS -lreadline -lncurses" \ + -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS -I/usr/kerberos/include" \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_INSTALL_LIBDIR=lib${LIBDIRSUFFIX} \ + -DENABLE_MCROUTER=true \ + -DCMAKE_BUILD_TYPE=Release . +make +make install DESTDIR=$PKG + +find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +# Compress man pages +mkdir -p $PKG/usr/man +mv hphp/doc/man $PKG/usr/man/man1 +find $PKG/usr/man -type f -exec gzip -9 {} \; + +mkdir -p $PKG/etc/{rc.d,hhvm} $PKG/usr/lib64/hhvm/extensions +install -m 644 $CWD/etc/rc.hhvm $PKG/etc/rc.d/rc.hhvm.new +install -m 644 $CWD/etc/server.ini $PKG/etc/hhvm/server.ini.new +install -m 644 $CWD/etc/php.ini $PKG/etc/hhvm/php.ini.new + +# PID +mkdir -p $PKG/var/run/hhvm + +# Copy program documentation into the package +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a hphp/doc/* $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/development/hhvm/hhvm.info b/development/hhvm/hhvm.info new file mode 100644 index 0000000000..44a7a2f8bc --- /dev/null +++ b/development/hhvm/hhvm.info @@ -0,0 +1,12 @@ +PRGNAM="hhvm" +VERSION="3.10.1" +HOMEPAGE="http://hhvm.com/" +DOWNLOAD="UNSUPPORTED" +MD5SUM="" +DOWNLOAD_x86_64="http://download.dlackware.com/hosted-sources/hhvm/hhvm-3.10.1.tar.xz \ + https://cmake.org/files/v3.2/cmake-3.2.3-Linux-x86_64.tar.gz" +MD5SUM_x86_64="16bde351dc9028e9545e944a6d8e441c \ + 82eb3cbcf74ffc5f68e8bb6f1e20271e" +REQUIRES="tbb glog ocaml dwarf oniguruma libmemcached jemalloc krb5" +MAINTAINER="Eugene Wissner" +EMAIL="belka@caraus.de" diff --git a/development/hhvm/slack-desc b/development/hhvm/slack-desc new file mode 100644 index 0000000000..d6b0c7100c --- /dev/null +++ b/development/hhvm/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +hhvm: hhvm (a virtual machine designed for executing Hack and PHP) +hhvm: +hhvm: HHVM uses a just-in-time (JIT) compilation approach to achieve +hhvm: superior performance while maintaining the development flexibility +hhvm: that PHP provides. +hhvm: +hhvm: Hack is a programming language for HHVM. +hhvm: +hhvm: +hhvm: Homepage: http://hhvm.com/ +hhvm: |