Skip to content

Commit

Permalink
Make migration script work with OSX bash and zsh
Browse files Browse the repository at this point in the history
`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 ff1cd01)
  • Loading branch information
marcbaechinger committed Apr 5, 2023
1 parent 0106f02 commit 67991cb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions media3-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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')"

0 comments on commit 67991cb

Please sign in to comment.