From: Zack Cerza Date: Wed, 10 Sep 2025 21:47:45 +0000 (-0600) Subject: setup_container_runtime.sh: Version comparison X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a8aa262555adcb79b00147e0b4b625a24bba1b21;p=ceph-build.git setup_container_runtime.sh: Version comparison ... using Go templates instead of jq Signed-off-by: Zack Cerza --- diff --git a/scripts/setup_container_runtime.sh b/scripts/setup_container_runtime.sh index a62a53db..14087eed 100755 --- a/scripts/setup_container_runtime.sh +++ b/scripts/setup_container_runtime.sh @@ -4,8 +4,7 @@ function setup_container_runtime () { loginctl enable-linger "$(id -nu)" if command -v podman; then podman system info > /dev/null || podman system reset --force - PODMAN_MAJOR_VERSION=$(podman version -f json | jq -r '.Client.Version|split(".")[0]') - if [ "$PODMAN_MAJOR_VERSION" -lt 4 ]; then + if [ "$(podman version -f "{{ lt .Client.Version \"4\" }}")" = "true" ]; then echo "Found a very old podman; removing" command -v dnf && sudo dnf remove -y podman command -v apt && sudo apt remove -y podman @@ -27,8 +26,7 @@ function setup_container_runtime () { fi if command -v podman; then - PODMAN_MAJOR_VERSION=$(podman version -f json | jq -r '.Client.Version|split(".")[0]') - if [ "$PODMAN_MAJOR_VERSION" -ge 4 ]; then + if [ "$(podman version -f "{{ ge .Client.Version \"4\" }}")" = "true" ]; then PODMAN_DIR="$HOME/.local/share/containers" test -d "$PODMAN_DIR" && command -v restorecon && sudo restorecon -R -T0 -x "$PODMAN_DIR" PODMAN_STORAGE_DIR="$PODMAN_DIR/storage" @@ -37,7 +35,9 @@ function setup_container_runtime () { if [ "$(podman unshare du -s --block-size=1G "$PODMAN_STORAGE_DIR" | awk '{print $1}')" -ge 50 ]; then time podman image prune --filter=until="$((24*7))h" --all --force time podman system prune --force - test "$PODMAN_MAJOR_VERSION" -ge 5 && time podman system check --repair --quick + if [ "$(podman version -f "{{ ge .Client.Version \"5\" }}")" = "true" ]; then + time podman system check --repair --quick + fi fi fi fi