From 9296d25811fba7a72a7b31969275c7ba4eba3a63 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 13 Oct 2009 00:07:13 +0200 Subject: [PATCH] shutils: return proper error in {do,pre,post}_* stage funcs and use msg_error. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091012220713-k3j00b7x3jk5s3we --- shutils/build_funcs.sh | 4 ++-- shutils/common_funcs.sh | 5 ++++- shutils/configure_funcs.sh | 4 ++-- shutils/install_funcs.sh | 21 ++++++++------------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/shutils/build_funcs.sh b/shutils/build_funcs.sh index 3af79517..a59c735c 100644 --- a/shutils/build_funcs.sh +++ b/shutils/build_funcs.sh @@ -58,7 +58,7 @@ build_src_phase() [ -z "$make_cmd" ] && make_cmd=/usr/bin/make # Run pre_build func. - run_func pre_build + run_func pre_build || msg_error "pre_build stage failed!" [ -n "$XBPS_MAKEJOBS" -a -z "$disable_parallel_build" ] && \ makejobs="-j$XBPS_MAKEJOBS" @@ -80,7 +80,7 @@ build_src_phase() [ $? -ne 0 ] && msg_error "building $pkg (build phase)." # Run post_build func. - run_func post_build + run_func post_build || msg_error "post_build stage failed!" unset makejobs diff --git a/shutils/common_funcs.sh b/shutils/common_funcs.sh index bdc5f3e5..42ab197a 100644 --- a/shutils/common_funcs.sh +++ b/shutils/common_funcs.sh @@ -33,7 +33,10 @@ run_func() [ -z "$func" ] && return 1 type -t $func | grep -q 'function' - [ $? -eq 0 ] && $func + if [ $? -eq 0 ]; then + $func + return $? + fi } run_rootcmd() diff --git a/shutils/configure_funcs.sh b/shutils/configure_funcs.sh index 1d7356ac..c1c83e1d 100644 --- a/shutils/configure_funcs.sh +++ b/shutils/configure_funcs.sh @@ -62,7 +62,7 @@ configure_src_phase() fi # Run pre_configure func. - run_func pre_configure + run_func pre_configure || msg_error "pre_configure stage failed!" # Export configure_env vars. for f in ${configure_env}; do @@ -124,7 +124,7 @@ configure_src_phase() fi # Run post_configure func. - run_func post_configure + run_func post_configure || msg_error "post_configure stage failed!" # unset configure_env vars. for f in ${configure_env}; do diff --git a/shutils/install_funcs.sh b/shutils/install_funcs.sh index b582c9a0..cd3ef6e3 100644 --- a/shutils/install_funcs.sh +++ b/shutils/install_funcs.sh @@ -49,12 +49,10 @@ install_src_phase() return 0 fi - [ ! -d $wrksrc ] && msg_error "unexistent build directory [$wrksrc]" - - cd $wrksrc || exit 1 + cd $wrksrc || msg_error "can't change cwd to wrksrc!" # Run pre_install func. - run_func pre_install + run_func pre_install || msg_error "pre_install stage failed!" msg_normal "Running install phase for $pkgname-$lver." @@ -65,13 +63,13 @@ install_src_phase() fi if [ "$build_style" = "custom-install" ]; then - run_func do_install + run_func do_install || msg_error "do_install stage failed!" else make_install $lver fi # Run post_install func. - run_func post_install + run_func post_install || msg_error "post_install stage failed!" # Remove libtool archives from pkg destdir. if [ -z "$libtool_no_delete_archives" ]; then @@ -110,7 +108,8 @@ install_src_phase() . $XBPS_TEMPLATESDIR/$pkgname/$subpkg.template pkgname=${sourcepkg}-${subpkg} set_tmpl_common_vars - run_func do_install + run_func do_install || \ + msg_error "$pkgname do_install stage failed!" run_template ${sourcepkg} [ "$pkg" = "${sourcepkg}-${subpkg}" ] && break done @@ -120,8 +119,7 @@ install_src_phase() # Remove $wrksrc if -C not specified. # if [ -d "$wrksrc" -a -z "$dontrm_builddir" ]; then - rm -rf $wrksrc - [ $? -eq 0 ] && \ + rm -rf $wrksrc && \ msg_normal "Removed $pkgname-$lver build directory." fi } @@ -147,10 +145,7 @@ make_install() # Install package via make. # run_rootcmd no ${make_cmd} ${make_install_target} ${make_install_args} - if [ "$?" -ne 0 ]; then - msg_error "installing $pkgname-$lver." - exit 1 - fi + [ $? -ne 0 ] && msg_error "installing $pkgname-$lver." # Replace libtool archives if requested. if [ -z "$in_chroot" ]; then