summaryrefslogtreecommitdiff
path: root/scripts/include/common.sh
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-01-24 04:27:01 +0300
committerAndrei Karas <akaras@inbox.ru>2017-01-24 04:27:01 +0300
commit508999bc2d58668ccc55248f0c319ee866f71c15 (patch)
tree8126f51eb81ed692e1592f8c8c0536bf2e41a682 /scripts/include/common.sh
parent2ddf896a62b8a2744e11c1508bda39732c7a24f9 (diff)
downloadspm-508999bc2d58668ccc55248f0c319ee866f71c15.tar.gz
spm-508999bc2d58668ccc55248f0c319ee866f71c15.tar.bz2
spm-508999bc2d58668ccc55248f0c319ee866f71c15.tar.xz
spm-508999bc2d58668ccc55248f0c319ee866f71c15.zip
Add error checks into common.sh
Diffstat (limited to 'scripts/include/common.sh')
-rw-r--r--scripts/include/common.sh34
1 files changed, 34 insertions, 0 deletions
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
}