From d7a9b8115f9df96304b9a6212dffb4d49e0d2d94 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Fri, 26 Jan 2024 16:12:45 -0500 Subject: [PATCH] fix: Install script not working as intended (#15) Related to https://github.com/blue-build/github-action/issues/5 --- README.md | 2 +- install.sh | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5bb4d46..39f82d7 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ cargo install --locked blue-build This will install the binary on your system in `/usr/local/bin`. This is only a `linux-gnu` version. ```bash -podman run --rm ghcr.io/blue-build/cli:latest-installer | sudo bash +podman run --rm ghcr.io/blue-build/cli:latest-installer | bash ``` ## How to use diff --git a/install.sh b/install.sh index 8fe7ed7..b1ca3c5 100755 --- a/install.sh +++ b/install.sh @@ -2,29 +2,39 @@ set -euo pipefail +# We use sudo for podman so that we can copy directly into /usr/local/bin + function cleanup() { echo "Cleaning up image" - podman stop -i -t 0 blue-build-installer + sudo podman stop -i -t 0 blue-build-installer sleep 2 - podman image rm ghcr.io/blue-build/cli:latest-installer + sudo podman image rm ghcr.io/blue-build/cli:latest-installer } -podman pull ghcr.io/blue-build/cli:latest-installer +trap cleanup SIGINT -podman run -d --rm --name blue-build-installer ghcr.io/blue-build/cli:latest-installer tail -f /dev/null +sudo podman run \ + --pull always \ + --replace \ + --detach \ + --rm \ + --name blue-build-installer \ + ghcr.io/blue-build/cli:latest-installer \ + tail -f /dev/null set +e -podman cp blue-build-installer:/out/bb /usr/local/bin/bb +sudo podman cp blue-build-installer:/out/bb /usr/local/bin/bb RETVAL=$? set -e -if [ -n $RETVAL ]; then +if [ $RETVAL != 0 ]; then cleanup - echo "Failed to copy file, try:" - printf "\tpodman run --rm ghcr.io/blue-build/cli:latest-installer | sudo bash\n" + echo "Failed to copy file" exit 1 else + # sudo mv bb /usr/local/bin/ + echo "Finished! BlueBuild has been installed at /usr/local/bin/bb" cleanup fi