From a36a2b2705f432a883559db5943e2be27fb882b2 Mon Sep 17 00:00:00 2001 From: Joe Matthew Date: Fri, 9 Aug 2024 10:50:19 +0200 Subject: [PATCH] fix: clever installation of packages --- Dockerfile | 20 ++++++++++++++++---- Makefile | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2fa48ff..064d2bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,10 +38,22 @@ RUN apt-get update COPY --from=dev /app/dist/pantos-service-node_*.deb . RUN ARCH=$(dpkg --print-architecture) && \ - if [ -f ./*-signed.deb ]; then \ - apt-get install -y --no-install-recommends ./*_${ARCH}-signed.deb ./*_all-signed.deb; \ - else \ - apt-get install -y --no-install-recommends ./*.deb; \ + PKGS=$(ls ./*-signed.deb 2>/dev/null || ls ./*.deb) && \ + INSTALLED_COUNT=0 && \ + for pkg in $PKGS; do \ + if [ -f "$pkg" ]; then \ + PKG_ARCH=$(dpkg-deb --field "$pkg" Architecture) && \ + if [ "$PKG_ARCH" = "all" ] || [ "$PKG_ARCH" = "$ARCH" ]; then \ + apt-get install -f -y --no-install-recommends "$pkg" && \ + INSTALLED_COUNT=$((INSTALLED_COUNT + 1)); \ + else \ + echo "Skipping $pkg due to architecture mismatch"; \ + fi; \ + fi; \ + done && \ + if [ "$INSTALLED_COUNT" -eq 0 ]; then \ + echo "Error: No packages were installed" >&2; \ + exit 1; \ fi && \ rm -rf *.deb && \ apt-get clean && \ diff --git a/Makefile b/Makefile index 809e726..1e6cfe1 100644 --- a/Makefile +++ b/Makefile @@ -144,7 +144,7 @@ debian: dpkg-buildpackage -uc -us -g mkdir -p dist ARCHITECTURE=$$(dpkg --print-architecture); \ - mv ../$(debian_package) dist/panto-service-node_$(PANTOS_SERVICE_NODE_VERSION)_$${ARCHITECTURE}.deb + mv ../$(debian_package) dist/pantos-service-node_$(PANTOS_SERVICE_NODE_VERSION)_$${ARCHITECTURE}.deb .PHONY: debian-all debian-all: debian debian-full