Protect sdk upload script from missing ndk, add documentation for checking write access, improve comments to add context (flutter/engine#47989)
Script used to upload 34v7 with ndk 26.1.10909125 Added documentation for how to check for write access before running script. Added documentation for why the ndk is in a non standard location. Protected against silent ndk failure caused by a failure to download ndk on m1 macs https://github.com/flutter/engine/pull/47609#issuecomment-1800207937 Clean up os override so that script does not dirty the environment variables in a shell where it is run. See https://github.com/flutter/flutter/issues/117973 for more detail on why a newer ndk is required.
This commit is contained in:
@@ -15,6 +15,7 @@ print_usage () {
|
||||
echo ""
|
||||
echo "This script downloads the packages specified in packages.txt and uploads"
|
||||
echo "them to CIPD for linux, mac, and windows."
|
||||
echo "To confirm you have write permissions run 'cipd acl-check flutter/android/sdk/all/ -writer'."
|
||||
echo ""
|
||||
echo "Manage the packages to download in 'packages.txt'. You can use"
|
||||
echo "'sdkmanager --list --include_obsolete' in cmdline-tools to list all available packages."
|
||||
@@ -26,27 +27,27 @@ print_usage () {
|
||||
echo "and should only be run on linux or macos hosts."
|
||||
}
|
||||
|
||||
# Validate version is provided
|
||||
if [[ $1 == "" ]]; then
|
||||
first_argument=$1
|
||||
# Validate version or argument is provided.
|
||||
if [[ $first_argument == "" ]]; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Validate version contains only lower case letters and numbers
|
||||
if ! [[ $1 =~ ^[[:lower:][:digit:]]+$ ]]; then
|
||||
# Validate version contains only lower case letters and numbers.
|
||||
if ! [[ $first_argument =~ ^[[:lower:][:digit:]]+$ ]]; then
|
||||
echo "Version tag can only consist of lower case letters and digits.";
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate path contains depot_tools
|
||||
# Validate environment has cipd installed.
|
||||
if [[ `which cipd` == "" ]]; then
|
||||
echo "'cipd' command not found. depot_tools should be on the path."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sdk_path=${2:-$ANDROID_SDK_ROOT}
|
||||
version_tag=$1
|
||||
|
||||
# Validate directory contains all SDK packages
|
||||
if [[ ! -d "$sdk_path" ]]; then
|
||||
@@ -54,6 +55,8 @@ if [[ ! -d "$sdk_path" ]]; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate caller has cipd.
|
||||
if [[ ! -d "$sdk_path/cmdline-tools" ]]; then
|
||||
echo "SDK directory does not contain $sdk_path/cmdline-tools."
|
||||
print_usage
|
||||
@@ -81,7 +84,7 @@ while [ ! -f "$sdkmanager_path" ]; do
|
||||
done
|
||||
|
||||
# list available packages
|
||||
if [ $version_tag == "list" ]; then
|
||||
if [ $first_argument == "list" ]; then
|
||||
$sdkmanager_path --list --include_obsolete
|
||||
exit 0
|
||||
fi
|
||||
@@ -120,12 +123,18 @@ for platform in "${platforms[@]}"; do
|
||||
# in `ndk/`.
|
||||
# This simplifies the build scripts, and enables version difference between
|
||||
# the Dart and Flutter build while reusing the same build rules.
|
||||
# See https://github.com/flutter/flutter/issues/136666#issuecomment-1805467578
|
||||
mv $upload_dir/sdk/ndk $upload_dir/ndk-bundle
|
||||
ndk_sub_paths=`find $upload_dir/ndk-bundle -maxdepth 1 -type d`
|
||||
ndk_sub_paths_arr=($ndk_sub_paths)
|
||||
mv ${ndk_sub_paths_arr[1]} $upload_dir/ndk
|
||||
rm -rf $upload_dir/ndk-bundle
|
||||
|
||||
if [[ ! -d "$upload_dir/ndk" ]]; then
|
||||
echo "Failure to bundle ndk for platform"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Accept all licenses to ensure they are generated and uploaded.
|
||||
yes "y" | $sdkmanager_path --licenses --sdk_root=$sdk_root
|
||||
cp -r "$sdk_root/licenses" "$upload_dir/sdk"
|
||||
@@ -141,11 +150,16 @@ for platform in "${platforms[@]}"; do
|
||||
if [[ $platform == "macosx" ]]; then
|
||||
cipd_name="mac-$arch"
|
||||
fi
|
||||
echo "Uploading $cipd_name to CIPD"
|
||||
cipd create -in $upload_dir -name "flutter/android/sdk/all/$cipd_name" -install-mode copy -tag version:$version_tag
|
||||
|
||||
echo "Uploading $upload_dir as $cipd_name to CIPD"
|
||||
cipd create -in $upload_dir -name "flutter/android/sdk/all/$cipd_name" -install-mode copy -tag version:$first_argument
|
||||
done
|
||||
|
||||
rm -rf $sdk_root
|
||||
rm -rf $upload_dir
|
||||
|
||||
# This variable changes the behvaior of sdkmanager.
|
||||
# Unset to clean up after script.
|
||||
unset REPO_OS_OVERRIDE
|
||||
done
|
||||
rm -rf $temp_dir
|
||||
|
||||
Reference in New Issue
Block a user