fix: cannot build 'gerrit-3.2' on MacOS When `bazel build release` is called the following issue is being thrown: ERROR: /Users/jacek.centkowski/workspace/open/open-source/gerrit/plugins/gitiles/BUILD:23:9: Executing genrule //plugins/gitiles:gitiles-servlet-resources failed: (Exit 1): bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped) Use --sandbox_debug to see verbose messages from the sandbox sed: -I or -i may not be used with stdin Target //plugins/gitiles:gitiles failed to build It seems that 'Load fonts directly from Gerrit instead of 3rd party domains' introduced the `sed` transformation that is not supported under MacOS. As suggested in [1] the most portable way is to handle the backup file in the command line (at least it works on MacOS ;)). [1] https://stackoverflow.com/a/21243111 Bug: Issue 15307 Change-Id: I3c40bc42d0a0d1a25aacd1cd2687af03970f88b4
diff --git a/BUILD b/BUILD index 6aa6df5..057d3d2 100644 --- a/BUILD +++ b/BUILD
@@ -29,13 +29,17 @@ "cd $$TMP/com/google/gitiles/static", # To avoid loading 3rd party resources, we adapt gitiles' CSS to # load fonts from Gerrit directly: - # 1. Strip out Google font CSS imports - "sed -e '\\%^@import .//fonts\\.googleapis\\.com/%d' -i base.css", + # 1. Strip out Google font CSS imports to tmp file as in-place replace is OSX no-go + "sed -e '\\%^@import .//fonts\\.googleapis\\.com/%d' base.css > $$TMP/base.css.tmp", + # move tmp file back to base.css + "mv $$TMP/base.css.tmp base.css", # 2. Add Gerrit's fonts CSS "sed -e 's%^\\(.*Common styles and definitions.*\\)$$%" + - "\\1\\n\\n@import \"../../../styles/fonts.css\";%' -i base.css", + "\\1\\n\\n@import \"../../../styles/fonts.css\";%' base.css > $$TMP/base.css.tmp", + "mv $$TMP/base.css.tmp base.css", # 3. Use Gerrit's Roboto Mono for Source Code Pro - "sed -e 's/Source Code Pro/Roboto Mono/g' -i base.css", + "sed -e 's/Source Code Pro/Roboto Mono/g' base.css > $$TMP/base.css.tmp", + "mv $$TMP/base.css.tmp base.css", # Switching from `static` to `+static` (see comment in plugin definiton) "cd $$TMP/com/google/gitiles", "mv static +static",