@@ -15,6 +15,7 @@ print_usage () {
15
15
echo " "
16
16
echo " This script downloads the packages specified in packages.txt and uploads"
17
17
echo " them to CIPD for linux, mac, and windows."
18
+ echo " To confirm you have write permissions run 'cipd acl-check flutter/android/sdk/all/ -writer'."
18
19
echo " "
19
20
echo " Manage the packages to download in 'packages.txt'. You can use"
20
21
echo " 'sdkmanager --list --include_obsolete' in cmdline-tools to list all available packages."
@@ -26,34 +27,36 @@ print_usage () {
26
27
echo " and should only be run on linux or macos hosts."
27
28
}
28
29
29
- # Validate version is provided
30
- if [[ $1 == " " ]]; then
30
+ first_argument=$1
31
+ # Validate version or argument is provided.
32
+ if [[ $first_argument == " " ]]; then
31
33
print_usage
32
34
exit 1
33
35
fi
34
36
35
- # Validate version contains only lower case letters and numbers
36
- if ! [[ $1 =~ ^[[:lower:][:digit:]]+$ ]]; then
37
+ # Validate version contains only lower case letters and numbers.
38
+ if ! [[ $first_argument =~ ^[[:lower:][:digit:]]+$ ]]; then
37
39
echo " Version tag can only consist of lower case letters and digits." ;
38
40
print_usage
39
41
exit 1
40
42
fi
41
43
42
- # Validate path contains depot_tools
44
+ # Validate environment has cipd installed.
43
45
if [[ ` which cipd` == " " ]]; then
44
46
echo " 'cipd' command not found. depot_tools should be on the path."
45
47
exit 1
46
48
fi
47
49
48
50
sdk_path=${2:- $ANDROID_SDK_ROOT }
49
- version_tag=$1
50
51
51
52
# Validate directory contains all SDK packages
52
53
if [[ ! -d " $sdk_path " ]]; then
53
54
echo " Android SDK at '$sdk_path ' not found."
54
55
print_usage
55
56
exit 1
56
57
fi
58
+
59
+ # Validate caller has cipd.
57
60
if [[ ! -d " $sdk_path /cmdline-tools" ]]; then
58
61
echo " SDK directory does not contain $sdk_path /cmdline-tools."
59
62
print_usage
@@ -81,7 +84,7 @@ while [ ! -f "$sdkmanager_path" ]; do
81
84
done
82
85
83
86
# list available packages
84
- if [ $version_tag == " list" ]; then
87
+ if [ $first_argument == " list" ]; then
85
88
$sdkmanager_path --list --include_obsolete
86
89
exit 0
87
90
fi
@@ -120,12 +123,18 @@ for platform in "${platforms[@]}"; do
120
123
# in `ndk/`.
121
124
# This simplifies the build scripts, and enables version difference between
122
125
# the Dart and Flutter build while reusing the same build rules.
126
+ # See https://github.com/flutter/flutter/issues/136666#issuecomment-1805467578
123
127
mv $upload_dir /sdk/ndk $upload_dir /ndk-bundle
124
128
ndk_sub_paths=` find $upload_dir /ndk-bundle -maxdepth 1 -type d`
125
129
ndk_sub_paths_arr=($ndk_sub_paths )
126
130
mv ${ndk_sub_paths_arr[1]} $upload_dir /ndk
127
131
rm -rf $upload_dir /ndk-bundle
128
132
133
+ if [[ ! -d " $upload_dir /ndk" ]]; then
134
+ echo " Failure to bundle ndk for platform"
135
+ exit 1
136
+ fi
137
+
129
138
# Accept all licenses to ensure they are generated and uploaded.
130
139
yes " y" | $sdkmanager_path --licenses --sdk_root=$sdk_root
131
140
cp -r " $sdk_root /licenses" " $upload_dir /sdk"
@@ -141,11 +150,16 @@ for platform in "${platforms[@]}"; do
141
150
if [[ $platform == " macosx" ]]; then
142
151
cipd_name=" mac-$arch "
143
152
fi
144
- echo " Uploading $cipd_name to CIPD"
145
- cipd create -in $upload_dir -name " flutter/android/sdk/all/$cipd_name " -install-mode copy -tag version:$version_tag
153
+
154
+ echo " Uploading $upload_dir as $cipd_name to CIPD"
155
+ cipd create -in $upload_dir -name " flutter/android/sdk/all/$cipd_name " -install-mode copy -tag version:$first_argument
146
156
done
147
157
148
158
rm -rf $sdk_root
149
159
rm -rf $upload_dir
160
+
161
+ # This variable changes the behvaior of sdkmanager.
162
+ # Unset to clean up after script.
163
+ unset REPO_OS_OVERRIDE
150
164
done
151
165
rm -rf $temp_dir
0 commit comments