Skip to content
gitricko edited this page Oct 12, 2016 · 10 revisions

This is a custom buildpack for Cloud Foundry forking from https://github.com/cloudfoundry/python-buildpack. It adds installation of pdf2htmlEx and ghostscript. For pdf2htmlEx, refer to https://github.com/LeoKotschenreuther/python-pdf2htmlEX-buildpack/wiki. For ghostscript, following these steps:

  • Use Docker to make a container with Ubuntu 14.04 system which is the same as Cloud Foundry.

  • Install ghostscript in the Ubuntu docker container. Don't run 'sudo apt-get install ghostscript', you'll only get older version, which is 9.10 as of now. Download the newer version of ghostscript source from http://www.ghostscript.com/download/gsdnld.html. In current example, we use 9.19 version ghostscript-9.19.tar.gz. Unzip the file and run the following command to install it to a custom directory.

    ./configure --prefix=$OUTPUT_DIR

    make

    make install

  • Package the Ghostscript output directory into a tar.gz file and put it into the top level directory of the buildpack. The package has gs executable file under folder bin, and libraries under share/ghostscript/9.19/lib.

  • In buildpack, under folder bin/steps, create a file ghostscript which unpack the tar.gz file into our installation directory.

     mkdir -p $INSTALL_DIR
    
     tar -zxvf $ROOT_DIR/$GS_TGZ -C $INSTALL_DIR
    

Then set the environment for running ghostscript by creating a gs.sh under ./profile/.d.

ENVSCRIPT=$BUILD_DIR/.profile.d/gs.sh

echo "export PATH=\"$INSTALL_DIR/gs/bin:\$PATH\"" > $ENVSCRIPT

echo "export GS_LIB=\"$INSTALL_DIR/gs/share/ghostscript/$GS_VERSION/lib\"" >> $ENVSCRIPT

echo "export LD_LIBRARY_PATH=\"$INSTALL_DIR/gs/share/ghostscript/$GS_VERSION/lib:\$LD_LIBRARY_PATH\"" >> $ENVSCRIPT
  • Add the calling of your ghostscript file in 'compile' file under bin folder.

Clone this wiki locally