-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add protoc-gen script to releng (2.x) (#23697)
* chore: add protoc-gen script to releng * chore: break cross-container-tag into separate variable * fix: call GNUMakefile "generate-sources" target instead This also does a better job at mounting the root directory in the docker container.
- Loading branch information
1 parent
b51fefd
commit 1c6fbf9
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
set -o errexit \ | ||
-o nounset \ | ||
-o pipefail | ||
|
||
ROOT="$(realpath "${BASH_SOURCE}")" # -> <project root>/releng/protoc-gen | ||
ROOT="$(dirname "${ROOT}")" # -> <project root>/releng/ | ||
ROOT="$(dirname "${ROOT}")" # -> <project root>/ | ||
|
||
( | ||
# Since this script is run outside of a docker container, it is | ||
# possible that one (or more) of the following executables is | ||
# not installed. | ||
set -x | ||
which docker | ||
which sudo | ||
which yq | ||
) 1>/dev/null | ||
|
||
CROSS_BUILDER_VERSION="$(yq -e eval '.parameters.cross-container-tag.default' "${ROOT}/.circleci/config.yml")" | ||
|
||
# Updating ownership within the container requires both the "UID" and "GID" | ||
# of the current user. Since the current user does not exist within the | ||
# container, "${USER}:" cannot be supplied to `chown`. | ||
USER_UID="$(id -u)" | ||
USER_GID="$(id -g)" | ||
|
||
read -d '' DOCKERSCRIPT <<EOF || true | ||
set -o errexit \ | ||
-o nounset \ | ||
-o pipefail | ||
touch /tmp/timestamp | ||
git config --global --add safe.directory /project | ||
pushd /project | ||
make generate-sources | ||
# If the previous command generated a new file, it will have "root:root" | ||
# ownership. This becomes an annoyance to work with (i.e git complains | ||
# when checking out branches). To circumvent this issue, update all | ||
# new files to the correct ownership. | ||
find . -newer /tmp/timestamp -exec chown -v "${USER_UID}:${USER_GID}" "{}" \\\; | ||
EOF | ||
|
||
sudo docker run --rm -it -v "${ROOT}:/project" "quay.io/influxdb/cross-builder:${CROSS_BUILDER_VERSION}" bash -c "${DOCKERSCRIPT}" | ||
|