From 58705e4ed5a87040592cc7eb2b0ccb499f2d91cd Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 24 May 2024 14:41:03 -0400 Subject: [PATCH] Support podman in `make dev-tor` Unfortunately `podman volume` and `docker volume` are not identical, podman will (sensibly) error if you try to create a volume that already exists unless you pass `--ignore`, which docker doesn't support and is only in podman 4.4+. So we check with `$DOCKER_BIN inspect` first and only create the volume if necessary. And apply the same changes to `make clean` as well. Co-authored-by: deeplow --- devops/clean | 12 ++++++++++-- securedrop/bin/dev-shell | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/devops/clean b/devops/clean index ce7be26db6..f49e2b9aba 100755 --- a/devops/clean +++ b/devops/clean @@ -5,6 +5,14 @@ set -e set -u +USE_PODMAN="${USE_PODMAN:-}" + +# Allow opting into using podman with USE_PODMAN=1 +if [[ -n "${USE_PODMAN}" ]]; then + DOCKER_BIN="podman" +else + DOCKER_BIN="docker" +fi function remove_unwanted_files() { @@ -37,8 +45,8 @@ function remove_unwanted_files() { build/*.deb # Remove any Onion URL from make dev-tor - if docker volume inspect sd-onion-services > /dev/null; then - docker volume remove sd-onion-services + if $DOCKER_BIN volume inspect sd-onion-services > /dev/null; then + $DOCKER_BIN volume remove sd-onion-services fi # Remove extraneous copies of the git repos, pulled in diff --git a/securedrop/bin/dev-shell b/securedrop/bin/dev-shell index 35caccce99..8758dc7420 100755 --- a/securedrop/bin/dev-shell +++ b/securedrop/bin/dev-shell @@ -116,7 +116,7 @@ function docker_run() { if [ -n "${USE_TOR:-}" ]; then # Mount persistent onion services - docker volume create sd-onion-services + $DOCKER_BIN volume inspect sd-onion-services -f " " || $DOCKER_BIN volume create sd-onion-services DOCKER_RUN_ARGUMENTS="${DOCKER_RUN_ARGUMENTS} --volume sd-onion-services:/var/lib/tor/services" fi