如何在 openshift 上安装 pcre

How to install pcre on openshift

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

对于上下文,我正在尝试在 openshift 上安装我的 Yesod/haskell 应用程序,并且 运行 在 "cabal install" 期间遇到了这种 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:

好吧,我基本上回答了当前标题的问题。起点是将此文件放在 openshift 应用程序 git 存储库的 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 支持没有返回答案,我会单独询问。