From: Mike Frysinger Date: Sat, 4 Feb 2006 05:56:09 +0000 (-0000) Subject: cleanup code and handle errors better as Simon Stelling says in Bug 121317 X-Git-Tag: v2.1_pre5_2760~90 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=349beefedf261a4e7a98790f4bc0bfde09f5dd1c;p=portage.git cleanup code and handle errors better as Simon Stelling says in Bug 121317 svn path=/main/trunk/; revision=2654 --- diff --git a/bin/dobin b/bin/dobin index 06960126e..9624c8a40 100755 --- a/bin/dobin +++ b/bin/dobin @@ -3,26 +3,30 @@ # Distributed under the terms of the GNU General Public License v2 # $Id: /var/cvsroot/gentoo-src/portage/bin/dobin,v 1.13 2004/10/04 13:56:50 vapier Exp $ -if [ ${#} -lt 1 ] ; then - echo "${0}: at least one argument needed" +if [[ $# -lt 1 ]] ; then + echo "$0: at least one argument needed" 1>&2 exit 1 fi -if [ ! -d "${D}${DESTTREE}/bin" ] ; then +if [[ ! -d ${D}${DESTTREE}/bin ]] ; then install -d "${D}${DESTTREE}/bin" || exit 2 fi +case ${CHOST} in + *-freebsd*) group=wheel ;; + *) group=root ;; +esac + +ret=0 + for x in "$@" ; do - if [ -x "${x}" ] ; then - #if executable, use existing perms - install "${x}" "${D}${DESTTREE}/bin" || exit 3 + if [[ -e ${x} ]] ; then + install -m0755 -o root -g ${group} "${x}" "${D}${DESTTREE}/bin" else - #otherwise, use reasonable defaults - echo ">>> dobin: making ${x} executable..." - if [ "$USERLAND" == "GNU" ]; then - install -m0755 -o root -g root "${x}" "${D}${DESTTREE}/bin" || exit 4 - else - install -m0755 -o root -g wheel "${x}" "${D}${DESTTREE}/bin" || exit 4 - fi + echo "!!! ${0##*/}: ${x} does not exist" 1>&2 + false fi + ((ret+=$?)) done + +exit ${ret} diff --git a/bin/dosbin b/bin/dosbin index 17bb8bb36..0e67275f8 100755 --- a/bin/dosbin +++ b/bin/dosbin @@ -3,25 +3,30 @@ # Distributed under the terms of the GNU General Public License v2 # $Id: /var/cvsroot/gentoo-src/portage/bin/dosbin,v 1.11 2004/10/04 13:56:50 vapier Exp $ -if [ ${#} -lt 1 ] ; then - echo "${0}: at least one argument needed" +if [[ $# -lt 1 ]] ; then + echo "$0: at least one argument needed" 1>&2 exit 1 fi -if [ ! -d "${D}${DESTTREE}/sbin" ] ; then + +if [[ ! -d ${D}${DESTTREE}/sbin ]] ; then install -d "${D}${DESTTREE}/sbin" || exit 2 fi +case ${CHOST} in + *-freebsd*) group=wheel ;; + *) group=root ;; +esac + +ret=0 + for x in "$@" ; do - if [ -x "${x}" ] ; then - #if executable, use existing perms - install -m0755 "${x}" "${D}${DESTTREE}/sbin" || exit 3 + if [[ -e ${x} ]] ; then + install -m0755 -o root -g ${group} "${x}" "${D}${DESTTREE}/sbin" else - #otherwise, use reasonable defaults - echo ">>> dosbin: making ${x} executable..." - if [ "$USERLAND" == "GNU" ]; then - install -m0755 -o root -g root "${x}" "${D}${DESTTREE}/sbin" || exit 4 - else - install -m0755 -o root -g wheel "${x}" "${D}${DESTTREE}/sbin" || exit 4 - fi + echo "!!! ${0##*/}: ${x} does not exist" 1>&2 + false fi + ((ret+=$?)) done + +exit ${ret}