aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md31
-rwxr-xr-xkerl193
2 files changed, 153 insertions, 71 deletions
diff --git a/README.md b/README.md
index c0376ae..241a553 100644
--- a/README.md
+++ b/README.md
@@ -7,14 +7,21 @@ Kerl aims to be shell agnostic and its only dependencies, excluding what's requi
Unless explicitely disabled, agner is installed automatically in the sandboxes for supported Erlang/OTP versions.
+All 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:
$ curl -O https://github.com/evax/kerl/raw/master/kerl
+
+Then ensure its executable
+
$ chmod a+x kerl
+and drop it in your $PATH
+
How it works
============
@@ -31,11 +38,11 @@ List the available releases (kerl ignores releases < 10):
R10B-0 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
R13B R13B01 R13B02 R13B03 R13B04 R14A R14B R14B01 R14B02
- Run "./kerl update" to update this list from erlang.org
+ Run "./kerl update releases" to update this list from erlang.org
Pick your choice and build it:
- $ ./kerl build R14B02
+ $ kerl build R14B02
Downloading otp_src_R14B02.tar.gz to /home/evax/.kerl/archives
(curl progresses...)
Verifying archive checksum...
@@ -49,12 +56,12 @@ Pick your choice and build it:
You can verify it's been registered:
- $ ./kerl list builds
+ $ kerl list builds
R14B02
-Now install it to some location (optionally you can disable agner support by adding KERL_DISABLE_AGNER=yes to your $HOME/.kerlrc file):
+Now install it to some location (optionally you can disable agner support by adding KERL_DISABLE_AGNER=yes to your $HOME/.kerlrc file, or on the contrary define a list of additional packages to install using the KERL_AGNER_AUTOINSTALL directive in the same file):
- $ ./kerl install R14B02 /path/to/install/dir/
+ $ kerl install R14B02 /path/to/install/dir/
Installing Erlang/OTP R14B02 in /path/to/install/dir...
Installing agner in /path/to/install/dir...
You can activate this installation running the following command:
@@ -64,7 +71,7 @@ Now install it to some location (optionally you can disable agner support by add
Here again you can check the installation's been registered:
- $ ./kerl list installations
+ $ kerl list installations
R14B02 /path/to/install/dir
And at last activate it:
@@ -77,14 +84,14 @@ You're now ready to work with R14B02:
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.8.3
$ agner version
- 0.4.15
+ 0.4.16
You can use agner to install packages in your activated installation, they'll be directly available:
$ agner install cowboy
(...)
Installed to:
- /path/to/install/dir/lib/erlang/lib/cowboy-@master
+ /path/to/install/dir/lib/cowboy-@master
$ erl
(...)
@@ -123,6 +130,11 @@ You can delete builds and installations with the following commands:
$ kerl delete installation /path/to/install/dir
The installation in /path/to/install/dir has been deleted
+You can update the agner version associated with a specific build (this will only affect installations made after that):
+
+ $ kerl update agner R14B02
+ Updating agner for build R14B02...
+ agner has been updated successfully
Tuning
======
@@ -134,6 +146,7 @@ You can set the following variables:
- 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_CONFIGURE_OPTIONS options to pass to Erlang's ./configure script, e.g. --without-termcap
-- KERL_MAKE_OPTIONS options to pass to make, e.g. -j2
- KERL_DISABLE_AGNER if non-empty will disable agner support
- KERL_AGNER_AUTOINSTALL a list of packages to pre-install
+- KERL_SASL_STARTUP use SASL system startup instead of minimal
+
diff --git a/kerl b/kerl
index 16d5315..e68fa58 100755
--- a/kerl
+++ b/kerl
@@ -27,8 +27,8 @@ KERL_CONFIG=$HOME/.kerlrc
KERL_DOWNLOAD_DIR=$KERL_BASE_DIR/archives
KERL_BUILD_DIR=$KERL_BASE_DIR/builds
KERL_CONFIGURE_OPTIONS=
-KERL_MAKE_OPTIONS=
KERL_DISABLE_AGNER=
+KERL_SASL_STARTUP=
# ensure the base dir exsists
mkdir -p $KERL_BASE_DIR
@@ -36,14 +36,21 @@ mkdir -p $KERL_BASE_DIR
# source the config file if available
if [ -f "$KERL_CONFIG" ]; then . "$KERL_CONFIG"; fi
-usage() {
+if [ -z "$KERL_SASL_STARTUP" ]; then
+ INSTALL_OPT=-minimal
+else
+ INSTALL_OPT=-sasl
+fi
+
+usage()
+{
echo "kerl: build and install Erlang/OTP"
echo "usage: $0 <command> [options ...]"
echo "\n <command> Command to be executed\n"
echo "Valid commands are:"
echo " build Build specified release"
echo " install Install the specified release at the given location"
- echo " update Update the list of available releases from erlang.org"
+ echo " update Update agner or the list of available releases from erlang.org"
echo " list List releases, builds and installations"
echo " delete Delete builds and installations"
echo " active Print the path of the active installation"
@@ -53,24 +60,28 @@ usage() {
if [ $# -eq 0 ]; then usage; fi
-get_releases() {
+get_releases()
+{
curl -s $ERLANG_DOWNLOAD_URL/ | \
sed -e 's/^.*>otp_src_\(R1[-1234567890ABCD]\+\)\.tar\.gz<.*$/\1/' \
-e '/^R/!d'
}
-update_checksum_file() {
+update_checksum_file()
+{
echo "Getting the checksum file from erlang.org..."
curl $ERLANG_DOWNLOAD_URL/MD5 > "$KERL_DOWNLOAD_DIR/MD5" || exit 1
}
-ensure_checksum_file() {
+ensure_checksum_file()
+{
if [ ! -f "$KERL_DOWNLOAD_DIR/MD5" ]; then
update_checksum_file
fi
}
-check_releases() {
+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"
@@ -83,7 +94,8 @@ KERL_NO_AGNER_SUPPORT="R10B-0 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 R13B R13B01 R13B02 R13B03 R13B04"
-agner_support() {
+agner_support()
+{
if [ -z "$KERL_DISABLE_AGNER" ]; then
for v in $KERL_NO_AGNER_SUPPORT; do
if [ "$v" = "$1" ]; then
@@ -95,7 +107,8 @@ agner_support() {
return 1
}
-assert_valid_release() {
+assert_valid_release()
+{
check_releases
for rel in `cat $KERL_BASE_DIR/otp_releases`; do
if [ "$1" = "$rel" ]; then
@@ -106,14 +119,29 @@ assert_valid_release() {
exit 1
}
-is_valid_installation() {
+is_valid_installation()
+{
if [ -f "$1/activate" ]; then
return 0
fi
return 1
}
-do_build() {
+do_update_agner()
+{
+ assert_valid_release $1
+ TARGET=$KERL_BUILD_DIR/release_$1
+ cd "$KERL_BUILD_DIR/agner_$1" && \
+ AGNER_BIN="$TARGET/bin" AGNER_EXACT_PREFIX="$TARGET/lib" \
+ ./agner install agner > /dev/null 2>&1
+ if [ "$?" -eq 1 ]; then
+ return 1
+ fi
+ return 0
+}
+
+do_build()
+{
assert_valid_release $1
FILENAME=otp_src_$1.tar.gz
if [ ! -f "$KERL_DOWNLOAD_DIR/$FILENAME" ]; then
@@ -124,43 +152,40 @@ do_build() {
fi
ensure_checksum_file
echo "Verifying archive checksum..."
- SUM=`md5sum $KERL_DOWNLOAD_DIR/$FILENAME | cut -d " " -f 1`
- ORIG_SUM=`grep $FILENAME $KERL_DOWNLOAD_DIR/MD5 | cut -d " " -f 2`
+ SUM=`md5sum "$KERL_DOWNLOAD_DIR/$FILENAME" | cut -d " " -f 1`
+ ORIG_SUM=`grep $FILENAME "$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)"
- mkdir -p $KERL_BUILD_DIR
- mkdir -p $KERL_BASE_DIR/logs
- if [ ! -d $KERL_BUILD_DIR/otp_src_$1 ]; then
+ mkdir -p "$KERL_BUILD_DIR"
+ mkdir -p "$KERL_BASE_DIR/logs"
+ if [ ! -d "$KERL_BUILD_DIR/otp_src_$1" ]; then
echo "Extracting source code"
- cd $KERL_BUILD_DIR && tar xfz $KERL_DOWNLOAD_DIR/$FILENAME
+ cd "$KERL_BUILD_DIR" && tar xfz "$KERL_DOWNLOAD_DIR/$FILENAME"
fi
- mkdir -p "$KERL_BASE_DIR/install"
echo "Building Erlang/OTP $1, please wait..."
- cd $KERL_BUILD_DIR/otp_src_$1
- ./configure $KERL_CONFIGURE_OPTIONS --prefix="$KERL_BASE_DIR/install/$1" > \
- $KERL_BASE_DIR/logs/configure_$1.log 2>&1
+ cd "$KERL_BUILD_DIR/otp_src_$1"
+ ./otp_build setup -a $KERL_CONFIGURE_OPTIONS > "$KERL_BASE_DIR/logs/otp_build_$1.log" 2>&1
if [ "$?" -eq 1 ]; then
- echo "./configure failed, see $KERL_BASE_DIR/logs/configure_$1.log";
- exit 1
- fi
- rm -f "$KERL_BASE_DIR/logs/configure_$1.log"
- make $KERL_MAKE_OPTIONS > $KERL_BASE_DIR/logs/build_$1.log 2>&1 && \
- make install > $KERL_BASE_DIR/logs/build_$1.log 2>&1
- if [ "$?" -eq 1 ]; then
- echo "Build failed, see $KERL_BASE_DIR/logs/build_$1.log"
+ echo "Build failed, see $KERL_BASE_DIR/logs/otp_build_$1.log"
list_remove builds $2
+ exit 1
fi
- rm -f "$KERL_BASE_DIR/logs/build_$1.log"
+ rm -f "$KERL_BASE_DIR/logs/otp_build_$1.log"
+ ./otp_build release -a "$KERL_BUILD_DIR/release_$1" > /dev/null 2>&1
+ cd "$KERL_BUILD_DIR/release_$1"
+ ./Install $INSTALL_OPT "$KERL_BUILD_DIR/release_$1" > /dev/null 2>&1
echo "Erlang/OTP $1 has been successfully built"
list_add builds $1
if agner_support $1; then
echo "Fetching and building agner..."
- cd "$KERL_BASE_DIR/builds" && \
+ cd "$KERL_BUILD_DIR" && \
git clone https://github.com/agner/agner.git agner_$1 > /dev/null 2>&1 && \
- cd agner_$1 && PATH="$KERL_BASE_DIR/otp_src_$1/bin:$PATH" make > /dev/null 2>&1
+ cd agner_$1 && \
+ PATH="$KERL_BASE_DIR/otp_src_$1/bin:$PATH" make > /dev/null 2>&1 && \
+ do_update_agner $1
if [ "$?" -eq 1 ]; then
echo "Agner install failed"; exit 1
fi
@@ -168,7 +193,8 @@ do_build() {
fi
}
-do_install() {
+do_install()
+{
assert_valid_release $1
if ! list_has builds $1; then
echo "You must build the $1 realease before installing it"
@@ -182,8 +208,8 @@ do_install() {
absdir=`cd "$2" && pwd`
echo "Installing Erlang/OTP $1 in $absdir..."
cd $KERL_BUILD_DIR/otp_src_$1
- ./configure $KERL_CONFIGURE_OPTIONS --prefix="$absdir" > /dev/null 2>&1 &&
- make $KERL_MAKE_OPTIONS install > /dev/null 2>&1
+ ./otp_build release -a "$absdir" > /dev/null 2>&1 &&
+ cd "$absdir" && ./Install $INSTALL_OPT "$absdir" > /dev/null 2>&1
if [ $? -eq 1 ]; then
echo "Couldn't install Erlang/OTP $1 in $absdir"
exit 1
@@ -191,7 +217,8 @@ do_install() {
list_add installations "$1 $absdir";
cat <<ACTIVATE > "$absdir/activate"
# credits to virtualenv
-kerl_deactivate() {
+kerl_deactivate()
+{
if [ -n "\$_KERL_SAVED_PATH" ]; then
PATH="\$_KERL_SAVED_PATH"
export PATH
@@ -225,7 +252,7 @@ PATH="$absdir/bin:\$PATH"
export PATH
AGNER_BIN="$absdir/bin"
export AGNER_BIN
-AGNER_EXACT_PREFIX="$absdir/lib/erlang/lib"
+AGNER_EXACT_PREFIX="$absdir/lib"
export AGNER_EXACT_PREFIX
if [ -n "\$BASH" -o -n "\$ZSH_VERSION" ]; then
hash -r
@@ -233,27 +260,29 @@ fi
ACTIVATE
if agner_support $1; then
echo "Installing agner in $absdir..."
- . "$absdir/activate" && cd "$KERL_BASE_DIR/builds/agner_$1" && \
- ./agner install agner > /dev/null 2>&1
- if [ "$?" -eq 1 ]; then
- echo "Couldn' install agner in $absdir"
- exit 1
- fi
- if [ -n "$KERL_AGNER_AUTOINSTALL" ]; then
- for i in $KERL_AGNER_AUTOINSTALL; do
- echo "Autoinstalling $i"
- agner install $i > /dev/null 2>&1
- done
- fi
+ cp -R "$KERL_BUILD_DIR/release_$1/lib/agner-@master" "$absdir/lib/"
+ cd "$absdir/bin" && ln -s "$absdir/lib/agner-@master/bin/agner" agner
+ #. "$absdir/activate" && cd "$KERL_BASE_DIR/builds/agner_$1" && \
+ #./agner install agner > /dev/null 2>&1
+ #if [ "$?" -eq 1 ]; then
+ # echo "Couldn' install agner in $absdir"
+ # exit 1
+ #fi
+ #if [ -n "$KERL_AGNER_AUTOINSTALL" ]; then
+ # for i in $KERL_AGNER_AUTOINSTALL; do
+ # echo "Autoinstalling $i"
+ # agner install $i > /dev/null 2>&1
+ # done
+ #fi
fi
- rm -Rf "$absdir/agner_build"
echo "You can activate this installation running the following command:"
echo ". $absdir/activate"
echo "Later on, you can leave the installation typing:"
echo "kerl_deactivate"
}
-list_print() {
+list_print()
+{
if [ -f $KERL_BASE_DIR/otp_$1 ]; then
if [ -z "$2" ]; then
cat $KERL_BASE_DIR/otp_$1
@@ -265,7 +294,8 @@ list_print() {
fi
}
-list_add() {
+list_add()
+{
if [ -f $KERL_BASE_DIR/otp_$1 ]; then
grep "$2" $KERL_BASE_DIR/otp_$1 > /dev/null 2>&1 || \
echo "$2" >> $KERL_BASE_DIR/otp_$1
@@ -274,28 +304,38 @@ list_add() {
fi
}
-list_remove() {
+list_remove()
+{
if [ -f "$KERL_BASE_DIR/otp_$1" ]; then
sed -i -e "/^.*$2$/d" "$KERL_BASE_DIR/otp_$1"
fi
}
-list_has() {
+list_has()
+{
if [ -f "$KERL_BASE_DIR/otp_$1" ]; then
grep $2 "$KERL_BASE_DIR/otp_$1" > /dev/null 2>&1 && return 0
fi
return 1
}
-list_usage() {
+list_usage()
+{
echo "usage: $0 list <releases|builds|installations>"
}
-delete_usage() {
+delete_usage()
+{
echo "usage: $0 delete <build|installation> id_or_path"
}
-do_active() {
+update_usage()
+{
+ echo "usage: $0 $1 <releases|agner>"
+}
+
+do_active()
+{
if [ -n "$_KERL_SAVED_PATH" ]; then
echo "The current active installation is:"
echo `echo $PATH | cut -d ":" -f 1 | head -c -4`
@@ -326,10 +366,38 @@ case "$1" in
fi
;;
update)
- rm -f "$KERL_BASE_DIR/otp_releases"
- check_releases
- echo "The available releases are:"
- list_print releases spaces
+ if [ $# -lt 2 ]; then
+ update_usage
+ exit 1
+ fi
+ case "$2" in
+ releases)
+ rm -f "$KERL_BASE_DIR/otp_releases"
+ check_releases
+ echo "The available releases are:"
+ list_print releases spaces
+ ;;
+ agner)
+ if [ $# -ne 3 ]; then
+ echo "usage: $0 $1 $2 <build>"
+ exit 1
+ fi
+ assert_valid_release $3
+ if agner_support $3; then
+ echo "Updating agner for build $3..."
+ if do_update_agner $3; then
+ echo "agner has been updated successfully"
+ else
+ echo "failed to update agner"
+ exit 1
+ fi
+ fi
+ ;;
+ *)
+ update_usage
+ exit 1
+ ;;
+ esac
;;
list)
if [ $# -ne 2 ]; then
@@ -340,7 +408,7 @@ case "$1" in
releases)
check_releases
list_print $2 space
- echo "Run \"$0 update\" to update this list from erlang.org"
+ echo "Run \"$0 update releases\" to update this list from erlang.org"
;;
builds)
list_print $2
@@ -366,6 +434,7 @@ case "$1" in
if [ -d "$KERL_BUILD_DIR/otp_src_$3" ]; then
rm -Rf $KERL_BUILD_DIR/otp_src_$3
rm -Rf $KERL_BUILD_DIR/agner_$3
+ rm -Rf $KERL_BUILD_DIR/release_$3
list_remove $2s $3
echo "The $3 build has been deleted"
else