Files
NetworkManager/contrib/scripts/nm-code-format-container.sh
Thomas Haller a6ff5ee448 contrib/scripts: add Fedora version to podmain container name for "nm-code-format-container.sh"
Older branches, like "nm-1-32" will always be formatted with a
different, older clang-format version. Luckily we also have on "nm-1-32"
branch the "nm-code-format-container.sh" script, so we can still
reformat the sources using the container.

However, as the name of the container was always "nm-code-format",
we would have to re-generate the container when we switch between
branches. As the container really only depends on the Fedora version
(as the clang-format version is tied to the corresponding Fedora
version), let's include the Fedora version in the name of the container.
2022-01-04 21:17:19 +01:00

48 lines
834 B
Bash
Executable File

#!/bin/bash
set -e
die() {
echo "$@" >&2
exit 1
}
DIR="$(realpath "$(dirname "$0")/../../")"
cd "$DIR"
FEDORA_VERSION=35
PODNAME="nm-code-format-f$FEDORA_VERSION"
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:$FEDORA_VERSION" \
/bin/bash -c 'dnf upgrade -y && dnf install -y git /usr/bin/clang-format && ./contrib/scripts/nm-code-format.sh -i'
exit 0
fi
podman start -a "$PODNAME"