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 { ...@@ -217,9 +217,9 @@ function validate_string_patterns {
'The MediaSessionConnector is integrated in androidx.media3.session.MediaSession' '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 if [[ "$OSTYPE" == "darwin"* ]]; then
SED_CMD_INPLACE="sed -i '' " SED_CMD_INPLACE="sed -i .bak "
fi fi
MIGRATE_FILES='1' MIGRATE_FILES='1'
...@@ -322,12 +322,9 @@ then ...@@ -322,12 +322,9 @@ then
exit 0 exit 0
fi fi
PWD=$(pwd)
if [[ ! -z $NO_CLEAN ]]; if [[ ! -z $NO_CLEAN ]];
then then
cd "$PROJECT_ROOT"
./gradlew clean ./gradlew clean
cd "$PWD"
fi fi
# create expressions for class renamings # create expressions for class renamings
...@@ -367,6 +364,7 @@ do ...@@ -367,6 +364,7 @@ do
echo "migrating $file" echo "migrating $file"
expr="$renaming_expressions $classes_expressions $packages_expressions" expr="$renaming_expressions $classes_expressions $packages_expressions"
$SED_CMD_INPLACE $expr $file $SED_CMD_INPLACE $expr $file
rm ${file}.bak
done <<< "$files" done <<< "$files"
# create expressions for dependencies in gradle files # create expressions for dependencies in gradle files
...@@ -385,4 +383,5 @@ while read -r build_file; ...@@ -385,4 +383,5 @@ while read -r build_file;
do do
echo "migrating build file $build_file" echo "migrating build file $build_file"
$SED_CMD_INPLACE $dependency_expressions $build_file $SED_CMD_INPLACE $dependency_expressions $build_file
rm ${build_file}.bak
done <<< "$(find . -type f -name 'build\.gradle')" 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