Skip to content

Commit

Permalink
BSD sed inplace args fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Mar 3, 2024
1 parent e354610 commit efa4242
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions sysroot/relocate-sdk.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
diff --git a/relocate-sdk.sh b/relocate-sdk.sh
--- a/relocate-sdk.sh (date 1687254851000)
+++ b/relocate-sdk.sh (date 1687703200191)
@@ -43,10 +43,10 @@
+++ b/relocate-sdk.sh (date 1699325031602)
@@ -39,14 +39,20 @@

# Make sure file uses the right language
export LC_ALL=C
+# Proper in-place argument for sed
+if sed --version 1>/dev/null 2>&1; then
+ SED_INPLACE_ARGS="-i"
+else # BSD sed
+ SED_INPLACE_ARGS="-i ''"
+fi
# Replace the old path with the new one in all text files
grep -lr "${OLDPATH}" . | while read -r FILE ; do
if file -b --mime-type "${FILE}" | grep -q '^text/' && [ "${FILE}" != "${LOCFILE}" ]
then
- sed -i "s|${OLDPATH}|${NEWPATH}|g" "${FILE}"
+ sed -i "" "s|${OLDPATH}|${NEWPATH}|g" "${FILE}"
+ sed ${SED_INPLACE_ARGS} "s|${OLDPATH}|${NEWPATH}|g" "${FILE}"
fi
done

# At the very end, we update the location file to not break the
# SDK if this script gets interruted.
-sed -i "s|${OLDPATH}|${NEWPATH}|g" ${LOCFILE}
+sed -i "" "s|${OLDPATH}|${NEWPATH}|g" ${LOCFILE}
+sed ${SED_INPLACE_ARGS} "s|${OLDPATH}|${NEWPATH}|g" ${LOCFILE}

0 comments on commit efa4242

Please sign in to comment.