如何在openshift上安装pcre

时间:2015-04-16 21:37:56

标签: openshift redhat pcre yesod

知道如何在OpenShift / RHEL上获取pcre(和pcre-devel)库吗?我不能通过yum直接安装包。

对于上下文,我正在尝试在openshift上安装我的Yesod / haskell应用程序,并在“cabal安装”期间遇到与此pcre依赖关系的问题。

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:

1 个答案:

答案 0 :(得分:1)

好吧,我基本上回答了目前标题为的问题。起点是将此文件放在openshift应用程序的git repo的pre_build钩子中(即.openshift / action_hooks / pre_build)。

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

我确实需要添加一行,如下所示,注释#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

所以现在pcre已成功安装在我的openshift装备上。任务完成!好吧,主要是。库路径还有一个单独的问题,但如果RedHat / OpenShift支持没有回复,我会单独询问。