From 9575e03dc9f0d2848cb51c967fbeeb486e4915e8 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 27 Mar 2024 16:13:17 +0100 Subject: [PATCH] board/common: fix container upgrde for oci-archive:/ images Add exception for local images, the "pull" step must be handled by the operator, i.e., wget of the latest image to the same location as set up in the image configuration, e.g., for oci-archive:/tmp/foo.tar.gz that /tmp/foo.tar.gz exists when issuing the upgrade command. Fixes #368 Signed-off-by: Joachim Wiberg --- board/common/rootfs/usr/sbin/container | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/board/common/rootfs/usr/sbin/container b/board/common/rootfs/usr/sbin/container index d5485600..cb531933 100755 --- a/board/common/rootfs/usr/sbin/container +++ b/board/common/rootfs/usr/sbin/container @@ -567,8 +567,14 @@ case $cmd in echo "No such container ($1), or invalid ImageName. Cannot upgrade." exit 1; fi - podman stop "$1" - podman pull "$img" || (echo "Failed fetching $img, check your network (settings)."; exit 1) + if echo "$img" | grep -Eq '^localhost/'; then + # Likely an OCI archive, or local directory, assume user has updated image. + file=$(awk '{s=$NF} END{print s}' "/var/lib/containers/active/${1}.sh") + echo "Upgrading container ${1} with local archive: $file ..." + else + podman stop "$1" + podman pull "$img" || (echo "Failed fetching $img, check your network (settings)."; exit 1) + fi "/var/lib/containers/active/${1}.sh" || (echo "Failed recreating container $1"; exit 1) ;; volume)