]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
setup_container_runtime.sh: Version comparison
authorZack Cerza <zack@cerza.org>
Wed, 10 Sep 2025 21:47:45 +0000 (15:47 -0600)
committerZack Cerza <zack@cerza.org>
Wed, 10 Sep 2025 21:48:48 +0000 (15:48 -0600)
... using Go templates instead of jq

Signed-off-by: Zack Cerza <zack@cerza.org>
scripts/setup_container_runtime.sh

index a62a53db162f1415f07e800e059b01271d508a16..14087eedd4e91e5823c48153be36dcd6d9a3f323 100755 (executable)
@@ -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