summaryrefslogtreecommitdiff
path: root/otp_build
diff options
context:
space:
mode:
authorSiri Hansen <siri@erlang.org>2014-01-27 14:18:49 +0100
committerSiri Hansen <siri@erlang.org>2014-02-13 08:47:51 +0100
commit656f0386d5604bdcfe5f9d7477ef55773d4ecb71 (patch)
tree40c8651db2adcbb43cd77bb286d073808640779b /otp_build
parent5d2bacd788c7cd95b079fc152599cf26c1ddd51c (diff)
downloaderlang-656f0386d5604bdcfe5f9d7477ef55773d4ecb71.tar.gz
Add patch_app option to otp_build
Diffstat (limited to 'otp_build')
-rwxr-xr-xotp_build127
1 files changed, 126 insertions, 1 deletions
diff --git a/otp_build b/otp_build
index 945027f0ed..f5a7a0be44 100755
--- a/otp_build
+++ b/otp_build
@@ -2,7 +2,7 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2002-2012. All Rights Reserved.
+# Copyright Ericsson AB 2002-2014. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
@@ -52,6 +52,9 @@ usage ()
echo " release [-a] <target_dir> - creates full release to <target_dir>"
echo " smp [-a] - build an Erlang system, smp flavor only"
echo " tests <dir> - Build testsuites to <dir>"
+ echo " patch_app <target_dir> <app1>... - build given apps to <target_dir>"
+ echo " If core apps are patched, new start scripts will be created"
+ echo " and 'Install' must be run again."
echo ""
echo "These are for cleaning up an open source distribution"
echo "with prebuilt files, so that it resembles the clean developers"
@@ -1191,6 +1194,125 @@ do_release ()
release || exit 1
}
+do_patch_app ()
+{
+ # If target dir exists and has an installation of same major release, then
+ # build given apps.
+ # If patch includes erts, kernel, stdlib, sasl, then find latest
+ # erts, kernel, stdlib, sasl and create .rel files.
+ # Create .script/.boot
+
+ if [ $# -lt 2 ]; then
+ usage
+ exit 1
+ fi
+
+ setup_make
+ if [ X`$MAKE is_cross_configured` = Xyes ]; then
+ TARGET=`$MAKE target_configured`
+ fi
+ target_dir=$1
+ if [ ! -d $target_dir/releases/$otp_major_vsn ]; then
+ echo "No OTP $otp_major_vsn installation in $target_dir" 1>&2
+ exit 1
+ fi
+ shift
+
+ # Build all applications to target
+ for app in "$@"; do
+ if [ "$app" = "erts" ] && [ -d $ERL_TOP/$app ]; then
+ (cd $ERL_TOP/$app && $MAKE MAKE="$MAKE" TARGET=$TARGET \
+ TESTROOT=$target_dir release) || exit 1
+ elif [ "$app" != "erts" ] && [ -d $ERL_TOP/lib/$app ]; then
+ (cd $ERL_TOP/lib/$app && $MAKE MAKE="$MAKE" TARGET=$TARGET \
+ TESTROOT=$target_dir release) || exit 1
+ else
+ echo "Invalid application $app" 1>&2
+ exit 1
+ fi
+ done
+
+ # If erts, kernel, stdlib or sasl is included, find versions
+ for app in "$@"; do
+ if [ "$app" = "erts" ]; then
+ erts_vsn=`grep '^VSN' erts/vsn.mk | sed "s|^VSN.*=[^0-9]*\([0-9].*\)$|\1|g"`
+ update_rel=true
+ elif [ "$app" = "kernel" ]; then
+ kernel_vsn=`sed "s|^KERNEL_VSN[^=]*=[^0-9]*\([0-9].*\)$|\1|g" lib/kernel/vsn.mk`
+ update_rel=true
+ elif [ "$app" = "stdlib" ]; then
+ stdlib_vsn=`sed "s|^STDLIB_VSN[^=]*=[^0-9]*\([0-9].*\)$|\1|g" lib/stdlib/vsn.mk`
+ update_rel=true
+ elif [ "$app" = "sasl" ]; then
+ sasl_vsn=`sed "s|^SASL_VSN[^=]*=[^0-9]*\([0-9].*\)$|\1|g" lib/sasl/vsn.mk`
+ update_rel=true
+ fi
+ done
+
+ # and find the old versions for those not included
+ if [ "X$update_rel" != "X" ]; then
+ if [ "X$erts_vsn" = "X" ]; then
+ erts_vsns=`ls -d $target_dir/erts-* | sed "s|$target_dir/erts-\([0-9\.].*\)|\1|g"`
+ erts_vsn=`echo "$erts_vsns" | sort -t '.' -g | tail -n 1`
+ fi
+ if [ "X$kernel_vsn" = "X" ]; then
+ kernel_vsns=`ls -d $target_dir/lib/kernel-* | sed "s|$target_dir/lib/kernel-\([0-9\.].*\)|\1|g"`
+ kernel_vsn=`echo "$kernel_vsns" | sort -t '.' -g | tail -n 1`
+ fi
+ if [ "X$stdlib_vsn" = "X" ]; then
+ stdlib_vsns=`ls -d $target_dir/lib/stdlib-* | sed "s|$target_dir/lib/stdlib-\([0-9\.].*\)|\1|g"`
+ stdlib_vsn=`echo "$stdlib_vsns" | sort -t '.' -g | tail -n 1`
+ fi
+ if [ "X$sasl_vsn" = "X" ]; then
+ sasl_vsns=`ls -d $target_dir/lib/sasl-* | sed "s|$target_dir/lib/sasl-\([0-9\.].*\)|\1|g"`
+ sasl_vsn=`echo "$sasl_vsns" | sort -t '.' -g | tail -n 1`
+ fi
+
+ # Generate .rel, .script and .boot - to tmp dir
+ start_clean="{release, {\"OTP APN 181 01\",\"$otp_major_vsn\"}, {erts, \"$erts_vsn\"},\n [{kernel,\"$kernel_vsn\"},\n {stdlib,\"$stdlib_vsn\"}]}.\n"
+ start_sasl="{release, {\"OTP APN 181 01\",\"$otp_major_vsn\"}, {erts, \"$erts_vsn\"},\n [{kernel,\"$kernel_vsn\"},\n {stdlib,\"$stdlib_vsn\"},\n {sasl,\"$sasl_vsn\"}]}.\n"
+
+ tmp_dir=$target_dir/tmp;
+ if [ ! -d $tmp_dir ]; then
+ mkdir $tmp_dir
+ fi
+ echo $start_sasl > $tmp_dir/start_sasl.rel
+ echo $start_clean > $tmp_dir/start_clean.rel
+ echo $start_clean > $tmp_dir/no_dot_erlang.rel
+
+ erlc=$ERL_TOP/bootstrap/bin/erlc
+ if [ ! -x $erlc ]; then
+ echo "erlc not found, can not create .script and .boot files" 1>&2
+ exit 1
+ fi
+
+ $erlc -I$target_dir/lib/*/ebin -o$tmp_dir $tmp_dir/start_sasl.rel || exit 1
+ $erlc -I$target_dir/lib/*/ebin -o$tmp_dir +no_warn_sasl $tmp_dir/start_clean.rel || exit 1
+ $erlc -I$target_dir/lib/*/ebin -o$tmp_dir +no_warn_sasl +no_dot_erlang $tmp_dir/no_dot_erlang.rel || exit 1
+
+ # Generate RELEASES file
+ erl=$ERL_TOP/bootstrap/bin/erl
+ if [ ! -x $erl ]; then
+ echo "erl not found, can not create RELEASES file" 1>&2
+ exit 1
+ fi
+ $erl -noinput +B -eval "release_handler:create_RELEASES(\"%ERL_ROOT%\", \"$tmp_dir\", \"$tmp_dir/start_sasl.rel\", []), halt()" || exit 1
+
+ # If all good so far, move generated files into target area
+ mv $tmp_dir/RELEASES $target_dir/releases/RELEASES.src
+ mv $tmp_dir/* $target_dir/releases/$otp_major_vsn
+ rmdir $tmp_dir
+
+ # Remove old start scripts (forces a new run of Install)
+ rm -f $target_dir/releases/RELEASES
+ rm -f $target_dir/bin/*.script
+ rm -f $target_dir/bin/*.boot
+ rm -f $target_dir/bin/erl
+ fi
+
+}
+
+
do_tests ()
{
setup_make
@@ -1451,6 +1573,9 @@ case "$1" in
shift
fi;
do_release "$2";;
+ patch_app)
+ shift;
+ do_patch_app "$@";;
tests)
if [ $minus_a_flag = true ]; then
shift