|
|
@ -1,5 +1,6 @@ |
|
|
PREFIX ?= /usr/local |
|
|
PREFIX ?= /usr/local |
|
|
.PHONY: all test unit-test syntax-test e2e-test lint clean prerequisites install uninstall release tarball install-tarball |
|
|
.PHONY: all test unit-test syntax-test e2e-test lint clean prerequisites install uninstall release tarball install-tarball srpm rpm |
|
|
|
|
|
VERSION := $(shell git describe --tags --abbrev=0) |
|
|
|
|
|
|
|
|
all: syntax-test lint unit-test e2e-test release |
|
|
all: syntax-test lint unit-test e2e-test release |
|
|
|
|
|
|
|
|
@ -14,6 +15,7 @@ prerequisites: |
|
|
@/bin/bash -Eeuo pipefail -c 'if ! yq --version &>/dev/null; then dnf install -y yq; fi' |
|
|
@/bin/bash -Eeuo pipefail -c 'if ! yq --version &>/dev/null; then dnf install -y yq; fi' |
|
|
@/bin/bash -Eeuo pipefail -c 'if ! shellcheck --version &>/dev/null; then dnf install -y shellcheck; fi' |
|
|
@/bin/bash -Eeuo pipefail -c 'if ! shellcheck --version &>/dev/null; then dnf install -y shellcheck; fi' |
|
|
@/bin/bash -Eeuo pipefail -c 'if ! gh --version &>/dev/null; then dnf install -y gh; fi' |
|
|
@/bin/bash -Eeuo pipefail -c 'if ! gh --version &>/dev/null; then dnf install -y gh; fi' |
|
|
|
|
|
@/bin/bash -Eeuo pipefail -c 'if ! rpmbuild --version &>/dev/null; then dnf install -y rpm-build; fi' |
|
|
|
|
|
|
|
|
unit-test: prerequisites |
|
|
unit-test: prerequisites |
|
|
@echo "Running unit tests..." |
|
|
@echo "Running unit tests..." |
|
|
@ -25,7 +27,7 @@ e2e-test: prerequisites |
|
|
|
|
|
|
|
|
install: |
|
|
install: |
|
|
@echo "Installing zvirt..." |
|
|
@echo "Installing zvirt..." |
|
|
@install -d $(PREFIX)/lib/zvirt |
|
|
@install -d $(PREFIX)/lib/zvirt $(PREFIX)/bin |
|
|
@install -m 755 src/bin/zvirt $(PREFIX)/bin/zvirt |
|
|
@install -m 755 src/bin/zvirt $(PREFIX)/bin/zvirt |
|
|
@install -m 644 src/lib/zvirt/core.sh $(PREFIX)/lib/zvirt/core.sh |
|
|
@install -m 644 src/lib/zvirt/core.sh $(PREFIX)/lib/zvirt/core.sh |
|
|
|
|
|
|
|
|
@ -36,19 +38,32 @@ uninstall: |
|
|
|
|
|
|
|
|
tarball: |
|
|
tarball: |
|
|
@echo "Creating release tarball..." |
|
|
@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 |
|
|
@mkdir -p build |
|
|
|
|
|
@tar --exclude-vcs --exclude='*.swp' -czf build/zvirt-$(VERSION).tar.gz --transform "s|^src|zvirt-$(VERSION)|" src |
|
|
|
|
|
|
|
|
install-tarball: tarball |
|
|
install-tarball: tarball |
|
|
@echo "Installing zvirt from release tarball..." |
|
|
@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) |
|
|
@tar -xvzf build/zvirt-$(VERSION).tar.gz --strip-components=1 -C $(PREFIX) |
|
|
|
|
|
|
|
|
|
|
|
srpm: prerequisites tarball |
|
|
|
|
|
@echo "Creating SRPM..." |
|
|
|
|
|
@git ls-files | sed 's|^|./|' > build/filelist.txt |
|
|
|
|
|
@mkdir -p build/zvirt-$(VERSION)/SOURCES |
|
|
|
|
|
@tar --verbatim-files-from --files-from=build/filelist.txt -cvzf build/zvirt-$(VERSION)/SOURCES/zvirt-$(VERSION).tar.gz --transform "s|^./|zvirt-$(VERSION)/|" |
|
|
|
|
|
@rpmbuild --define "_topdir $$(pwd)/build/zvirt-$(VERSION)" --define "version $(VERSION)" -ba packaging/zvirt.spec |
|
|
|
|
|
|
|
|
|
|
|
rpm: prerequisites |
|
|
|
|
|
@echo "Creating RPM..." |
|
|
|
|
|
@rpmbuild --define "_topdir $$(pwd)/build/zvirt-$(VERSION)" --define "version $(VERSION)" -bb packaging/zvirt.spec |
|
|
|
|
|
|
|
|
release: prerequisites tarball |
|
|
release: prerequisites tarball srpm rpm |
|
|
@echo "Creating GitHub release..." |
|
|
@echo "Creating GitHub release..." |
|
|
@set -Eeuo pipefail; VERSION=$$(git describe --tags --abbrev=0); gh release create $$VERSION zvirt-$$VERSION.tar.gz --draft --title "zvirt $$VERSION" --notes "Release $$VERSION of zvirt." |
|
|
@gh release create $(VERSION) build/zvirt-$(VERSION).tar.gz build/zvirt-$(VERSION)/RPMS/noarch/zvirt-$(VERSION)-*.rpm build/zvirt-$(VERSION)/SRPMS/zvirt-$(VERSION)-*.rpm --draft --title "zvirt $(VERSION)" --notes "Release $(VERSION) of zvirt." |
|
|
|
|
|
|
|
|
clean: |
|
|
clean: |
|
|
|
|
|
@echo "Cleaning up..." |
|
|
|
|
|
@rm -rf build/zvirt-* |
|
|
|
|
|
|
|
|
lint: prerequisites |
|
|
lint: prerequisites |
|
|
@echo "Linting..." |
|
|
@echo "Linting..." |
|
|
@cd src && shellcheck --severity=error bin/zvirt lib/zvirt/*.sh |
|
|
@cd src && shellcheck --severity=error bin/zvirt lib/zvirt/*.sh |
|
|
|