From 7d92d6a5c655d095a3ed16daca25ba756c7713f0 Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Tue, 22 Oct 2024 05:20:49 +0200 Subject: [PATCH] [chore] Fix `make update-otel` on macOS (#35587) **Description:** When working on #35580, it seemed that `make update-otel` was not properly updating the `builder-config.yaml` files. I traced this down to the `updatehelper` script not working as intended. This turned out to be because it uses some features of the `sed` utility which do not exist on macOS, causing no updates to be made. The `\s` (whitespace) regex class is a GNU extension for `sed`; the POSIX-compatible equivalent is `[[:space:]]` ([related SO question](https://stackoverflow.com/questions/18840175/find-and-replace-with-spaces-using-sed-mac-terminal)). Moreover, on macOS, the `-i` (in-place) option requires an argument, even if empty; otherwise the `-e` following it is parsed as that argument, creating an unnecessary backup file ([related SO question](https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux)). **Testing:** I manually tested this change as part of developing the aforementioned PR; the script seems to work on macOS now. It would be good for someone to test this change on Linux to make sure nothing has broken there. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1e087f09fea2..86ecba3a3276 100644 --- a/Makefile +++ b/Makefile @@ -395,16 +395,16 @@ define updatehelper echo "Usage: updatehelper "; \ exit 1; \ fi - grep "go\.opentelemetry\.io" $(1) | sed 's/^\s*-\s*//' | while IFS= read -r line; do \ + grep "go\.opentelemetry\.io" $(1) | sed 's/^[[:space:]]*-[[:space:]]*//' | while IFS= read -r line; do \ if grep -qF "$$line" $(2); then \ package=$$(grep -F "$$line" $(2) | head -n 1 | awk '{print $$1}'); \ version=$$(grep -F "$$line" $(2) | head -n 1 | awk '{print $$2}'); \ builder_package=$$(grep -F "$$package" $(3) | awk '{print $$3}'); \ builder_version=$$(grep -F "$$package" $(3) | awk '{print $$4}'); \ if [ "$$builder_package" == "$$package" ]; then \ - echo "$$builder_version";\ - sed -i -e "s|$$builder_package.*$$builder_version|$$builder_package $$version|" $(3); \ - echo "[$(3)]: $$package updated to $$version"; \ + sed -i.bak -e "s|$$builder_package.*$$builder_version|$$builder_package $$version|" $(3); \ + rm $(3).bak; \ + echo "[$(3)]: $$package updated from $$builder_version to $$version"; \ fi; \ fi; \ done