From 62adeb2008c88e343e59fbd2a47cfe9e990f3245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Mon, 24 Nov 2025 14:49:56 -0500 Subject: [PATCH] prepare release --- Makefile | 30 +++++++++++++++++++++++++----- src/{ => bin}/zvirt | 4 ++-- src/lib/{ => zvirt}/core.sh | 0 test/e2e/zvirt.bats | 4 ++-- test/unit/core.bats | 2 +- test/unit/usage.bats | 2 +- 6 files changed, 31 insertions(+), 11 deletions(-) rename src/{ => bin}/zvirt (95%) rename src/lib/{ => zvirt}/core.sh (100%) diff --git a/Makefile b/Makefile index 36436a5..41aa24b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ -.PHONY: all test unit-test syntax-test e2e-test lint clean prerequisites +PREFIX ?= /usr/local +.PHONY: all test unit-test syntax-test e2e-test lint clean prerequisites install -all: syntax-test unit-test lint +all: syntax-test unit-test e2e-test lint install syntax-test: @echo "Running syntax tests..." @@ -14,13 +15,32 @@ prerequisites: unit-test: prerequisites @echo "Running unit tests..." - @LANG=LC_ALL=C BATS_LIB_PATH=$(PWD)/test/test_helper bats test/unit + @LANG=C LC_ALL=C BATS_LIB_PATH=$(PWD)/test/test_helper bats test/unit e2e-test: prerequisites @echo "Running end-to-end tests..." - @LANG=LC_ALL=C BATS_LIB_PATH=$(PWD)/test/test_helper bats test/e2e + @LANG=C LC_ALL=C BATS_LIB_PATH=$(PWD)/test/test_helper bats test/e2e + +install: + @echo "Installing zvirt..." + @install -d $(PREFIX)/lib/zvirt + @install -m 755 src/bin/zvirt $(PREFIX)/bin/zvirt + @install -m 644 src/lib/zvirt/core.sh $(PREFIX)/lib/zvirt/core.sh + +uninstall: + @echo "Uninstalling zvirt..." + @rm -f $(PREFIX)/bin/zvirt + @rm -rf $(PREFIX)/lib/zvirt + +release: + @echo "Creating release tarball..." + @set -Eeuo pipefail; VERSION=$$(git describe --tags --abbrev=0); tar --exclude-vcs --exclude='*.swp' -czf zvirt-$$VERSION.tar.gz --transform "s|^src|zvirt-$$VERSION|" src + +install-release: + @echo "Installing zvirt from release tarball..." + @set -Eeuo pipefail; VERSION=$$(git describe --tags --abbrev=0); tar -xvzf zvirt-$$VERSION.tar.gz --strip-components=1 -C $(PREFIX) clean: lint: @echo "Linting..." - @shellcheck src/zvirt src/lib/*.sh + @shellcheck src/bin/zvirt src/lib/zvirt/*.sh diff --git a/src/zvirt b/src/bin/zvirt similarity index 95% rename from src/zvirt rename to src/bin/zvirt index 7142ee1..866d701 100755 --- a/src/zvirt +++ b/src/bin/zvirt @@ -30,8 +30,8 @@ export LANG=C export LC_ALL=C # Load core library -script_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" -source "$script_dir/lib/core.sh" +script_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")/../")" +source "$script_dir/lib/zvirt/core.sh" # Parse command line arguments and act accordingly init_global_variables diff --git a/src/lib/core.sh b/src/lib/zvirt/core.sh similarity index 100% rename from src/lib/core.sh rename to src/lib/zvirt/core.sh diff --git a/test/e2e/zvirt.bats b/test/e2e/zvirt.bats index c7840f4..b357bf5 100644 --- a/test/e2e/zvirt.bats +++ b/test/e2e/zvirt.bats @@ -8,10 +8,10 @@ setup() { export LANG=C LC_ALL=C zvirt () { - "${BATS_TEST_DIRNAME}/../../src/zvirt" "$@" + "${BATS_TEST_DIRNAME}/../../src/bin/zvirt" "$@" } - declare -g e2e_test_enable_debug=0 + declare -g e2e_test_enable_debug=1 e2e_test_debug_log(){ if [ "$e2e_test_enable_debug" -eq 1 ]; then echo "$@" >&3 diff --git a/test/unit/core.bats b/test/unit/core.bats index 2b9bbe3..0cb4077 100644 --- a/test/unit/core.bats +++ b/test/unit/core.bats @@ -8,7 +8,7 @@ setup() { # Load the core library and export its functions local fn_before="$(declare -F | cut -d ' ' -f 3 | sort)" set -Eeuo pipefail - source "${BATS_TEST_DIRNAME}/../../src/lib/core.sh" + source "${BATS_TEST_DIRNAME}/../../src/lib/zvirt/core.sh" local fn_after="$(declare -F | cut -d ' ' -f 3 | sort)" declare -a zvirt_fn=( $(comm -13 <(echo "$fn_before") <(echo "$fn_after")) ) for fn in "${zvirt_fn[@]}"; do diff --git a/test/unit/usage.bats b/test/unit/usage.bats index e22dc35..65b02f0 100644 --- a/test/unit/usage.bats +++ b/test/unit/usage.bats @@ -5,7 +5,7 @@ setup() { bats_load_library 'bats-assert' set -Eeuo pipefail - source "${BATS_TEST_DIRNAME}/../../src/lib/core.sh" + source "${BATS_TEST_DIRNAME}/../../src/lib/zvirt/core.sh" function call_parse_args () { init_global_variables