【问题标题】:How do I compile and install the source code on OpenShift?如何在 OpenShift 上编译和安装源代码?
【发布时间】:2015-05-06 15:10:22
【问题描述】:

我正在尝试在 OpenShift 上在线安装“whois”, 由于权限,我无法使用 yum 安装

\> yum install whois
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed

我不知道任何其他安装包的方法,所以考虑编译源代码。

make 可用。

\> make -version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-redhat-linux-gnu

那么如何在 OpenShift 上通过 SSH 编译源代码? 非常感谢!

编辑: 我可以make 包裹但不能install 包裹。

更新: 添加环境变量和相关数据。

$PATH

[app-domain.rhcloud.com whois-5.2.7]\> echo $PATH
/var/lib/openshift/{{ directory_hash }}/python//virtenv/bin:/var/lib/openshift/{{ directory_hash }}/python//bin:/opt/rh/python27/root/usr/bin:/bin:/usr/bin:/usr/sbin

install

[app-domain.rhcloud.com whois-5.2.7]\> which install
/var/lib/openshift/{{ directory_hash }}/python/bin/install

make install 期间的错误消息

[app-domain.rhcloud.com whois-5.2.7]\> make install BASEDIR=./destdir/
install -d ./destdir//usr/bin/
/var/lib/openshift/{{ directory_hash }}/python//bin/install: line 10: version: unbound variable
make: *** [install-whois] Error 1

make /path/to/install 期间的错误消息

[app-domain.rhcloud.com whois-5.2.7]\> make /var/lib/openshift/{{ directory_hash }}/python/bin/install BASEDIR=./destdir/
make: Nothing to be done for `/var/lib/openshift/{{ directory_hash }}/python/bin/install'.

【问题讨论】:

    标签: compilation installation makefile openshift openshift-cartridge


    【解决方案1】:

    更新: 您发布的环境$PATH 变量表明系统的install 命令可能被python 的install 命令取代。这就是为什么在尝试安装二进制文件时 make 命令失败的原因。

    你有两个解决方案。

    • 暂时从$PATH 变量中删除python 路径。下次登录OpenShift时会恢复原值:

      export PATH=/bin:/usr/bin:/usr/sbin

    • 编辑Makefile 和po/Makefile 文件并将install 命令的固定路径设置为/usr/bin/install。 Makefiles 中的行:

      INSTALL = install

      应改为:

      INSTALL = /usr/bin/install


    要解决安装到/usr 时的权限问题,您必须将whois 安装到自定义目录。此示例将其安装到 destdir 子目录。

    $ wget http://ftp.debian.org/debian/pool/main/w/whois/whois_5.2.7.tar.xz
    $ tar xf whois_5.2.7.tar.xz
    $ cd whois-5.2.7/
    $ mkdir destdir
    $ make
    $ make install BASEDIR=./destdir/
    $ ./destdir/usr/bin/whois --version
    Version 5.2.7.
    
    Report bugs to <md+whois@linux.it>.
    

    【讨论】:

    • 同样的错误,unbound variable!已尝试将 install 更改为其绝对路径,但仍然无法正常工作!
    • 你能把make install的整个输出包括错误信息发布到某个地方吗?
    • 我可以从终端使用whois 访问已安装的软件包吗?
    • whois 二进制文件安装到./destdir/usr/bin/whois。您可以从指定二进制文件的完整路径的终端运行它。您还可以将路径添加到您的 $PATH 变量并以 whois 运行它而不指定路径。看看我如何在我的答案中运行它。
    • 我曾经以同样的方式执行制作的包(使用make)!所以没有办法通过键入whois 来执行它吗?如果必须像执行 make 包一样运行包,安装的意义何在?
    【解决方案2】:

    首先你应该获取'whois'的源代码:

    wget http://ftp.debian.org/debian/pool/main/w/whois/whois_5.2.7.tar.xz
    

    那么就需要解压了:

    tar -xf whois_5.2.7.tar.xz
    

    现在你有了一个包含源代码的目录,所以最后一步是用'make'编译它。

    我认为所有这些都可以通过 OpenShift 上的 SSH 完成。

    【讨论】:

    • 我已经完成了所有的制作,可以在 shell 上运行包但无法安装。它说,unbound variable
    • 无论如何我可以在make之后安装包吗?
    • 我已经有一段时间没有手动编译一个应用程序了,但是“make”之后不就是“make install”的过程吗?我认为这是您缺少的步骤。如果我完全错了,请纠正我。
    • @Zhinkk 这就是确切的过程,但install 命令抛出unbound variable
    猜你喜欢
    • 1970-01-01
    • 2015-08-25
    • 2021-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-25
    • 1970-01-01
    相关资源
    最近更新 更多