aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvax Software <[email protected]>2011-04-06 20:12:57 +0200
committerEvax Software <[email protected]>2011-04-06 20:12:57 +0200
commit7855b3eea8b8b9fafeb8d947e1c7a70a2e7cf4c5 (patch)
treeedea399b97839d81cc39bfa5750db6922c3db019
parent2d492ba02cc0da472f67845e166d69dbd921eb61 (diff)
downloadkerl-7855b3eea8b8b9fafeb8d947e1c7a70a2e7cf4c5.tar.gz
kerl-7855b3eea8b8b9fafeb8d947e1c7a70a2e7cf4c5.tar.bz2
kerl-7855b3eea8b8b9fafeb8d947e1c7a70a2e7cf4c5.zip
Add support for named builds
-rw-r--r--README.md43
-rwxr-xr-xkerl150
2 files changed, 121 insertions, 72 deletions
diff --git a/README.md b/README.md
index 241a553..c89cdf2 100644
--- a/README.md
+++ b/README.md
@@ -42,27 +42,39 @@ List the available releases (kerl ignores releases < 10):
Pick your choice and build it:
- $ kerl build R14B02
+ $ kerl build R14B02 r14b02
Downloading otp_src_R14B02.tar.gz to /home/evax/.kerl/archives
(curl progresses...)
Verifying archive checksum...
(curl progresses...)
Checksum verified (229fb8f193b09ac04a57a9d7794349b7)
Extracting source code
- Building Erlang/OTP R14B02, please wait...
+ Building Erlang/OTP R14B02 (r14b02), please wait...
Erlang/OTP R14B02 has been successfully built
Fetching and building agner...
Agner has been successfully built
-You can verify it's been registered:
+Note that named builds allow you to have different builds for the same Erlang/OTP release with different configure options:
+
+ $ KERL_CONFIGURE_OPTIONS=--disable-hipe kerl build R14B02 r14b02_nohipe
+ Verifying archive checksum...
+ Checksum verified (229fb8f193b09ac04a57a9d7794349b7)
+ Extracting source code
+ Building Erlang/OTP R14B02 (r14b02_nohipe), please wait...
+ Erlang/OTP R14B02 (r14b02_nohipe) has been successfully built
+ Fetching and building agner...
+ Agner has been successfully built
+
+You can verify your build has been registered:
$ kerl list builds
- R14B02
+ R14B02,r14b02
+ R14B02,r14b02_nohipe
-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):
+Now install a build 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/
- Installing Erlang/OTP R14B02 in /path/to/install/dir...
+ $ kerl install r14b02 /path/to/install/dir/
+ Installing Erlang/OTP R14B02 (r14b02) in /path/to/install/dir...
Installing agner in /path/to/install/dir...
You can activate this installation running the following command:
. /path/to/install/dir/activate
@@ -72,13 +84,13 @@ 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
- R14B02 /path/to/install/dir
+ r14b02 /path/to/install/dir
And at last activate it:
$ . /path/to/install/dir/activate
-You're now ready to work with R14B02:
+You're now ready to work with your r14b02 installation:
$ erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.8.3
@@ -113,10 +125,11 @@ You can get an overview of the current kerl state with:
$ kerl status
Available builds:
- R14B02
+ R14B02,r14b02
+ R14B02,r14b02_nohipe
----------
Available installations:
- R14B02 /path/to/install/dir
+ r14b02 /path/to/install/dir
----------
Currently active installation:
The current active installation is:
@@ -124,16 +137,16 @@ You can get an overview of the current kerl state with:
You can delete builds and installations with the following commands:
- $ kerl delete build R14B02
- The R14B02 build has been deleted
+ $ kerl delete build r14b02
+ The r14b02 build has been deleted
$ 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...
+ $ kerl update agner r14b02
+ Updating agner for build r14b02...
agner has been updated successfully
Tuning
diff --git a/kerl b/kerl
index 1ea4ad9..2004dac 100755
--- a/kerl
+++ b/kerl
@@ -26,6 +26,9 @@ KERL_BASE_DIR=$HOME/.kerl
KERL_CONFIG=$HOME/.kerlrc
KERL_DOWNLOAD_DIR=$KERL_BASE_DIR/archives
KERL_BUILD_DIR=$KERL_BASE_DIR/builds
+if [ -n "$KERL_CONFIGURE_OPTIONS" ]; then
+ _KCO="$KERL_CONFIGURE_OPTIONS"
+fi
KERL_CONFIGURE_OPTIONS=
KERL_DISABLE_AGNER=
KERL_SASL_STARTUP=
@@ -36,6 +39,10 @@ mkdir -p $KERL_BASE_DIR
# source the config file if available
if [ -f "$KERL_CONFIG" ]; then . "$KERL_CONFIG"; fi
+if [ -n "$_KCO" ]; then
+ KERL_CONFIGURE_OPTIONS="$_KCO"
+fi
+
if [ -z "$KERL_SASL_STARTUP" ]; then
INSTALL_OPT=-minimal
else
@@ -121,7 +128,8 @@ agner_support()
return 1
}
-assert_valid_release()
+
+is_valid_release()
{
check_releases
for rel in `cat $KERL_BASE_DIR/otp_releases`; do
@@ -129,8 +137,31 @@ assert_valid_release()
return 0
fi
done
- echo "$1 is not a valid Erlang/OTP release"
- exit 1
+ return 1
+}
+
+assert_valid_release()
+{
+ if ! is_valid_release $1; then
+ echo "$1 is not a valid Erlang/OTP release"
+ exit 1
+ fi
+ return 0
+}
+
+get_release_from_name()
+{
+ if [ -f "$KERL_BASE_DIR/otp_builds" ]; then
+ for l in `cat "$KERL_BASE_DIR/otp_builds"`; do
+ rel=`echo $l | cut -d "," -f 1`
+ name=`echo $l | cut -d "," -f 2`
+ if [ "$name" = "$1" ]; then
+ echo "$rel"
+ return 0
+ fi
+ done
+ fi
+ return 1
}
is_valid_installation()
@@ -143,9 +174,13 @@ is_valid_installation()
do_update_agner()
{
- assert_valid_release $1
- TARGET=$KERL_BUILD_DIR/release_$1
- cd "$KERL_BUILD_DIR/agner_$1" && \
+ rel=`get_release_from_name $1`
+ if [ "$?" -eq 1 ]; then
+ echo "Unknown build name $1"
+ exit 1
+ fi
+ TARGET="$KERL_BUILD_DIR/$1/release_$rel"
+ cd "$KERL_BUILD_DIR/$1/agner_$rel" && \
AGNER_BIN="$TARGET/bin" AGNER_EXACT_PREFIX="$TARGET/lib" \
./agner install agner > /dev/null 2>&1
if [ "$?" -eq 1 ]; then
@@ -157,6 +192,15 @@ do_update_agner()
do_build()
{
assert_valid_release $1
+ if [ -f "$KERL_BASE_DIR/otp_builds" ]; then
+ for l in `cat "$KERL_BASE_DIR/otp_builds"`; do
+ name=`echo $l | cut -d " " -f 1`
+ if [ "$name" = "$2" ]; then
+ echo "There's already a build named $2"
+ exit 1
+ fi
+ done
+ fi
FILENAME=otp_src_$1.tar.gz
if [ ! -f "$KERL_DOWNLOAD_DIR/$FILENAME" ]; then
echo "Downloading $FILENAME to $KERL_DOWNLOAD_DIR"
@@ -173,33 +217,32 @@ do_build()
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/$2"
+ if [ ! -d "$KERL_BUILD_DIR/$2/otp_src_$1" ]; then
echo "Extracting source code"
- cd "$KERL_BUILD_DIR" && tar xfz "$KERL_DOWNLOAD_DIR/$FILENAME"
+ cd "$KERL_BUILD_DIR/$2" && tar xfz "$KERL_DOWNLOAD_DIR/$FILENAME"
fi
- echo "Building Erlang/OTP $1, please wait..."
- cd "$KERL_BUILD_DIR/otp_src_$1"
- ./otp_build setup -a $KERL_CONFIGURE_OPTIONS > "$KERL_BASE_DIR/logs/otp_build_$1.log" 2>&1
+ echo "Building Erlang/OTP $1 ($2), please wait..."
+ cd "$KERL_BUILD_DIR/$2/otp_src_$1"
+ ./otp_build setup -a $KERL_CONFIGURE_OPTIONS > "$KERL_BUILD_DIR/$2/otp_build_$1.log" 2>&1
if [ "$?" -eq 1 ]; then
- echo "Build failed, see $KERL_BASE_DIR/logs/otp_build_$1.log"
- list_remove builds $2
+ echo "Build failed, see $KERL_BUILD_DIR/$2/otp_build_$1.log"
+ list_remove builds "$1 $2"
exit 1
fi
- 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
+ rm -f "$KERL_BUILD_DIR/$2/otp_build_$1.log"
+ ./otp_build release -a "$KERL_BUILD_DIR/$2/release_$1" > /dev/null 2>&1
+ cd "$KERL_BUILD_DIR/$2/release_$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"
if agner_support $1; then
echo "Fetching and building agner..."
- cd "$KERL_BUILD_DIR" && \
+ cd "$KERL_BUILD_DIR/$2" && \
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 && \
- do_update_agner $1
+ PATH="$KERL_BUILD_DIR/$2/otp_src_$1/bin:$PATH" make > /dev/null 2>&1 && \
+ do_update_agner $2
if [ "$?" -eq 1 ]; then
echo "Agner install failed"; exit 1
fi
@@ -209,9 +252,9 @@ do_build()
do_install()
{
- assert_valid_release $1
- if ! list_has builds $1; then
- echo "You must build the $1 realease before installing it"
+ rel=`get_release_from_name $1`
+ if [ "$?" -eq 1 ]; then
+ echo "No build named $1"
exit 1
fi
mkdir -p "$2"
@@ -220,12 +263,12 @@ do_install()
exit 1
fi
absdir=`cd "$2" && pwd`
- echo "Installing Erlang/OTP $1 in $absdir..."
- cd $KERL_BUILD_DIR/otp_src_$1
+ echo "Installing Erlang/OTP $rel ($1) in $absdir..."
+ cd "$KERL_BUILD_DIR/$1/otp_src_$rel"
./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"
+ echo "Couldn't install Erlang/OTP $rel ($1) in $absdir"
exit 1
fi
list_add installations "$1 $absdir";
@@ -274,20 +317,14 @@ fi
ACTIVATE
if agner_support $1; then
echo "Installing agner in $absdir..."
- cp -R "$KERL_BUILD_DIR/release_$1/lib/agner-@master" "$absdir/lib/"
+ cp -R "$KERL_BUILD_DIR/$1/release_$rel/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
+ 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
echo "You can activate this installation running the following command:"
echo ". $absdir/activate"
@@ -340,7 +377,7 @@ list_usage()
delete_usage()
{
- echo "usage: $0 delete <build|installation> id_or_path"
+ echo "usage: $0 delete <build|installation> <build_name or path>"
}
update_usage()
@@ -362,15 +399,15 @@ do_active()
case "$1" in
build)
- if [ $# -ne 2 ]; then
- echo "specify a release to install (e.g. R14B02)"
+ if [ $# -ne 3 ]; then
+ echo "usage: $0 $1 <release> <build_name>"
exit 1
fi
- do_build $2
+ do_build $2 $3
;;
install)
if [ $# -lt 2 ]; then
- echo "usage: $0 $1 <release> [directory]"
+ echo "usage: $0 $1 <build_name> [directory]"
exit 1
fi
if [ $# -eq 3 ]; then
@@ -393,10 +430,9 @@ case "$1" in
;;
agner)
if [ $# -ne 3 ]; then
- echo "usage: $0 $1 $2 <build>"
+ echo "usage: $0 $1 $2 <build_name>"
exit 1
fi
- assert_valid_release $3
if agner_support $3; then
echo "Updating agner for build $3..."
if do_update_agner $3; then
@@ -444,15 +480,15 @@ case "$1" in
fi
case "$2" in
build)
- assert_valid_release $3
- 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
+ rel=`get_release_from_name $3`
+ if [ -d "$KERL_BUILD_DIR/$3/otp_src_$rel" ]; then
+ rm -Rf $KERL_BUILD_DIR/$3/otp_src_$rel
+ rm -Rf $KERL_BUILD_DIR/$3/agner_$rel
+ rm -Rf $KERL_BUILD_DIR/$3/release_$rel
+ list_remove $2s "$rel $3"
echo "The $3 build has been deleted"
else
- echo "No build for Erlang/OTP $3"
+ echo "No build named $3"
exit 1
fi
;;