aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Allen <[email protected]>2016-05-03 09:36:38 -0500
committerMark Allen <[email protected]>2016-05-03 09:36:38 -0500
commit092fc73dde5a1161112ab87db5fc64a0f9269703 (patch)
treea801059895b98e837f71342c4904cfe7d510d670
parentba8557b37a25410976d8a659f12ee65a6cdc2561 (diff)
parent46ed6c0f9fbd03cd30365458dde2b82fd46a723f (diff)
downloadkerl-092fc73dde5a1161112ab87db5fc64a0f9269703.tar.gz
kerl-092fc73dde5a1161112ab87db5fc64a0f9269703.tar.bz2
kerl-092fc73dde5a1161112ab87db5fc64a0f9269703.zip
Merge pull request #122 from kerl/git_build1.0
Support release and tarball retrieval from github
-rw-r--r--README.md160
-rwxr-xr-xkerl248
2 files changed, 271 insertions, 137 deletions
diff --git a/README.md b/README.md
index 352495f..02a809e 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Kerl aims to be shell agnostic and its only dependencies, excluding what's requi
All is done so that, once a specific release has been built, creating a new installation is as fast as possible.
Downloading
-===========
+-----------
You can download the script directly from github:
@@ -26,13 +26,18 @@ Optionally download and install kerl's zsh-completion file from https://github.c
How it works
-============
+------------
-Kerl keeps tracks of the releases it downloaded, built and installed,
-allowing easy installations to new destinations (without complete rebuilding) and easy switches between Erlang/OTP installations.
+Kerl keeps tracks of the releases it downloads, builds and installs, allowing
+easy installations to new destinations (without complete rebuilding) and easy
+switches between Erlang/OTP installations.
+
+By default, kerl downloads source tarballs from the [official Erlang website](http://www.erlang.org), but
+you can tell kerl to download tarballs of Erlang source code from the tags
+pushed to the [official source code](https://github.com/erlang/otp) by setting `KERL_BUILD_BACKEND=git`
Usage
-=====
+-----
List the available releases (kerl ignores releases < 10):
@@ -90,7 +95,9 @@ And at last activate it:
$ . /path/to/install/dir/activate
-Activation will backup your $PATH, prepend it with the installation's bin/ directory. Thus it's only valid for the current shell session, and until you activate another installation or call `kerl_deactivate`.
+Activation will backup your $PATH, prepend it with the installation's bin/
+directory. Thus it's only valid for the current shell session, and until you
+activate another installation or call `kerl_deactivate`.
You're now ready to work with your r14b02 installation:
@@ -136,7 +143,12 @@ You can easily deploy an installation to another host having `ssh` and `rsync` a
Later on, you can leave the installation typing:
kerl_deactivate
-As an experimental feature, you can build Erlang directly from a git repository with a command of the form `kerl build git <git_url> <git_version> <build_name>` where <git_version> can be either a branch, a tag or a commit id as it will be passed to `git checkout`:
+Building from a git source
+--------------------------
+
+You can build Erlang directly from a git repository with a command of the form
+`kerl build git <git_url> <git_version> <build_name>` where `<git_version>` can
+be either a branch, a tag or a commit id that will be passed to `git checkout`:
$ kerl build git https://github.com/erlang/otp.git dev r14b02_dev
Checking Erlang/OTP git repositoy from https://github.com/erlang/otp.git...
@@ -144,12 +156,13 @@ As an experimental feature, you can build Erlang directly from a git repository
Erlang/OTP r14b02_dev from git has been successfully built
Tuning
-======
+------
You can tune kerl using the .kerlrc file in your $HOME directory.
You can set the following variables:
+- `KERL_BUILD_BACKEND` which source code download provider to use - (`tarball` - default) erlang.org or github (`git`)
- `KERL_DOWNLOAD_DIR` where to put downloaded files, defaults to $HOME/.kerl/archives
- `KERL_BUILD_DIR` where to hold the builds, defaults to $HOME/.kerl/builds
- `KERL_DEFAULT_INSTALL_DIR` if set in ~/.kerlrc, install builds to this dir if no path is provided on installs, (recommend `$KERL_BASE_DIR/installs`)
@@ -157,20 +170,34 @@ You can set the following variables:
- `KERL_CONFIGURE_APPLICATIONS` if non-empty, subset of applications used in the builds (and subsequent installations) process, e.g. `kernel stdlib sasl`
- `KERL_CONFIGURE_DISABLE_APPLICATIONS` if non-empty, subset of applications disabled in the builds (and subsequent installations) process, e.g. `odbc`
- `KERL_SASL_STARTUP` use SASL system startup instead of minimal
-- `KERL_USE_AUTOCONF` use autoconf in the builds process
-- `KERL_INSTALL_MANPAGES` if non-empty will install manpages
-- `KERL_INSTALL_HTMLDOCS` if non-empty will install HTML docs
- `KERL_DEPLOY_SSH_OPTIONS` if additional options are required, e.g. `-qx -o PasswordAuthentication=no`
- `KERL_DEPLOY_RSYNC_OPTIONS` if additional options are required, e.g. `--delete`
- `KERL_ENABLE_PROMPT` if set, the prompt will be prefixed with the name of the active build
+- `KERL_BUILD_DOCS` if set, will build documentation from source code repository
+- `KERL_USE_AUTOCONF` use autoconf in the builds process (**note**: implied by the `git` build backend)
+
+### Options for tarball builds only ###
+
+These options only work when `KERL_BUILD_BACKEND=tarball` (the default) **and**
+if `KERL_BUILD_DOCS` is not set. That is, they are *strictly* for backward
+compatibility. They will probably be removed in a future release.
+
+- `KERL_INSTALL_MANPAGES` if non-empty will install manpages into `/install/path/man`
+- `KERL_INSTALL_HTMLDOCS` if non-empty will install HTML docs into `/install/path/html`
+
+If you want documentation for git based builds, set `KERL_BUILD_DOCS=yes` - and if
+you don't want to download 120MB of docs from erlang.org, also set `KERL_BUILD_DOCS=yes`
Note on .kerlrc
-===============
+---------------
-Since .kerlrc is a dot file for `/bin/sh`, running shell commands inside the .kerlrc will affect the shell and environment variables for the commands being executed later. For example, the shell `export` commands in .kerlrc will affect *your login shell environment* when activating `curl`. Use with care.
+Since .kerlrc is a dot file for `/bin/sh`, running shell commands inside the
+.kerlrc will affect the shell and environment variables for the commands being
+executed later. For example, the shell `export` commands in .kerlrc will affect
+*your login shell environment* when activating `curl`. Use with care.
Glossary
-========
+--------
Here are the abstractions kerl is handling:
@@ -181,10 +208,9 @@ Here are the abstractions kerl is handling:
- **installations**: the result of deploying builds to filesystem locations (also referred to as "sandboxes")
Commands reference
-==================
+------------------
-build
------
+### build
kerl build <release_code> <build_name>
kerl build git <git_url> <git_version> <build_name>
@@ -198,39 +224,60 @@ Creates a named build either from an official Erlang/OTP release or from a git r
##### Configure options
-You can specify the configure options to use when building Erlang/OTP with the `KERL_CONFIGURE_OPTIONS` variable, either in your $HOME/.kerlrc file or prepending it to the command line.
+You can specify the configure options to use when building Erlang/OTP with the
+`KERL_CONFIGURE_OPTIONS` variable, either in your $HOME/.kerlrc file or
+prepending it to the command line.
$ KERL_CONFIGURE_OPTIONS=--enable-hipe kerl build R14B02 r14b02_hipe
##### Configure applications
-If non-empty, you can specify the subset of applications to use when building (and subsequent installing) Erlang/OTP with the `KERL_CONFIGURE_APPLICATIONS` variable, either in your $HOME/.kerlrc file or prepending it to the command line.
+If non-empty, you can specify the subset of applications to use when building
+(and subsequent installing) Erlang/OTP with the `KERL_CONFIGURE_APPLICATIONS`
+variable, either in your $HOME/.kerlrc file or prepending it to the command
+line.
$ KERL_CONFIGURE_APPLICATIONS="kernel stdlib sasl" kerl build R15B01 r15b01_minimal
##### Configure disable applications
-If non-empty, you can specify the subset of applications to disable when building (and subsequent installing) Erlang/OTP with the `KERL_CONFIGURE_DISABLE_APPLICATIONS` variable, either in your $HOME/.kerlrc file or prepending it to the command line.
+If non-empty, you can specify the subset of applications to disable when
+building (and subsequent installing) Erlang/OTP with the
+`KERL_CONFIGURE_DISABLE_APPLICATIONS` variable, either in your $HOME/.kerlrc
+file or prepending it to the command line.
$ KERL_CONFIGURE_DISABLE_APPLICATIONS="odbc" kerl build R16B02 r16b02_no_odbc
##### Enable autoconf
-You can enable the use of `autoconf` in the build process setting `KERL_USE_AUTOCONF=yes` in your $HOME/.kerlrc file
+You can enable the use of `autoconf` in the build process setting
+`KERL_USE_AUTOCONF=yes` in your $HOME/.kerlrc file
-*Note*: `autoconf` is always enabled for git builds
+**Note**: `autoconf` is always enabled for git builds
##### Using shell export command in .kerlrc
-Configure variables which includes spaces such as those in `CFLAGS` cannot be passed on with `KERL_CONFIGURE_OPTIONS`. In such a case you can use shell `export` command to define the environment variables for `./configure`. Note well: this method has a side effect to change your shell execution environment after activating a kerl installation of Erlang/OTP. Here is an example of .kerlrc for building Erlang/OTP for FreeBSD with clang compiler:
+Configure variables which includes spaces such as those in `CFLAGS` cannot be
+passed on with `KERL_CONFIGURE_OPTIONS`. In such a case you can use shell
+`export` command to define the environment variables for `./configure`. Note
+well: this method has a side effect to change your shell execution environment
+after activating a kerl installation of Erlang/OTP. Here is an example of
+.kerlrc for building Erlang/OTP for FreeBSD with clang compiler:
# for clang
export CC=clang CXX=clang CFLAGS="-g -O3 -fstack-protector" LDFLAGS="-fstack-protector"
# compilation options
KERL_CONFIGURE_OPTIONS="--disable-native-libs --enable-vm-probes --with-dynamic-trace=dtrace --with-ssl=/usr/local --with-javac --enable-hipe --enable-kernel-poll --with-wx-config=/usr/local/bin/wxgtk2u-2.8-config --without-odbc --enable-threads --enable-sctp --enable-smp-support"
-install
--------
+#### Building documentation
+
+Prior to kerl 1.0, kerl always downloaded prepared documentation from erlang.org. Now
+if `KERL_BUILD_DOCS=yes` is set, kerl will build the man pages and HTML
+documentation from the source repository in which is working.
+
+**Note**: This variable takes precedent over the other documentation parameters.
+
+### install
kerl install <build_name> [path]
@@ -246,22 +293,35 @@ If path is omitted the current working directory will be used. However, if `KERL
##### SASL startup
-You can have SASL started automatically setting `KERL_SASL_STARTUP=yes` in your $HOME/.kerlrc file or prepending it to the command line.
+You can have SASL started automatically setting `KERL_SASL_STARTUP=yes` in your
+$HOME/.kerlrc file or prepending it to the command line.
##### Manpages installation
-You can have manpages installed automatically setting `KERL_INSTALL_MANPAGES=yes` in your $HOME/.kerlrc file or prepending it to the command line.
+You can have manpages installed automatically setting
+`KERL_INSTALL_MANPAGES=yes` in your $HOME/.kerlrc file or prepending it to the
+command line.
-*Note*: for git-based builds, kerl downloads and installs the newest official manpages which may or may not correspond to the contents of your local build.
+**Note**: for git-based builds, you want to set `KERL_BUILD_DOCS=yes`
##### HTML docs installation
-You can have HTML docs installed automatically setting `KERL_INSTALL_HTMLDOCS=yes` in your $HOME/.kerlrc file or prepending it to the command line.
+You can have HTML docs installed automatically setting
+`KERL_INSTALL_HTMLDOCS=yes` in your $HOME/.kerlrc file or prepending it to the
+command line.
-*Note*: for git-based builds, kerl downloads and installs the newest official HTML docs which may or may not correspond to the contents of your local build.
+*Note*: for git-based builds, you want to set `KERL_BUILD_DOCS=yes`
-deploy
-------
+#### Documentation installation
+
+Man pages will be installed to `[path]/man` and HTML docs will be installed in
+`[path]/html`. The kerl `activate` script manipulates the MANPATH of the current
+shell such that `man 3 gen_server` or `erl -man gen_server` should work perfectly.
+
+(Do not fret - `kerl_deactivate` restores your shell's MANPATH to whatever its
+original value was.)
+
+### deploy
kerl deploy <[user@]host> [directory] [remote_directory]
@@ -279,28 +339,33 @@ If directory and remote_directory is omitted the current working directory will
##### Additional SSH options
-You can have additional options given to `ssh` by setting them in the `KERL_DEPLOY_SSH_OPTIONS` variable in your $HOME/.kerlrc file or on the command line, e.g. `KERL_DEPLOY_SSH_OPTIONS='-qx -o PasswordAuthentication=no'`.
+You can have additional options given to `ssh` by setting them in the
+`KERL_DEPLOY_SSH_OPTIONS` variable in your $HOME/.kerlrc file or on the command
+line, e.g. `KERL_DEPLOY_SSH_OPTIONS='-qx -o PasswordAuthentication=no'`.
##### Additional RSYNC options
-You can have additional options given to `rsync` by setting them in the `KERL_DEPLOY_RSYNC_OPTIONS` variable in your $HOME/.kerlrc file or on the command line, e.g. `KERL_DEPLOY_RSYNC_OPTIONS='--delete'`.
+You can have additional options given to `rsync` by setting them in the
+`KERL_DEPLOY_RSYNC_OPTIONS` variable in your $HOME/.kerlrc file or on the
+command line, e.g. `KERL_DEPLOY_RSYNC_OPTIONS='--delete'`.
-update
-------
+### update
kerl update releases
-Fetches the up-to-date list of OTP releases from erlang.org.
+If `KERL_BUILD_BACKEND=tarball` this command fetches the up-to-date list of OTP
+releases from erlang.org.
+
+If it is set to `KERL_BUILD_BACKEND=git` this command fetches an up-to-date
+list of OTP tags from the official OTP github repository.
-list
-----
+### list
kerl list <releases|builds|installations>
Lists the releases, builds or installations available.
-delete
-------
+### delete
kerl delete build <build_name>
kerl delete installation <path>
@@ -317,8 +382,7 @@ $ kerl delete installation /srv/otp/r14b02
The installation in /srv/otp/r14b02 has been deleted
```
-active
-------
+### active
kerl active
@@ -328,8 +392,7 @@ Prints the path of the currently active installation, if any.
The current active installation is:
/srv/otp/r14b02
-status
-------
+### status
kerl status
@@ -345,3 +408,10 @@ Prints the available builds and installations as well as the currently active in
r14b02 /srv/otp/r14b02_dev
----------
No Erlang/OTP kerl installation is currently active
+
+Changelog
+---------
+2 May 2016 - 1.0
+
+ - Support builds from git tags
+ - Support documentation builds/installs from source code
diff --git a/kerl b/kerl
index 4b9833a..1af46b4 100755
--- a/kerl
+++ b/kerl
@@ -1,5 +1,6 @@
#! /bin/sh
+# Copyright (c) 2016 Mark Allen
# Copyright (c) 2011, 2012 Spawngrid, Inc
# Copyright (c) 2011 Evax Software <contact(at)evax(dot)org>
#
@@ -24,7 +25,8 @@
#Grep fix for mac pcre errors
GREP_OPTIONS=''
-ERLANG_DOWNLOAD_URL=http://www.erlang.org/download
+ERLANG_DOWNLOAD_URL="http://www.erlang.org/download"
+OTP_GITHUB_URL="https://github.com/erlang/otp"
# Default values
: ${KERL_BASE_DIR:="$HOME"/.kerl}
@@ -57,6 +59,9 @@ fi
if [ -n "$KERL_BUILD_PLT" ]; then
_KBPLT="$KERL_BUILD_PLT"
fi
+if [ -n "$KERL_BUILD_DOCS" ]; then
+ _KBD="$KERL_BUILD_DOCS"
+fi
KERL_CONFIGURE_OPTIONS=
KERL_CONFIGURE_APPLICATIONS=
KERL_CONFIGURE_DISABLE_APPLICATIONS=
@@ -65,6 +70,7 @@ KERL_DEPLOY_SSH_OPTIONS=
KERL_DEPLOY_RSYNC_OPTIONS=
KERL_INSTALL_MANPAGES=
KERL_BUILD_PLT=
+KERL_BUILD_DOCS=
# ensure the base dir exsists
mkdir -p "$KERL_BASE_DIR" || exit 1
@@ -96,6 +102,9 @@ fi
if [ -n "$_KBPLT" ]; then
KERL_BUILD_PLT="$_KBPLT"
fi
+if [ -n "$_KBD" ]; then
+ KERL_BUILD_DOCS="$_KBD"
+fi
if [ -z "$KERL_SASL_STARTUP" ]; then
INSTALL_OPT=-minimal
@@ -103,20 +112,30 @@ else
INSTALL_OPT=-sasl
fi
+if [ -z "$KERL_BUILD_BACKEND" ]; then
+ KERL_BUILD_BACKEND="tarball"
+else
+ KERL_BUILD_BACKEND="git"
+ KERL_USE_AUTOCONF=1
+fi
+
KERL_SYSTEM=$(uname -s)
case "$KERL_SYSTEM" in
Darwin|FreeBSD|OpenBSD)
MD5SUM="openssl md5"
MD5SUM_FIELD=2
SED_OPT=-E
+ CP_OPT=-a
;;
*)
MD5SUM=md5sum
MD5SUM_FIELD=1
SED_OPT=-r
+ CP_OPT=-pr
;;
esac
+
usage()
{
echo "kerl: build and install Erlang/OTP"
@@ -126,7 +145,7 @@ usage()
echo " build Build specified release or git repository"
echo " install Install the specified release at the given location"
echo " deploy Deploy the specified installation to the given host and location"
- echo " update Update the list of available releases from erlang.org"
+ echo " update Update the list of available releases from your source provider"
echo " list List releases, builds and installations"
echo " delete Delete builds and installations"
echo " active Print the path of the active installation"
@@ -141,6 +160,27 @@ if [ $# -eq 0 ]; then usage; fi
get_releases()
{
+ if [ "$KERL_BUILD_BACKEND" = "git" ]
+ then
+ echo "Getting the available releases from github.com..."
+ get_git_releases
+ else
+ echo "Getting the available releases from erlang.org..."
+ get_tarball_releases
+ fi
+}
+
+get_git_releases()
+{
+ git ls-remote --tags "$OTP_GITHUB_URL" \
+ | egrep -o 'OTP[_-][^^{}]+' \
+ | sed $SED_OPT 's/OTP[_-]//' \
+ | sort -n \
+ | uniq
+}
+
+get_tarball_releases()
+{
curl -L -s $ERLANG_DOWNLOAD_URL/ | \
sed $SED_OPT -e 's/^.*<[aA] [hH][rR][eE][fF]=\"\otp_src_([-0-9A-Za-z_.]+)\.tar\.gz\">.*$/\1/' \
-e '/^R1|^[0-9]/!d' | \
@@ -149,8 +189,13 @@ get_releases()
update_checksum_file()
{
- echo "Getting the checksum file from erlang.org..."
- curl -L $ERLANG_DOWNLOAD_URL/MD5 > "$KERL_DOWNLOAD_DIR"/MD5 || exit 1
+ if [ "$KERL_BUILD_BACKEND" = "git" ];
+ then
+ return 0
+ else
+ echo "Getting the checksum file from erlang.org..."
+ curl -L $ERLANG_DOWNLOAD_URL/MD5 > "$KERL_DOWNLOAD_DIR"/MD5 || exit 1
+ fi
}
ensure_checksum_file()
@@ -163,7 +208,6 @@ ensure_checksum_file()
check_releases()
{
if [ ! -f "$KERL_BASE_DIR"/otp_releases ]; then
- echo "Getting the available releases from erlang.org..."
get_releases > "$KERL_BASE_DIR"/otp_releases
fi
}
@@ -305,42 +349,11 @@ do_git_build()
rm -Rf "${KERL_BUILD_DIR:?}/$3"
exit 1
fi
- LOGFILE="$KERL_BUILD_DIR/$3"/otp_build.log
echo "Building Erlang/OTP $3 from git, please wait..."
- ./otp_build autoconf $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1 && \
- ./otp_build configure $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1
- if [ $? -ne 0 ]; then
- echo "Build error, see $LOGFILE"
- exit 1
+ if [ -z "$KERL_BUILD_AUTOCONF" ]; then
+ KERL_USE_AUTOCONF=1
fi
- if [ -n "$KERL_CONFIGURE_APPLICATIONS" ]; then
- find ./lib -maxdepth 1 -type d -exec touch -f {}/SKIP \;
- for i in $KERL_CONFIGURE_APPLICATIONS; do
- rm ./lib/"$i"/SKIP
- if [ $? -ne 0 ]; then
- echo "Couldn't prepare '$i' application for building"
- exit 1
- fi
- done
- fi
- if [ -n "$KERL_CONFIGURE_DISABLE_APPLICATIONS" ]; then
- for i in $KERL_CONFIGURE_DISABLE_APPLICATIONS; do
- touch -f ./lib/"$i"/SKIP
- if [ $? -ne 0 ]; then
- echo "Couldn't disable '$i' application for building"
- exit 1
- fi
- done
- fi
- ./otp_build boot -a $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1
- if [ $? -ne 0 ]; then
- echo "Build error, see $LOGFILE"
- exit 1
- fi
- rm -f "$LOGFILE"
- ./otp_build release -a "$KERL_BUILD_DIR/$3"/release_git > /dev/null 2>&1
- cd "$KERL_BUILD_DIR/$3"/release_git || exit 1
- ./Install $INSTALL_OPT "$KERL_BUILD_DIR/$3"/release_git > /dev/null 2>&1
+ _do_build "git" "$3"
echo "Erlang/OTP $3 from git has been successfully built"
list_add builds "git,$3"
}
@@ -350,7 +363,40 @@ get_otp_version()
echo $1 | sed $SED_OPT -e 's/R?([0-9]{1,2})[.AB]?[0-9]*/\1/'
}
-do_build()
+show_logfile()
+{
+ echo "$1"
+ tail "$2"
+ echo
+ echo "Please see $2 for full details."
+}
+
+do_normal_build()
+{
+ assert_valid_release "$1"
+ assert_build_name_unused "$2"
+ FILENAME=""
+ download $1
+ mkdir -p "$KERL_BUILD_DIR/$2"
+ if [ ! -d "$KERL_BUILD_DIR/$2/$FILENAME" ]; then
+ echo "Extracting source code"
+ UNTARDIRNAME="$KERL_BUILD_DIR/$2/$FILENAME-kerluntar-$$"
+ rm -rf "$UNTARDIRNAME"
+ mkdir -p "$UNTARDIRNAME"
+ # github tarballs have a directory in the form of "otp-TAGNAME"
+ # Ericsson tarballs have the classic otp_src_RELEASE pattern
+ # Standardize on Ericsson format because that's what the rest of the script expects
+ (cd "$UNTARDIRNAME" && tar xfz "$KERL_DOWNLOAD_DIR/$FILENAME.tar.gz" && mv ./* "$KERL_BUILD_DIR/$2/otp_src_$1")
+ rm -rf "$UNTARDIRNAME"
+ fi
+
+ echo "Building Erlang/OTP $1 ($2), please wait..."
+ _do_build "$1" "$2"
+ echo "Erlang/OTP $1 ($2) has been successfully built"
+ list_add builds "$1,$2"
+}
+
+_do_build()
{
case "$KERL_SYSTEM" in
Darwin)
@@ -395,39 +441,29 @@ do_build()
;;
esac
- assert_valid_release "$1"
- assert_build_name_unused "$2"
-
- FILENAME=otp_src_$1.tar.gz
- download "$FILENAME"
- mkdir -p "$KERL_BUILD_DIR/$2"
- if [ ! -d "$KERL_BUILD_DIR/$2/otp_src_$1" ]; then
- echo "Extracting source code"
- UNTARDIRNAME="$KERL_BUILD_DIR/$2/otp_src_$1-kerluntar-$$"
- rm -rf "$UNTARDIRNAME"
- mkdir -p "$UNTARDIRNAME"
- (cd "$UNTARDIRNAME" && tar xfz "$KERL_DOWNLOAD_DIR/$FILENAME" && mv ./* "$KERL_BUILD_DIR/$2/otp_src_$1")
- rm -rf "$UNTARDIRNAME"
+ if [ -n "$KERL_BUILD_DOCS" ]; then
+ KERL_CONFIGURE_OPTIONS="$KERL_CONFIGURE_OPTIONS --prefix=$KERL_BUILD_DIR/$2/release_$1"
fi
- echo "Building Erlang/OTP $1 ($2), please wait..."
+
ERL_TOP="$KERL_BUILD_DIR/$2/otp_src_$1"
cd "$ERL_TOP" || exit 1
LOGFILE="$KERL_BUILD_DIR/$2/otp_build_$1.log"
if [ -n "$KERL_USE_AUTOCONF" ]; then
./otp_build autoconf $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1 && \
- ./otp_build configure $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1
+ ./otp_build configure $KERL_CONFIGURE_OPTIONS >> "$LOGFILE" 2>&1
else
./otp_build configure $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1
fi
if [ $? -ne 0 ]; then
- echo "Build failed:"
- tail "$LOGFILE"
- echo
- echo "Please see $LOGFILE for full details."
+ show_logfile "Configure failed." "$LOGFILE"
list_remove builds "$1 $2"
exit 1
fi
+
+ # TODO: Check to see if we got any warnings from the configure
+ # step.
+
if [ -n "$KERL_CONFIGURE_APPLICATIONS" ]; then
find ./lib -maxdepth 1 -type d -exec touch -f {}/SKIP \;
for i in $KERL_CONFIGURE_APPLICATIONS; do
@@ -450,16 +486,29 @@ do_build()
fi
./otp_build boot -a $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1
if [ $? -ne 0 ]; then
- echo "Build failed, see $LOGFILE"
+ show_logfile "Build failed." "$LOGFILE"
list_remove builds "$1 $2"
exit 1
fi
+ if [ -n "$KERL_BUILD_DOCS" ]; then
+ echo "Building docs..."
+ make docs >> "$LOGFILE" 2>&1
+ if [ $? -ne 0 ]; then
+ show_logfile "Building docs failed." "$LOGFILE"
+ list_remove builds "$1 $2"
+ exit 1
+ fi
+ make install-docs >> "$LOGFILE" 2>&1
+ if [ $? -ne 0 ]; then
+ show_logfile "Installing docs failed." "$LOGFILE"
+ list_remove builds "$1 $2"
+ exit 1
+ fi
+ fi
rm -f "$LOGFILE"
ERL_TOP="$ERL_TOP" ./otp_build release -a "$KERL_BUILD_DIR/$2/release_$1" > /dev/null 2>&1
cd "$KERL_BUILD_DIR/$2/release_$1" || exit 1
./Install $INSTALL_OPT "$KERL_BUILD_DIR/$2/release_$1" > /dev/null 2>&1
- echo "Erlang/OTP $1 ($2) has been successfully built"
- list_add builds "$1,$2"
}
do_install()
@@ -526,7 +575,7 @@ export _KERL_SAVED_REBAR_PLT_DIR
_KERL_PATH_REMOVABLE="$absdir/bin"
PATH="\${_KERL_PATH_REMOVABLE}:\$PATH"
export PATH _KERL_PATH_REMOVABLE
-_KERL_MANPATH_REMOVABLE="$absdir/man"
+_KERL_MANPATH_REMOVABLE="$absdir/lib/erlang/man:$absdir/man"
MANPATH="\${_KERL_MANPATH_REMOVABLE}:\$MANPATH"
export MANPATH _KERL_MANPATH_REMOVABLE
REBAR_PLT_DIR="$absdir"
@@ -544,34 +593,31 @@ if [ -n "\$BASH" -o -n "\$ZSH_VERSION" ]; then
hash -r
fi
ACTIVATE
- if [ "$rel" != "git" ]; then
- if [ -n "$KERL_INSTALL_MANPAGES" ]; then
- echo "Fetching and installing manpages..."
- do_install_manpages "$rel"
- fi
-
- if [ -n "$KERL_INSTALL_HTMLDOCS" ]; then
- echo "Fetching and installing HTML docs..."
- do_install_htmldocs "$rel"
+ if [ -n "$KERL_BUILD_DOCS" ]; then
+ DOC_DIR="$KERL_BUILD_DIR/$1/release_$rel/lib/erlang"
+ if [ -d "$DOC_DIR" ]; then
+ echo "Installing docs..."
+ mkdir -p "$absdir/lib/erlang"
+ cp $CP_OPT "$DOC_DIR/" "$absdir/lib/erlang"
+ ln -s "$absdir/lib/erlang/man" "$absdir/man"
+ ln -s "$absdir/lib/erlang/doc" "$absdir/html"
fi
else
- rel=$(get_newest_valid_release)
- if [ $? -ne 0 ]; then
- echo "No newest valid release"
- exit 1
- fi
-
- if [ -n "$KERL_INSTALL_MANPAGES" ]; then
- echo "CAUTION: Fetching and installing newest ($rel) manpages..."
- do_install_manpages "$rel"
- fi
+ if [ "$KERL_BUILD_BACKEND" = "tarball" ]; then
+ if [ "$rel" != "git" ]; then
+ if [ -n "$KERL_INSTALL_MANPAGES" ]; then
+ echo "Fetching and installing manpages..."
+ download_manpages "$rel"
+ fi
- if [ -n "$KERL_INSTALL_HTMLDOCS" ]; then
- echo "CAUTION: Fetching and installing newest ($rel) HTML docs..."
- do_install_htmldocs "$rel"
+ if [ -n "$KERL_INSTALL_HTMLDOCS" ]; then
+ echo "Fetching and installing HTML docs..."
+ download_htmldocs "$rel"
+ fi
+ fi
fi
fi
-
+
if [ -n "$KERL_BUILD_PLT" ]; then
echo "Building Dialyzer PLT..."
build_plt "$absdir"
@@ -583,18 +629,18 @@ ACTIVATE
echo "kerl_deactivate"
}
-do_install_manpages()
+download_manpages()
{
FILENAME=otp_doc_man_$1.tar.gz
- download "$FILENAME"
+ tarball_download "$FILENAME"
echo "Extracting manpages"
cd "$absdir" && tar xfz "$KERL_DOWNLOAD_DIR/$FILENAME"
}
-do_install_htmldocs()
+download_htmldocs()
{
FILENAME="otp_doc_html_$1.tar.gz"
- download "$FILENAME"
+ tarball_download "$FILENAME"
echo "Extracting HTML docs"
(cd "$absdir" && mkdir -p html && \
tar -C "$absdir/html" -xzf "$KERL_DOWNLOAD_DIR/$FILENAME")
@@ -782,9 +828,27 @@ do_active()
download()
{
+ mkdir -p "$KERL_DOWNLOAD_DIR"
+ if [ "$KERL_BUILD_BACKEND" = "git" ]; then
+ FILENAME="OTP-$1"
+ github_download "$FILENAME.tar.gz"
+ else
+ FILENAME="otp_src_$1"
+ tarball_download "$FILENAME.tar.gz"
+ fi
+}
+
+github_download()
+{
if [ ! -f "$KERL_DOWNLOAD_DIR/$1" ]; then
echo "Downloading $1 to $KERL_DOWNLOAD_DIR"
- mkdir -p "$KERL_DOWNLOAD_DIR"
+ curl -L "$OTP_GITHUB_URL/archive/$1" > "$KERL_DOWNLOAD_DIR/$1"
+ fi
+}
+
+tarball_download()
+{
+ if [ ! -f "$KERL_DOWNLOAD_DIR/$1" ]; then
curl -L "$ERLANG_DOWNLOAD_URL/$1" > "$KERL_DOWNLOAD_DIR/$1"
update_checksum_file
fi
@@ -812,7 +876,7 @@ case "$1" in
echo "usage: $0 $1 <release> <build_name>"
exit 1
fi
- do_build "$2" "$3"
+ do_normal_build "$2" "$3"
fi
;;
install)