cleanup code and handle errors better as Simon Stelling says in Bug 121317
authorMike Frysinger <vapier@gentoo.org>
Sat, 4 Feb 2006 05:56:09 +0000 (05:56 -0000)
committerMike Frysinger <vapier@gentoo.org>
Sat, 4 Feb 2006 05:56:09 +0000 (05:56 -0000)
svn path=/main/trunk/; revision=2654

bin/dobin
bin/dosbin

index 06960126e42f7bf5cc94b1bf00a42d525ddde674..9624c8a405aa579007a1c73c6c426bf81d46544d 100755 (executable)
--- 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}
index 17bb8bb3613a5b5c3518598f067c7fbe08559d9d..0e67275f8754dc106cc8da8ffc255a64c8dbdcfb 100755 (executable)
@@ -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}