From 508999bc2d58668ccc55248f0c319ee866f71c15 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 Jan 2017 04:27:01 +0300 Subject: Add error checks into common.sh --- scripts/include/common.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'scripts/include/common.sh') diff --git a/scripts/include/common.sh b/scripts/include/common.sh index b53f5f4..26ae83f 100644 --- a/scripts/include/common.sh +++ b/scripts/include/common.sh @@ -1,5 +1,12 @@ #!/bin/bash +function check_error { + if [ "$1" != 0 ]; then + echo "Error detected" + exit $1 + fi +} + function common_build_init { export dir=$(pwd) @@ -15,19 +22,24 @@ function common_build_init { if [ ! -d "../env" ]; then mkdir -p "../env" + check_error $? fi if [ ! -d "../bin" ]; then mkdir -p "../bin" + check_error $? fi if [ ! -d "../tmp" ]; then mkdir -p "../tmp" + check_error $? fi export builddir=$(realpath "${dir}/../tmp/${package}") export bindir=$(realpath "${dir}/../bin/${installname}") rm -rf "${builddir}" + check_error $? mkdir -p "${builddir}" + check_error $? } function common_package_init { @@ -48,35 +60,46 @@ function common_package_init { function common_run_package { cd ../packages + check_error $? echo "${package}.sh" source "./${package}.sh" + check_error $? } function common_use_package { cd ${scriptsdir} + check_error $? export envfile="../env/run${package}.sh" echo "#!/bin/bash" >${envfile} + check_error $? echo "" >>${envfile} echo "package_use" package_use + check_error $? echo "\$*" >>${envfile} + check_error $? chmod 0755 ${envfile} + check_error $? } function env_path { echo "export PATH=${bindir}/$1:\$PATH" >>${envfile} + check_error $? } function env_lib_library_path { echo "export LD_LIBRARY_PATH=${bindir}/$1:\$LD_LIBRARY_PATH" >>${envfile} + check_error $? } function env_pkg_config_path { echo "export PKG_CONFIG_PATH=${bindir}/$1:\$PKG_CONFIG_PATH" >>${envfile} + check_error $? } function env_man { echo "export MANPATH=${bindir}/$1:\$MANPATH" >>${envfile} + check_error $? } function run_autoreconf { @@ -85,48 +108,57 @@ function run_autoreconf { make distclean echo "autoreconf $*" autoreconf $* + check_error $? } function run_configure { cd "${builddir}" echo "configure --prefix="${bindir}" $*" "$srcdir"/configure --prefix="${bindir}" $* + check_error $? } function run_cmake { cd "${builddir}" echo "cmake -DCMAKE_INSTALL_PREFIX:PATH="${bindir}" "$srcdir" $*" cmake -DCMAKE_INSTALL_PREFIX:PATH="${bindir}" "$srcdir" $* + check_error $? } function run_make { echo "make" make + check_error $? } function run_make_install { echo "make install" make install + check_error $? } function run_git_clone { echo "clone git repository $1" git clone $1 "../src/${package}" + check_error $? } function run_hg_clone { echo "clone hg repository $1" hg clone $1 "../src/${package}" + check_error $? } function run_git_switch_branch { cd "${srcdir}" + check_error $? if [[ "${srcbranch}" == "" ]]; then export srcbranch="$1" fi echo "git checkout ${srcbranch}" git checkout "${srcbranch}" + check_error $? } function run_hg_switch_branch { @@ -137,6 +169,7 @@ function run_hg_switch_branch { fi echo "hg update ${srcbranch}" hg update ${srcbranch} + check_error $? } function package_use { @@ -154,6 +187,7 @@ function package_update_source { if [ -d .hg ]; then echo "hg pull" hg pull + check_error $? return fi } -- cgit v1.2.3-60-g2f50