blob: 09da9dc1ee31b565f8f7ff790c57f345cce5d450 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/bin/bash
# ---------------------------------------------------------------------------------------------------------------------
# SPDX-License-Identifier: MIT
# ---------------------------------------------------------------------------------------------------------------------
usage () {
echo >&2 "Usage: ${0##*/} [options]"
echo >&2
echo >&2 "Options:"
echo >&2 " -w WORKSPACEDIR Specify the workspace directory to create (default: 'workspace'))"
echo >&2 " -m MANIFEST Specify a manifest, rather than interactive selection"
echo >&2 " -x EXTRA_MANIFEST Specify an extra manifest. To specify"
echo >&2 " multiple, use multiple -x arguments."
echo >&2 " -X Explicitly disable extra manifests"
echo >&2 " -h Show this usage information"
echo >&2
}
abspath () {
_path="$1"
if [ -n "${_path##/*}" ]; then
_path="${2:-$PWD}/$1"
fi
echo "$_path"
}
if [ "$1" = "--help" ]; then
usage
exit 1
fi
WORKSPACEDIR=$PWD/workspace
manifest=
extra_disabled=
extra_manifests=
all_versions=
while getopts w:m:x:Xah opt; do
case "$opt" in
w)
WORKSPACEDIR="$OPTARG"
if [ -z "$WORKSPACEDIR" ]; then
echo >&2 "-w requires an argument"
exit 1
else
WORKSPACEDIR="$(abspath "$WORKSPACEDIR")"
fi
;;
m)
manifest="$OPTARG"
if [ -z "$manifest" ]; then
echo >&2 "-m requires an argument"
exit 1
else
if [ ! -e "$manifest" ]; then
echo >&2 "Error: manifest path $manifest does not exist"
exit 1
else
manifest="$(abspath "$manifest")"
fi
fi
;;
X)
if [ -n "$extra_manifest" ]; then
echo >&2 "Error: -x and -X are mutually exclusive"
exit 1
fi
extra_disabled=1
;;
x)
if [ -n "$extra_disabled" ]; then
echo >&2 "Error: -x and -X are mutually exclusive"
exit 1
fi
extra_manifest="$OPTARG"
if [ -z "$extra_manifest" ]; then
echo >&2 "-x requires an argument"
exit 1
else
if [ ! -e "$extra_manifest" ]; then
echo >&2 "Error: extra_manifest path $extra_manifest does not exist"
exit 1
else
extra_manifests="$extra_manifests $(abspath "$extra_manifest")"
fi
fi
;;
a)
all_versions=1
;;
\? | h)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ -e "$WORKSPACEDIR" ]; then
existing_workspace=1
else
existing_workspace=0
fi
scriptdir="$(dirname "$0")"
"$scriptdir/mel-checkout" ${all_versions:+-a} ${extra_disabled:+-X} "$WORKSPACEDIR" "$manifest" $extra_manifests \
&& cd "$WORKSPACEDIR"
if [ $? -ne 0 ]; then
if [ $existing_workspace -eq 0 ]; then
# New workspace, clean up on failure
rm -r "$WORKSPACEDIR"
fi
exit 1
fi
|