Bob Lantz

Correctly handle case when .tar.gz archive is missing

Previously, it would succeed since the checksum command would
return nothing in standard output.

Change-Id: I1a73d20a0e085107be8362a6226b1a213ecdab78
...@@ -19,10 +19,12 @@ summary: ...@@ -19,10 +19,12 @@ summary:
19 _EOF_ 19 _EOF_
20 } 20 }
21 21
22 -[ "$1" = "-h" ] && _usage && exit 0 22 +[ $# -gt 1 ] || [ "$1" = "-h" ] && _usage && exit 0
23 - 23 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT isn't set correctly" >&2 && exit 1
24 -[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 24 +set -e
25 +set -u
25 . $ONOS_ROOT/tools/build/envDefaults 26 . $ONOS_ROOT/tools/build/envDefaults
27 +[ ! -f "$ONOS_TAR" ] && echo "$ONOS_TAR does not exist - run onos-package?" >&2 && exit 1
26 28
27 node=${1:-$OCI} 29 node=${1:-$OCI}
28 remote=$ONOS_USER@$node 30 remote=$ONOS_USER@$node
...@@ -30,7 +32,7 @@ remote=$ONOS_USER@$node ...@@ -30,7 +32,7 @@ remote=$ONOS_USER@$node
30 locHash=$(cksum $ONOS_TAR | cut -d' ' -f1,2) 32 locHash=$(cksum $ONOS_TAR | cut -d' ' -f1,2)
31 remHash=$(ssh $remote cksum $ONOS_TAR 2>/dev/null | cut -d' ' -f1,2) 33 remHash=$(ssh $remote cksum $ONOS_TAR 2>/dev/null | cut -d' ' -f1,2)
32 34
33 -if [ "$locHash" = "$remHash" ]; then 35 +if [ -n "$locHash" ] && [ "$locHash" = "$remHash" ]; then
34 echo "ONOS bits $ONOS_TAR already up-to-date on $node..." 36 echo "ONOS bits $ONOS_TAR already up-to-date on $node..."
35 else 37 else
36 scp -q $ONOS_TAR $remote:/tmp 38 scp -q $ONOS_TAR $remote:/tmp
......