1

Any idea how to get hold of pcre (and pcre-devel) libraries on OpenShift / RHEL? I can't directly install packages via yum.

For context, I am trying to install my Yesod/haskell app on openshift, and running into trouble with this pcre dependency during "cabal install".

remote: Configuring pcre-light-0.4.0.3...
remote: cabal: Missing dependency on a foreign library:
remote: * Missing C library: pcre
remote: This problem can usually be solved by installing the system package that
remote: provides this library (you may need the "-dev" version). If the library is
remote: already installed but in a non-standard location then you can use the flags
remote: --extra-include-dirs= and --extra-lib-dirs= to specify where it is.
remote: cabal: Error: some packages failed to install:
synthcat
  • 302
  • 2
  • 15
  • 2
    The question doesn't have to do with haskell. Your actual question would be something like "How to install pcre on openshift". – zudov Apr 16 '15 at 21:41
  • Point taken, though I do see the value of context (in case another use doing what I was trying to do w/ Haskell/Yesod encountered the same thing). I have nonetheless changed the question based on the suggestion. – synthcat Apr 16 '15 at 22:16

1 Answers1

1

Well, I did essentially answer the question as currently titled. The starting point is the put this file in the pre_build hook of your openshift application's git repo (i.e., .openshift/action_hooks/pre_build).

https://gist.github.com/abn/7480593

I did have to add one line, shown below with the comment #AC

#!/bin/bash

# script to install pcre on openshift
# this can be called in your action_hooks to setup pcre
# useful if you want to use regex in uwsgi, or nginx
#
# NOTE: 
# If scaling, make sure you call this in your pre_start* hook, 
# ${OPENSHIFT_DATA_DIR} is not copied over for a new gear


PCRE_VERSION="8.33"
PCRE_NAME="pcre-${PCRE_VERSION}"
PCRE_TARBALL=${PCRE_NAME}.tar.gz
PCRE_SRC="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${PCRE_TARBALL}"

function setup_env()
{
    if [ -z $(echo $PATH | grep "$OPENSHIFT_DATA_DIR/bin") ]; then
        export PATH=$PATH:${OPENSHIFT_DATA_DIR}/bin
        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OPENSHIFT_DATA_DIR}/lib
    fi
}
function cleanup()
{
    rm -rf ${OPENSHIFT_DATA_DIR}/${PCRE_TARBALL}
    rm -rf ${OPENSHIFT_DATA_DIR}/${PCRE_NAME}
}

function install_pcre()
{
    cd ${OPENSHIFT_DATA_DIR} #AC
    wget ${PCRE_SRC}
    tar xvf ${PCRE_TARBALL}
    cd ${PCRE_NAME}
    ./configure --prefix=${OPENSHIFT_DATA_DIR}
    make
    make install
}

if [ ! -f "$OPENSHIFT_DATA_DIR/bin/pcre-config" ]; then
    install_pcre
    setup_env
    cleanup
fi

So now pcre is successfully installed on my openshift gear. Mission accomplished! Well, mostly. There is still a separate problem with library paths, but I will ask that separately if RedHat/OpenShift support doesn't come back with an answer.

synthcat
  • 302
  • 2
  • 15