From fdd86a394fe5c6a2dbd49d3033f4a78380d62ea3 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 13 Mar 2019 15:05:49 -0400 Subject: opkbuild: Add return statements after ob_error() calls --- (limited to 'src/opkbuild.sh') diff --git a/src/opkbuild.sh b/src/opkbuild.sh index 5b080e0..136743b 100644 --- a/src/opkbuild.sh +++ b/src/opkbuild.sh @@ -73,33 +73,38 @@ get_options() case "${opt}" in b) case "${opt_build}" in ''|'binary');; *) - ob_error "$(ob_get_msg 'bsf_mutex')";; + ob_error "$(ob_get_msg 'bsf_mutex')" + return 1 esac opt_build='binary' ;; B) case "${opt_build}" in ''|'binary');; *) - ob_error "$(ob_get_msg 'bsf_mutex')";; + ob_error "$(ob_get_msg 'bsf_mutex')" + return 1 esac opt_build='binary' opt_arch_dep=true ;; P) case "${opt_build}" in ''|'binary');; *) - ob_error "$(ob_get_msg 'bsf_mutex')";; + ob_error "$(ob_get_msg 'bsf_mutex')" + return 1 esac opt_build='binary' opt_plat_dep=true ;; S) case "${opt_build}" in ''|'source');; *) - ob_error "$(ob_get_msg 'bsf_mutex')";; + ob_error "$(ob_get_msg 'bsf_mutex')" + return 1 esac opt_build='source' ;; F) case "${opt_build}" in ''|'full');; *) - ob_error "$(ob_get_msg 'bsf_mutex')";; + ob_error "$(ob_get_msg 'bsf_mutex')" + return 1 esac opt_build='full' ;; @@ -137,7 +142,7 @@ get_options() ;; ?) ob_error "$(ob_get_msg 'bad_opt')" "${opt}" - exit 1 + return 1 ;; esac done @@ -155,6 +160,8 @@ get_options() else [ -z "${opt_clean}" ] && opt_clean='true' fi + + return 0 } test_uid0_cmd() @@ -162,11 +169,15 @@ test_uid0_cmd() # Verify that the UID 0 command works. if ! test_uid=$("${opt_uid0_cmd}" -- id -u); then ob_error "$(ob_get_msg 'uid0_cmd_not_found')" "${opt_uid0_cmd}" + return 1 fi if [ ${test_uid} -ne 0 ]; then ob_error "$(ob_get_msg 'uid0_cmd_bad_uid')" "${opt_uid0_cmd}" + return 1 fi + + return 0 } setup_arch_plat() @@ -228,17 +239,21 @@ build_source() src_pkg_data_base="src-${src}.data$(ob_get_system_path 'package-source' \ "${src}" "${ver}")" - "${opt_uid0_cmd}" -- mkdir -p \ - "${src_pkg_data_base}" || \ + if ! "${opt_uid0_cmd}" -- mkdir -p "${src_pkg_data_base}"; then ob_error "$(ob_get_msg 'cant_make_src_pkg_dir')" + return 1 + fi for file in ../*; do case "${file}" in ../tmp) ;; ../*) - "${opt_uid0_cmd}" -- cp -Rp "${file}" "${src_pkg_data_base}" || \ + if ! "${opt_uid0_cmd}" -- cp -Rp "${file}" \ + "${src_pkg_data_base}"; then ob_error "$(ob_get_msg 'cant_install_src_pkg_file')" + return 1 + fi ;; esac done @@ -253,7 +268,12 @@ build_source() exit 1 fi - rm -Rf "src-${src}.data" || ob_error "$(ob_get_msg 'cant_rm_src_pkg_data')" + if ! rm -Rf "src-${src}.data"; then + ob_error "$(ob_get_msg 'cant_rm_src_pkg_data')" + return 1 + fi + + return 0 } print_arch_stats() @@ -344,14 +364,14 @@ main() { ob_set_text_domain 'opkbuild' - get_options "${@}" + get_options "${@}" || return 1 shift $(($OPTIND - 1)) if [ ${#} -ne 0 ]; then usage exit 1 fi - test_uid0_cmd + test_uid0_cmd || return 1 setup_arch_plat @@ -360,7 +380,7 @@ main() setup_package if [ "${opt_build}" = 'source' -o "${opt_build}" = 'full' ]; then - build_source + build_source || return 1 fi if [ "${opt_build}" != 'source' ]; then @@ -374,6 +394,8 @@ main() build clean fi + + return 0 } main "${@}" -- cgit v0.9.1