diff options
| author | Michael Biebl <biebl@debian.org> | 2024-05-05 00:07:42 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2024-05-05 00:07:42 +0200 |
| commit | a9c892f6640668b93848584d246280c4d33cc025 (patch) | |
| tree | 914226b8c8fffd1a8e101e71d361d6d126322c12 /contrib/scripts/nm-code-format-container.sh | |
| parent | f03946fe0cdd73041658be1009f06f0e287c4b80 (diff) | |
| parent | 34bb501be08aa2b313d88e67d6e0a7e0a3f9cfa6 (diff) | |
Update upstream source from tag 'upstream/1.47.90'
Update to upstream version '1.47.90' with Debian dir fca683c43690f5e2bfc191d3d528666444bec54b
Diffstat (limited to 'contrib/scripts/nm-code-format-container.sh')
| -rwxr-xr-x | contrib/scripts/nm-code-format-container.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/scripts/nm-code-format-container.sh b/contrib/scripts/nm-code-format-container.sh new file mode 100755 index 00000000..7a5ce0d4 --- /dev/null +++ b/contrib/scripts/nm-code-format-container.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -e + +die() { + echo "$@" >&2 + exit 1 +} + +DIR="$(realpath "$(dirname "$0")/../../")" +cd "$DIR" + +# The correct clang-format version is the one from the Fedora version used in our +# gitlab-ci pipeline. Parse it from ".gitlab-ci/config.yml". +FEDORA_VERSION="$(sed '/^ tier: 1/,/^ - name/!d' .gitlab-ci/config.yml | sed -n "s/^ - '\([0-9]\+\)'$/\1/p" | sed -n 1p)" + +test -n "$FEDORA_VERSION" || die "Could not detect the Fedora version in .gitlab-ci/config.yml" + +IMAGENAME="nm-code-format:f$FEDORA_VERSION" + +ARGS=( "$@" ) + +if ! podman image exists "$IMAGENAME" ; then + echo "Building image \"$IMAGENAME\"..." + podman build \ + --squash-all \ + --tag "$IMAGENAME" \ + -f <(cat <<EOF +FROM fedora:$FEDORA_VERSION +RUN dnf upgrade -y +RUN dnf install -y git /usr/bin/clang-format +EOF +) +fi + +CMD=( ./contrib/scripts/nm-code-format.sh "${ARGS[@]}" ) + +podman run \ + --rm \ + --name "nm-code-format-f$FEDORA_VERSION" \ + -v "$DIR:/tmp/NetworkManager:Z" \ + -w /tmp/NetworkManager \ + -e "_NM_CODE_FORMAT_CONTAINER=$IMAGENAME" \ + -ti \ + "$IMAGENAME" \ + "${CMD[@]}" |