From 3afa604acd0b2b5948b1330c944f8165d4cdb07c Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Mon, 25 Jan 2021 18:02:15 +0200 Subject: [PATCH] [Build-System] Check requirements when generating tarballs. --- bootstrap.sh | 172 +--------------------------- scripts/ci/build-requirements.sh | 191 +++++++++++++++++++++++++++++++ scripts/ci/src_tarball.sh | 11 ++ 3 files changed, 204 insertions(+), 170 deletions(-) create mode 100755 scripts/ci/build-requirements.sh diff --git a/bootstrap.sh b/bootstrap.sh index 6d8256aab1..fa7e10ad88 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -2,6 +2,8 @@ ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- ##### bootstrap FreeSWITCH and FreeSWITCH libraries +. $(dirname $0)/scripts/ci/build-requirements.sh + echo "bootstrap: checking installation..." BGJOB=false @@ -45,176 +47,6 @@ setup_gnu() { touch README } -check_ac_ver() { - # autoconf 2.59 or newer - ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` - if test -z "$ac_version"; then - echo "bootstrap: autoconf not found." - echo " You need autoconf version 2.59 or newer installed" - echo " to build FreeSWITCH from source." - exit 1 - fi - if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then - echo "Autoconf 2.62 is broken on OpenBSD, please try another version" - exit 1 - fi - IFS=_; set $ac_version; IFS=' ' - ac_version=$1 - IFS=.; set $ac_version; IFS=' ' - if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then - echo "bootstrap: autoconf version $ac_version found." - echo " You need autoconf version 2.59 or newer installed" - echo " to build FreeSWITCH from source." - exit 1 - else - echo "bootstrap: autoconf version $ac_version (ok)" - fi -} - -check_am_ver() { - # automake 1.7 or newer - am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` - if test -z "$am_version"; then - echo "bootstrap: automake not found." - echo " You need automake version 1.7 or newer installed" - echo " to build FreeSWITCH from source." - exit 1 - fi - IFS=_; set $am_version; IFS=' ' - am_version=$1 - IFS=.; set $am_version; IFS=' ' - if test "$1" = "1" -a "$2" -lt "7"; then - echo "bootstrap: automake version $am_version found." - echo " You need automake version 1.7 or newer installed" - echo " to build FreeSWITCH from source." - exit 1 - else - echo "bootstrap: automake version $am_version (ok)" - fi -} - -check_acl_ver() { - # aclocal 1.7 or newer - acl_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` - if test -z "$acl_version"; then - echo "bootstrap: aclocal not found." - echo " You need aclocal version 1.7 or newer installed" - echo " to build FreeSWITCH from source." - exit 1 - fi - IFS=_; set $acl_version; IFS=' ' - acl_version=$1 - IFS=.; set $acl_version; IFS=' ' - if test "$1" = "1" -a "$2" -lt "7"; then - echo "bootstrap: aclocal version $acl_version found." - echo " You need aclocal version 1.7 or newer installed" - echo " to build FreeSWITCH from source." - exit 1 - else - echo "bootstrap: aclocal version $acl_version (ok)" - fi -} - -check_lt_ver() { - # Sample libtool --version outputs: - # ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11) - # ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a - # output is multiline from 1.5 onwards - - # Require libtool 1.4 or newer - libtool=${LIBTOOL:-`${LIBDIR}/apr/build/PrintPath glibtool libtool libtool22 libtool15 libtool14`} - lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` - if test -z "$lt_pversion"; then - echo "bootstrap: libtool not found." - echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source." - exit 1 - fi - lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'` - IFS=.; set $lt_version; IFS=' ' - lt_status="good" - - if test -z "$1"; then a=0 ; else a=$1;fi - if test -z "$2"; then b=0 ; else b=$2;fi - if test -z "$3"; then c=0 ; else c=$3;fi - lt_major=$a - - if test "$a" -eq "2"; then - lt_status="good" - elif test "$a" -lt "2"; then - if test "$b" -lt "5" -o "$b" = "5" -a "$c" -lt "14" ; then - lt_status="bad" - fi - else - lt_status="bad" - fi - if test $lt_status = "good"; then - echo "bootstrap: libtool version $lt_pversion (ok)" - else - echo "bootstrap: libtool version $lt_pversion found." - echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source." - exit 1 - fi -} - -check_libtoolize() { - # check libtoolize availability - if [ -n "${LIBTOOL}" ]; then - libtoolize=${LIBTOOLIZE:-`dirname "${LIBTOOL}"`/libtoolize} - else - libtoolize=${LIBTOOLIZE:-`${LIBDIR}/apr/build/PrintPath glibtoolize libtoolize libtoolize22 libtoolize15 libtoolize14`} - fi - if [ "x$libtoolize" = "x" ]; then - echo "libtoolize not found in path" - exit 1 - fi - if [ ! -x "$libtoolize" ]; then - echo "$libtoolize does not exist or is not executable" - exit 1 - fi - - # compare libtool and libtoolize version - ltl_pversion=`$libtoolize --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` - ltl_version=`echo $ltl_pversion|sed -e 's/\([a-z]*\)$/.\1/'` - IFS=.; set $ltl_version; IFS=' ' - - if [ "x${lt_version}" != "x${ltl_version}" ]; then - echo "$libtool and $libtoolize have different versions" - exit 1 - fi -} - -check_make() { - # - # Check to make sure we have GNU Make installed - # - - make=`which make` - if [ -x "$make" ]; then - make_version=`$make --version || true | grep GNU` - if [ $? -ne 0 ]; then - make=`which gmake` - if [ -x "$make" ]; then - make_version=`$make --version | grep GNU` - if [ $? -ne 0 ]; then - echo "GNU Make does not exist or is not executable" - exit 1; - fi - fi - fi - fi -} - - -check_awk() { - # TODO: Building with mawk on at least Debian squeeze is know to - # work, but mawk is believed to fail on some systems. If we can - # replicate this, we need a particular behavior that we can test - # here to verify whether we have an acceptable awk. - : -} - - - print_autotools_vers() { # # Info output diff --git a/scripts/ci/build-requirements.sh b/scripts/ci/build-requirements.sh new file mode 100755 index 0000000000..b27efd62c7 --- /dev/null +++ b/scripts/ci/build-requirements.sh @@ -0,0 +1,191 @@ +#!/bin/sh +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- + +check_ac_ver() { + # autoconf 2.59 or newer + ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` + if test -z "$ac_version"; then + echo "build-requirements: autoconf not found." + echo " You need autoconf version 2.59 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + fi + if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then + echo "Autoconf 2.62 is broken on OpenBSD, please try another version" + exit 1 + fi + IFS=_; set $ac_version; IFS=' ' + ac_version=$1 + IFS=.; set $ac_version; IFS=' ' + if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then + echo "build-requirements: autoconf version $ac_version found." + echo " You need autoconf version 2.59 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + else + echo "build-requirements: autoconf version $ac_version (ok)" + fi +} + +check_am_ver() { + # automake 1.7 or newer + am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` + if test -z "$am_version"; then + echo "build-requirements: automake not found." + echo " You need automake version 1.7 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + fi + IFS=_; set $am_version; IFS=' ' + am_version=$1 + IFS=.; set $am_version; IFS=' ' + if test "$1" = "1" -a "$2" -lt "7"; then + echo "build-requirements: automake version $am_version found." + echo " You need automake version 1.7 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + else + echo "build-requirements: automake version $am_version (ok)" + fi +} + +check_acl_ver() { + # aclocal 1.7 or newer + acl_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` + if test -z "$acl_version"; then + echo "build-requirements: aclocal not found." + echo " You need aclocal version 1.7 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + fi + IFS=_; set $acl_version; IFS=' ' + acl_version=$1 + IFS=.; set $acl_version; IFS=' ' + if test "$1" = "1" -a "$2" -lt "7"; then + echo "build-requirements: aclocal version $acl_version found." + echo " You need aclocal version 1.7 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + else + echo "build-requirements: aclocal version $acl_version (ok)" + fi +} + +check_lt_ver() { + # Sample libtool --version outputs: + # ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11) + # ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a + # output is multiline from 1.5 onwards + + # find APR PrintPath binary path + for el in "${LIBDIR}/apr/build/PrintPath" \ + "libs/apr/build/PrintPath" \ + "../libs/apr/build/PrintPath" \ + "../../libs/apr/build/PrintPath"; do + if test -f "$el"; then + PrintPathBin="$el" + break + fi + done + + # Require libtool 1.4 or newer + libtool=${LIBTOOL:-`${PrintPathBin} glibtool libtool libtool22 libtool15 libtool14`} + lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` + if test -z "$lt_pversion"; then + echo "build-requirements: libtool not found." + echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source." + exit 1 + fi + lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'` + IFS=.; set $lt_version; IFS=' ' + lt_status="good" + + if test -z "$1"; then a=0 ; else a=$1;fi + if test -z "$2"; then b=0 ; else b=$2;fi + if test -z "$3"; then c=0 ; else c=$3;fi + lt_major=$a + + if test "$a" -eq "2"; then + lt_status="good" + elif test "$a" -lt "2"; then + if test "$b" -lt "5" -o "$b" = "5" -a "$c" -lt "14" ; then + lt_status="bad" + fi + else + lt_status="bad" + fi + if test $lt_status = "good"; then + echo "build-requirements: libtool version $lt_pversion (ok)" + else + echo "build-requirements: libtool version $lt_pversion found." + echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source." + exit 1 + fi +} + +check_libtoolize() { + # find APR PrintPath binary path + for el in "${LIBDIR}/apr/build/PrintPath" \ + "libs/apr/build/PrintPath" \ + "../libs/apr/build/PrintPath" \ + "../../libs/apr/build/PrintPath"; do + if test -f "$el"; then + PrintPathBin="$el" + break + fi + done + + # check libtoolize availability + if [ -n "${LIBTOOL}" ]; then + libtoolize=${LIBTOOLIZE:-`dirname "${LIBTOOL}"`/libtoolize} + else + libtoolize=${LIBTOOLIZE:-`${PrintPathBin} glibtoolize libtoolize libtoolize22 libtoolize15 libtoolize14`} + fi + if [ "x$libtoolize" = "x" ]; then + echo "libtoolize not found in path" + exit 1 + fi + if [ ! -x "$libtoolize" ]; then + echo "$libtoolize does not exist or is not executable" + exit 1 + fi + + # compare libtool and libtoolize version + ltl_pversion=`$libtoolize --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` + ltl_version=`echo $ltl_pversion|sed -e 's/\([a-z]*\)$/.\1/'` + IFS=.; set $ltl_version; IFS=' ' + + if [ "x${lt_version}" != "x${ltl_version}" ]; then + echo "$libtool and $libtoolize have different versions" + exit 1 + fi +} + +check_make() { + # + # Check to make sure we have GNU Make installed + # + + make=`which make` + if [ -x "$make" ]; then + make_version=`$make --version || true | grep GNU` + if [ $? -ne 0 ]; then + make=`which gmake` + if [ -x "$make" ]; then + make_version=`$make --version | grep GNU` + if [ $? -ne 0 ]; then + echo "GNU Make does not exist or is not executable" + exit 1; + fi + fi + fi + fi +} + +check_awk() { + # TODO: Building with mawk on at least Debian squeeze is know to + # work, but mawk is believed to fail on some systems. If we can + # replicate this, we need a particular behavior that we can test + # here to verify whether we have an acceptable awk. + : +} diff --git a/scripts/ci/src_tarball.sh b/scripts/ci/src_tarball.sh index 5f3b629953..2cc2b382e1 100755 --- a/scripts/ci/src_tarball.sh +++ b/scripts/ci/src_tarball.sh @@ -1,6 +1,17 @@ #!/bin/sh ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- +. $(dirname $0)/build-requirements.sh + +# run build checks +check_make +check_awk +check_ac_ver +check_am_ver +check_acl_ver +check_lt_ver +check_libtoolize + sdir="." [ -n "${0%/*}" ] && sdir="${0%/*}" . $sdir/common.sh