Skip to content

Commit e2d89ae

Browse files
authored
Tarball build, smoke-test startup fixes (#676)
* Catch some bad build-source-tarball args and exit Add an arg parsing loop, and stop running if something isn't recognized. For example, this prevents destroying my dev build if I spell "--skip-build" wrong or get the arg order incorrect. * Use exit code 0 for "--help" Also add unrecognized arg print in smoke-test.sh. * TARBALL_ROOT already existing isn't an error CI creates TARBALL_ROOT before building the tarball. Still include the message as informational in case it's useful to diagnose other scenarios. (cherry picked from commit 9a012eb)
1 parent 6dfcb6b commit e2d89ae

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

build-source-tarball.sh

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,49 @@
22
set -euo pipefail
33
IFS=$'\n\t'
44

5-
if [ -z "${1:-}" ]; then
5+
usage() {
66
echo "usage: $0 <path-to-tarball-root> [--skip-build]"
7+
echo ""
8+
}
9+
10+
if [ -z "${1:-}" ]; then
11+
usage
712
exit 1
813
fi
914

15+
TARBALL_ROOT=$1
16+
shift
17+
1018
SKIP_BUILD=0
1119

12-
if [ "${2:-}" == "--skip-build" ]; then
13-
SKIP_BUILD=1
14-
fi
20+
while :; do
21+
if [ $# -le 0 ]; then
22+
break
23+
fi
24+
25+
lowerI="$(echo $1 | awk '{print tolower($0)}')"
26+
case $lowerI in
27+
-?|-h|--help)
28+
usage
29+
exit 0
30+
;;
31+
--skip-build)
32+
SKIP_BUILD=1
33+
;;
34+
*)
35+
echo "Unrecognized argument '$1'"
36+
usage
37+
exit 1
38+
;;
39+
esac
40+
41+
shift
42+
done
1543

16-
TARBALL_ROOT=$1
1744
export FULL_TARBALL_ROOT=$(readlink -f $TARBALL_ROOT)
1845

1946
if [ -e "$TARBALL_ROOT" ]; then
20-
echo "error '$TARBALL_ROOT' exists"
47+
echo "info: '$TARBALL_ROOT' already exists"
2148
fi
2249

2350
export SCRIPT_ROOT="$(cd -P "$( dirname "$0" )" && pwd)"

smoke-test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ while :; do
5757
case $lowerI in
5858
-?|-h|--help)
5959
usage
60-
exit 1
60+
exit 0
6161
;;
6262
--dotnetdir)
6363
shift
@@ -106,6 +106,7 @@ while :; do
106106
archiveRestoredPackages=true
107107
;;
108108
*)
109+
echo "Unrecognized argument '$1'"
109110
usage
110111
exit 1
111112
;;

0 commit comments

Comments
 (0)