Skip to content

Commit 67991cb

Browse files
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 ff1cd01)
1 parent 0106f02 commit 67991cb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

media3-migration.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ function validate_string_patterns {
217217
'The MediaSessionConnector is integrated in androidx.media3.session.MediaSession'
218218
}
219219

220-
SED_CMD_INPLACE='sed -i '
220+
SED_CMD_INPLACE='sed --in-place=.bak '
221221
if [[ "$OSTYPE" == "darwin"* ]]; then
222-
SED_CMD_INPLACE="sed -i '' "
222+
SED_CMD_INPLACE="sed -i .bak "
223223
fi
224224

225225
MIGRATE_FILES='1'
@@ -322,12 +322,9 @@ then
322322
exit 0
323323
fi
324324

325-
PWD=$(pwd)
326325
if [[ ! -z $NO_CLEAN ]];
327326
then
328-
cd "$PROJECT_ROOT"
329327
./gradlew clean
330-
cd "$PWD"
331328
fi
332329

333330
# create expressions for class renamings
@@ -367,6 +364,7 @@ do
367364
echo "migrating $file"
368365
expr="$renaming_expressions $classes_expressions $packages_expressions"
369366
$SED_CMD_INPLACE $expr $file
367+
rm ${file}.bak
370368
done <<< "$files"
371369

372370
# create expressions for dependencies in gradle files
@@ -385,4 +383,5 @@ while read -r build_file;
385383
do
386384
echo "migrating build file $build_file"
387385
$SED_CMD_INPLACE $dependency_expressions $build_file
386+
rm ${build_file}.bak
388387
done <<< "$(find . -type f -name 'build\.gradle')"

0 commit comments

Comments
 (0)