Erlang

From GeilThings

Jump to: navigation, search
Erlang
General
Version R16B01
Stable R16B01
Function Programming Language
Scripts


Contents


General

erl
erlang:system_info(otp_release).
erl -noshell -eval 'io:fwrite("Hello, World!\n"), init:stop().'
  • Version:
erl -noshell -eval 'io:fwrite(erlang:system_info(otp_release) ++ "\n"), init:stop().'

Installation

# Install requirements.
# A list can be found under http://www.erlang.org/doc/installation_guide/INSTALL.html#Required-Utilities
 
# sed (Text parsing utility, http://en.wikipedia.org/wiki/Sed) and 
# xsltproc (xslt library, http://en.wikipedia.org/wiki/Libxslt) were already installed.
 
# fop: Application to convert certain files to PDF or other formats.
# http://en.wikipedia.org/wiki/Formatting_Objects_Processor, http://xmlgraphics.apache.org/fop/
cd /opt
wget http://apache.mirror.clusters.cc/xmlgraphics/fop/binaries/fop-1.0-bin.tar.gz
tar -zxvf fop-1.0-bin.tar.gz
cd /usr/bin
ln -s /opt/fop-1.0/fop
# fop needs JAVA_HOME to be set.
 
# CentOS 6.2:
# NOT SOLVED: Message:
# APPLICATIONS INFORMATION 
# wx             : wxWidgets not found, wx will NOT be usable
# yum install wxGTK wxGTK-gl did not help
 
cd /opt
wget http://www.erlang.org/download/otp_src_R14B03.tar.gz
tar -zxvf otp_src_R14B03.tar.gz
cd otp_src_R14B03
./configure
make
make install

Warnings installing Erlang

1. After ./configure: APPLICATIONS DISABLED - odbc : ODBC library - link check failed

Solution: Install unixODBC-devel
yum install unixODBC-devel
 
# Test it:
odbcinst -j
 
# The odbc warning appeared again after moving from CentOS 5.6 to CentOS 5.7; reinstalling it removed the warning.
yum erase unixODBC-devel
yum install unixODBC-devel

2. After ./configure: APPLICATIONS INFORMATION - wx : wxWidgets not found, wx will NOT be usable

No solution needed; I left the warning as it is since wxWidgets is used only for development of GUIs (http://en.wikipedia.org/wiki/WxWidgets).

Upgrade Erlang

  • CentOS 6.2: Valid for R15B to R15B01 to R15B02
  • CentOS 5.6: Valid for R14B03 to R14B04 to R15B.
  1. Stop applications running under Erlang.
  2. Rename Erlang directory.
  3. Install the new Erlang version.
  4. Restart and test applications running under Erlang (Yaws and CouchDB).
# Variables
APPNAME=erlang
 
# Determine current Erlang version.
OLDVERSION=`erl -noshell -eval 'io:fwrite(erlang:system_info(otp_release) ++ "\n"), init:stop().'`
# Check.
echo $OLDVERSION
 
RAWNEWVERSION=`curl -sd "action=ask&query=[[Erlang]]|%3FStable&format=json" http://www.geilthings.com/api.php` 
# Get Version as Substring.  
# Using grep to sed to extract STRING between first occurrence of MATCH1 and next occurrence of MATCH2:  
# http://stackoverflow.com/questions/4392106/sed-extract-string-between-first-occurrence-of-match1-and-next-occurrence-of-m  
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`  
echo $NEWVERSION
 
if [[ ${OLDVERSION} != ${NEWVERSION} ]]; then
  echo ${APPNAME}: installed: ${OLDVERSION}, actual: ${NEWVERSION}
  echo "You could update ${APPNAME} to ${NEWVERSION}"
  echo "Would you like to install ${APPNAME} ${NEWVERSION} y/n?"
  read item
  if [[ "$item" == "y" || "$item" == "Y" ]]; then
    echo "Installing ${APPNAME} ${NEWVERSION}. Follow instructions."
  else
    echo "Exit"
  fi
else
  echo "You don't need to update ${APPNAME}; it is uptodate (${NEWVERSION})"
fi
 
DATE=`date +%Y-%m-%d`
 
# Stop applications running under Erlang (Yaws and CouchDB).
/etc/init.d/yaws stop
su - couchdb -c "/usr/local/etc/rc.d/couchdb stop"
 
# Rename Erlang directory.
mv /usr/local/lib/erlang /opt/old_erlang-${OLDVERSION}-${DATE}
 
# Install the new Erlang version.
cd /opt
wget http://www.erlang.org/download/otp_src_${NEWVERSION}.tar.gz
tar -zxvf otp_src_${NEWVERSION}.tar.gz
# This below did not work for R15B03-1, the directory name was still otp_src_R15B03
cd otp_src_${NEWVERSION}
 
./configure
make
make install clean
 
# Check that erlang runs and it is the proper version.
CHECKNEWVERSION=`erl -noshell -eval 'io:fwrite(erlang:system_info(otp_release) ++ "\n"), init:stop().'`
 
if [[ "$CHECKNEWVERSION" == "$NEWVERSION" ]]; then
  echo "The version ${CHECKNEWVERSION} is currently installed."
else
  echo "ERROR: The ${CHECKNEWVERSION} is currently installed and it is different from the expected ${NEWVERSION}."
fi
 
# Start and test applications running under Erlang (Yaws and CouchDB).
/etc/init.d/yaws start
# Check.
ps aux | grep yaws
su - couchdb -c "/usr/local/etc/rc.d/couchdb start"
# Check.
ps aux | grep couchdb
 
# yaws 1.91 breaks under Erlang R15B.
# e.g. see http://groups.google.com/group/erlang-programming/browse_thread/thread/9bcd23ed628ef5e6/7c6af3562dc7cbe0?show_docid=7c6af3562dc7cbe0
 
# Test applications.
# ...
 
# Remove the old Erlang directory some time later.
# rm -rf old_erlang ...

Versions

Software name Version number Version date
Erlang R15B03
R15B03-1
R16A
R16B
R16B01
1 December 2012
8 December 2012
31 January 2013
28 February 2013
22 June 2013

Comments

blog comments powered by Disqus