Commit 67991cb9 by bachinger Committed by Marc Baechinger

Make migration script work with OSX bash and zsh

`sed` has a different in-place command line syntax in FreeBsd
than GNU tools. This change makes the `sed` commands work with
FreeBSD `sed` on OSX in bash and zsh shells.

Issue: androidx/media#217
PiperOrigin-RevId: 522043938
(cherry picked from commit ff1cd017)
parent 0106f02a
Showing with 4 additions and 5 deletions
......@@ -217,9 +217,9 @@ function validate_string_patterns {
'The MediaSessionConnector is integrated in androidx.media3.session.MediaSession'
}
SED_CMD_INPLACE='sed -i '
SED_CMD_INPLACE='sed --in-place=.bak '
if [[ "$OSTYPE" == "darwin"* ]]; then
SED_CMD_INPLACE="sed -i '' "
SED_CMD_INPLACE="sed -i .bak "
fi
MIGRATE_FILES='1'
......@@ -322,12 +322,9 @@ then
exit 0
fi
PWD=$(pwd)
if [[ ! -z $NO_CLEAN ]];
then
cd "$PROJECT_ROOT"
./gradlew clean
cd "$PWD"
fi
# create expressions for class renamings
......@@ -367,6 +364,7 @@ do
echo "migrating $file"
expr="$renaming_expressions $classes_expressions $packages_expressions"
$SED_CMD_INPLACE $expr $file
rm ${file}.bak
done <<< "$files"
# create expressions for dependencies in gradle files
......@@ -385,4 +383,5 @@ while read -r build_file;
do
echo "migrating build file $build_file"
$SED_CMD_INPLACE $dependency_expressions $build_file
rm ${build_file}.bak
done <<< "$(find . -type f -name 'build\.gradle')"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment