Skip to content

Build Packages for Debian

Paul Tarjan edited this page May 15, 2013 · 1 revision

This is a work in progress!

Please follow the instructions on https://github.com/facebook/hiphop-php/wiki/Building-and-installing-HHVM-on-Debian-6 , but skip the "cmake" and "make" part. Credits go primarily to Mark A. Hershberger.

Go to your hiphop-php directory:

cd ~/dev/hiphop-php
mkdir debian

Edit debian/control:

Source: hiphop-php
Section: unknown
Priority: extra
Maintainer: Your Name <[email protected]>
Build-Depends: debhelper (>= 7), cmake
Standards-Version: 3.8.1
Homepage: http://github.com/facebook/hiphop-php

Package: hiphop-php
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, mcrypt
Description: the php to c++ compiler
 experimental debian packaging

Edit debian/changelog:

hiphop-php (0.1-1) unstable; urgency=low

  * Initial package

 -- Your Name <[email protected]>  Tue, 1 Jan 2013 0:0:0 +010

Edit debian/hiphop-php.install:

hphp/hhvm/hhvm                          usr/bin/
bin/systemlib.php                       usr/bin/
hphp/doc/mime.hdf                       usr/share/hiphop-php/hdf/
../lib/libevent_core-1.4.so.2           usr/hiphop-php/lib/
../lib/libglog.so.0.0.0                 usr/hiphop-php/lib/
../lib/libevent_core.so                 usr/hiphop-php/lib/
../lib/libcurl.a                        usr/hiphop-php/lib/
../lib/libevent_core-1.4.so.2.2.0       usr/hiphop-php/lib/
../lib/libevent_extra-1.4.so.2.2.0      usr/hiphop-php/lib/
../lib/pkgconfig                        usr/hiphop-php/lib/
../lib/pkgconfig/libglog.pc             usr/hiphop-php/lib/
../lib/pkgconfig/libcurl.pc             usr/hiphop-php/lib/
../lib/libevent_extra.la                usr/hiphop-php/lib/
../lib/libcurl.la                       usr/hiphop-php/lib/
../lib/libevent_core.a                  usr/hiphop-php/lib/
../lib/libjemalloc.so.1                 usr/hiphop-php/lib/
../lib/libcurl.so.4.3.0                 usr/hiphop-php/lib/
../lib/libjemalloc.a                    usr/hiphop-php/lib/
../lib/libcurl.so                       usr/hiphop-php/lib/
../lib/libglog.so.0                     usr/hiphop-php/lib/
../lib/libcurl.so.4                     usr/hiphop-php/lib/
../lib/libglog.la                       usr/hiphop-php/lib/
../lib/libglog.a                        usr/hiphop-php/lib/
../lib/libevent-1.4.so.2                usr/hiphop-php/lib/
../lib/libglog.so                       usr/hiphop-php/lib/
../lib/libevent_core.la                 usr/hiphop-php/lib/
../lib/libevent_extra.a                 usr/hiphop-php/lib/
../lib/libevent.a                       usr/hiphop-php/lib/
../lib/libevent_extra.so                usr/hiphop-php/lib/
../lib/libjemalloc_pic.a                usr/hiphop-php/lib/
../lib/libevent_extra-1.4.so.2          usr/hiphop-php/lib/
../lib/libevent.la                      usr/hiphop-php/lib/
../lib/libevent-1.4.so.2.2.0            usr/hiphop-php/lib/
../lib/libjemalloc.so                   usr/hiphop-php/lib/
../lib/libevent.so                      usr/hiphop-php/lib/

Warning: the following script does not clean hiphop-php! Edit debian/rules:

#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

export HPHP_HOME=$(CURDIR)
export HPHP_LIB=${HPHP_HOME}/bin
export USE_HHVM=1
export CMAKE_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu
export MYCMAKEOPTIONS=-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS="$(CFLAGS)" -DCMAKE_LD_FLAGS="-Wl,-z,defs" -DCMAKE_CXX_FLAGS="$(CXXFLAGS)" -DCMAKE_SKIP_RPATH=ON -DCMAKE_VERBOSE_MAKEFILE=ON

# These are locations of quilt stuff
#export QUILT_PATCHES=$(shell pwd)/debian/patches

BUILDDIR=$(CURDIR)/builddir

#Architecture
build:
        dh_testdir

#       -quilt push -a
        mkdir -p $(BUILDDIR)
#       cmake -DHPHP_HOME=$(CURDIR)   -DCMAKE_PROJECT_BINARY_DIR=$(CURDIR)/builddir -DPROJECT_BINARY_DIR=$(CURDIR)/builddir -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS="$(CFLAGS)" -DCMAKE_LD_FLAGS="-Wl,-z,defs" $
        echo "cmake $(MYCMAKEOPTIONS) .. "> ${BUILDDIR}/runbuild.sh
        cd $(BUILDDIR) && sh runbuild.sh
        touch $@


clean:
        dh_testdir
        dh_testroot
        rm -f build-arch-stamp build-indep-stamp

        rm -rf $(BUILDDIR)
#       -quilt pop -a
#       make clean

        dh_clean  --exclude ./src/third_party/timelib/parse_date.c.orig

install: install-indep install-arch
install-indep:
        dh_testdir
        dh_testroot
        dh_prep -i  --exclude ./src/third_party/timelib/parse_date.c.orig
        dh_installdirs -i
        dh_install -i

install-arch:
        dh_testdir
        dh_testroot
        dh_prep -s  --exclude ./src/third_party/timelib/parse_date.c.orig
        dh_installdirs -s

        $(MAKE) DESTDIR=$(CURDIR)/debian/hiphop-php install

        dh_install -s

# Must not depend on anything. This is to be called by
# binary-arch/binary-indep
# in another 'make' thread.
binary-common:
        dh_testdir
        dh_testroot
        dh_installchangelogs
        dh_installdocs
        dh_installexamples
        dh_installman
        dh_link
        dh_strip
        dh_compress
        dh_fixperms
        dh_makeshlibs
        dh_installdeb
        dh_gencontrol
        dh_md5sums
        dh_builddeb

# Build architecture independant packages using the common target.
binary-indep: build install
        $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common

# Build architecture dependant packages using the common target.
binary-arch: build install
        dh_install --sourcedir=.
        dh_install hphp/hhvm/hhvm usr/bin
        $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common

binary: binary-arch binary-indep

.PHONY: build clean binary-indep binary-arch binary install install-indep install-arch

Edit debian/hiphop-php.dirs:

usr/hiphop-php
usr/hiphop-php/lib
usr/hiphop-php/lib/pkgconfig
usr/share/hiphop-php
usr/share/hiphop-php/hdf

Now run the following to create binary packages:

dpkg-buildpackage -b
Clone this wiki locally