获取kerl脚本:
curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl; chmod a+x kerl
执行kerl可以看到以下信息:
[root@dev03v src]# ./kerl
kerl: build and install Erlang/OTP
usage: ./kerl <command> [options ...]
<command> Command to be executed
Valid commands are:
build Build specified release or git repository
install Install the specified release at the given location
deploy Deploy the specified installation to the given host and location
update Update the list of available releases from your source provider
list List releases, builds and installations
delete Delete builds and installations
active Print the path of the active installation
plt Print Dialyzer PLT path for the active installation
status Print available builds and installations
prompt Print a string suitable for insertion in prompt
cleanup Remove compilation artifacts (use after installation)
version Print current version (current: 1.3.4)
执行kerl list releases查看可用发行版本:
[root@dev03v src]# ./kerl list releases
R10B-0 R10B-10 R10B-1a R10B-2 R10B-3 R10B-4 R10B-5 R10B-6 R10B-7 R10B-8 R10B-9 R11B-0 R11B-1 R11B-2 R11B-3 R11B-4 R11B-5 R12B-0 R12B-1 R12B-2
R12B-3 R12B-4 R12B-5 R13A R13B01 R13B02-1 R13B02 R13B03 R13B04 R13B R14A R14B01 R14B02 R14B03 R14B04 R14B_erts-5.8.1.1 R14B R15B01 R15B02
R15B02_with_MSVCR100_installer_fix R15B03-1 R15B03 R15B R16A_RELEASE_CANDIDATE R16B01 R16B02 R16B03-1 R16B03 R16B 17.0-rc1 17.0-rc2 17.0 17.1
17.3 17.4 17.5 18.0 18.1 18.2.1 18.2 18.3 19.0 19.1 19.2
Run './kerl update releases' to update this list from erlang.org
然后执行kerl build {release} {build_name}来构建:
[root@dev03v erlang_deploy]# ./kerl build 19.2 erl_19.2
Getting checksum file from erlang.org...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 178 100 178 0 0 91 0 0:00:01 0:00:01 --:--:-- 91
100 26291 100 26291 0 0 4753 0 0:00:05 0:00:05 --:--:-- 7613
Verifying archive checksum...
Checksum verified (7cdd18a826dd7bda0ca46d1c3b2efca6)
/root/.kerl/builds/erl_19.2/otp_src_19.2
Extracting source code
Building Erlang/OTP 19.2 (erl_19.2), please wait...
APPLICATIONS DISABLED (See: /root/.kerl/builds/erl_19.2/otp_build_19.2.log)
* jinterface : No Java compiler found
* odbc : ODBC library - link check failed
APPLICATIONS INFORMATION (See: /root/.kerl/builds/erl_19.2/otp_build_19.2.log)
* wx : wxWidgets not found, wx will NOT be usable
DOCUMENTATION INFORMATION (See: /root/.kerl/builds/erl_19.2/otp_build_19.2.log)
* documentation :
* fop is missing.
* Using fakefop to generate placeholder PDF files.
Erlang/OTP 19.2 (erl_19.2) has been successfully built
如果下载速度太慢,可以将其他方式下载好的 otp_src_{version}.tar.gz 放在 /root/.kerl/archives/ 目录(目录不存在的话需要手动创建).
然后按照下面的代码注释掉kerl内部的 tarball_download() 函数中下载的几行逻辑,就可以跳过下载过程进行build了.
同理如果不需要检测checksum,下面的checksum检测逻辑也可以注释掉(因为获取checksum也有网络通信).
tarball_download() { # if [ ! -s "$KERL_DOWNLOAD_DIR/$1" ]; then # echo "Downloading $1 to $KERL_DOWNLOAD_DIR" # curl -f -L -o "$KERL_DOWNLOAD_DIR/$1" "$ERLANG_DOWNLOAD_URL/$1" || exit 1 # update_checksum_file # fi ensure_checksum_file echo "Verifying archive checksum..." SUM="$($MD5SUM "$KERL_DOWNLOAD_DIR/$1" | cut -d ' ' -f $MD5SUM_FIELD)" ORIG_SUM="$(grep -F "$1" "$KERL_DOWNLOAD_DIR"/MD5 | cut -d ' ' -f 2)" if [ "$SUM" != "$ORIG_SUM" ]; then echo "Checksum error, check the files in $KERL_DOWNLOAD_DIR" exit 1 fi echo "Checksum verified ($SUM)" }
可以看到虽然build成功,但是缺乏某些依赖导致某些功能不能使用.
如果需要这些功能还需要安装jdk, odbc, wx, fop.
jdk: jdk可以选择openjdk或者oracle jdk等. 这里不再赘述.
wx: wx的问题比较复杂. wxwidgets 需要手动安装, yum epel提供的wxwidgets由于没有开启enable-debug而导致不能用,因此需要手动安装.
下载地址在 http://www.wxwidgets.org/downloads/
wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.2/wxWidgets-3.0.2.tar.bz2
bzip2 -d wxWidgets-3.0.2.tar.bz2
tar -xvf wxWidgets-3.0.2.tar.bz2
cd wxWidgets-3.0.2
yum install gtk+* mesa* freeglut freeglut*
./configure --with-opengl --enable-debug --enable-unicode
make -j
make install
export LD_LIBRARY_PATH=/usr/local/lib
ldconfig
configure 的时候--with-opengl --enable-debug --enable-unicode是必须的,opengl是驱动,另外两个是必须的feature.
如果不开启的话,还会提示wxWidgets not found或者Can not link the wx driver.
如果仍然失败,需要产看日志寻找解决方法:
cat /root/.kerl/builds/erl_19.2/otp_src_19.2/lib/wx/config.log
...
configure:5308: checking for debug build of wxWidgets
configure:5342: checking for wx-config
configure:5361: found /usr/local/bin/wx-config
configure:5374: result: /usr/local/bin/wx-config
configure:5391: checking for wxWidgets version >= 2.8.4 (--unicode --debug=yes)
configure:5503: result: no
configure:5584: checking for standard build of wxWidgets
configure:5617: checking for wx-config
configure:5649: result: /usr/local/bin/wx-config
configure:5666: checking for wxWidgets version >= 2.8.4 (--unicode --debug=no)
configure:5778: result: no
configure:5908: WARNING:
wxWidgets must be installed on your system.
Please check that wx-config is in path, the directory
where wxWidgets libraries are installed (returned by
'wx-config --libs' or 'wx-config --static --libs' command)
is in LD_LIBRARY_PATH or equivalent variable and
wxWidgets version is 2.8.4 or above.
...
剩下的直接利用yum 安装:
yum install unixODBC-devel fop
(顺便吐个槽为啥wxWidgets依赖需要SDL...)
然后重新build.
以上.