diff options
author | Thomas Haller <thaller@redhat.com> | 2020-09-29 12:05:46 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-09-29 13:37:58 +0200 |
commit | 36b761fcaa958f5678ae057a80c99351f0082f5f (patch) | |
tree | d1b8610e8d5b4e0f9c8652d228635d85f8f0e4dc | |
parent | 20ebacbea2b6b0926679568d3fd9e4a4d63db25d (diff) | |
download | NetworkManager-36b761fcaa958f5678ae057a80c99351f0082f5f.tar.gz |
contrib: add "nm-code-format-container.sh" to reformat working directory in container
We use clang-format to format our code, and the exact format depends on
the clang version. Currently we use clang-11, as packaged in Fedora 33.
Add a script that runs a Fedora 33 container with podman and reformats
the current working directory.
Usage:
./contrib/scripts/nm-code-format-container.sh
-rwxr-xr-x | contrib/scripts/nm-code-format-container.sh | 45 |
1 files changed, 45 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 0000000000..680c916f21 --- /dev/null +++ b/contrib/scripts/nm-code-format-container.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +set -e + +die() { + echo "$@" >&2 + exit 1 +} + +DIR="$(realpath "$(dirname "$0")/../../")" +cd "$DIR" + +PODNAME=nm-code-format + +RENEW=0 +for a; do + case "$a" in + -f) + RENEW=1 + ;; + *) + die "invalid argument \"$a\"" + ;; + esac +done + +set -x + +if [ "$RENEW" == 1 ]; then + if podman container exists "$PODNAME" ; then + podman rm "$PODNAME" + fi +fi + +if ! podman container exists "$PODNAME" ; then + podman run \ + --name="$PODNAME" \ + -v "$DIR:/tmp/NetworkManager:Z" \ + -w /tmp/NetworkManager \ + fedora:33 \ + /bin/bash -c 'dnf upgrade -y && dnf install -y git which /usr/bin/clang-format && ./contrib/scripts/nm-code-format.sh -i' + exit 0 +fi + +podman start -a "$PODNAME" |