summaryrefslogtreecommitdiff
path: root/contrib/scripts/nm-code-format-container.sh
blob: 9d9643832fffb4e9100876b18ce2138e72e43d68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash

set -e

die() {
    echo "$@" >&2
    exit 1
}

DIR="$(realpath "$(dirname "$0")/../../")"
cd "$DIR"

FEDORA_VERSION=37

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"