netoik-cicd/Makefile

100 lines
2.6 KiB
Makefile
Raw Permalink Normal View History

2023-02-18 12:49:35 +00:00
NAME = netoik-cicd
VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g")
TEMP_DIR = "${PWD}/.temp"
2023-02-18 12:49:35 +00:00
RPM_SOURCEDIR = $(shell rpm --eval "%{_sourcedir}")
SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}")
UNITDIR = $(shell rpm --eval "%{_unitdir}")
BINDIR = $(shell rpm --eval "%{_bindir}")
RUNDIR = $(shell rpm --eval "%{_rundir}")
2023-02-18 12:49:35 +00:00
TMPDIR = $(shell rpm --eval "%{_tmppath}")
.PHONY: build
build: bin/$(NAME)-deployer bin/$(NAME)-runner bin/$(NAME)-pipeline
2023-02-18 12:49:35 +00:00
bin/$(NAME)-deployer: src/deployer.sh
install -D --no-target-directory "$<" "$@"
2023-02-18 12:49:35 +00:00
bin/$(NAME)-runner: src/runner.sh
install -D --no-target-directory "$<" "$@"
bin/$(NAME)-pipeline: src/pipeline.sh
install -D --no-target-directory "$<" "$@"
.PHONY: clean
clean:
rm --recursive --force ./bin
2023-02-18 12:49:35 +00:00
.PHONY: name
name:
@echo "$(NAME)"
.PHONY: version
version:
@echo "$(VERSION)"
$(RPM_SOURCEDIR)/$(NAME)-%.tar.gz: *
git archive --format=tar.gz \
--output="$@" \
--prefix="$(NAME)-$(VERSION)/" \
--worktree-attributes \
--verbose \
2023-05-02 14:39:39 +00:00
HEAD
2023-02-18 12:49:35 +00:00
.PHONY: tarball
tarball: $(RPM_SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
.PHONY: install
install: conf/*.sample systemd/*.service bin/*
install -D \
--no-target-directory \
"conf/$(NAME).conf.sample" \
"$(DESTDIR)$(SYSCONFDIR)/$(NAME)/$(NAME).conf"
install -D \
--target-directory="$(DESTDIR)$(SYSCONFDIR)/$(NAME)" \
"conf/$(NAME).conf.sample"
install -D \
--no-target-directory \
conf/errors.conf.sample \
"$(DESTDIR)$(SYSCONFDIR)/$(NAME)/errors.conf"
install -D \
--target-directory="$(DESTDIR)$(SYSCONFDIR)/$(NAME)" \
conf/errors.conf.sample
install -D \
--no-target-directory \
"systemd/deployer.service" \
"$(DESTDIR)$(UNITDIR)/$(NAME)-deployer.service"
install -D \
--no-target-directory \
"systemd/runner.service" \
"$(DESTDIR)$(UNITDIR)/$(NAME)-runner.service"
install -D \
--target-directory="$(DESTDIR)$(BINDIR)" \
"bin/$(NAME)-deployer"
install -D \
--target-directory="$(DESTDIR)$(BINDIR)" \
"bin/$(NAME)-runner"
install -D \
--target-directory="$(DESTDIR)$(BINDIR)" \
"bin/$(NAME)-pipeline"
install --directory "$(DESTDIR)$(RUNDIR)/$(NAME)/deployer"
install --directory "$(DESTDIR)$(RUNDIR)/$(NAME)/runner"
install --directory "$(DESTDIR)$(RUNDIR)/$(NAME)/pipeline"
install --directory "$(DESTDIR)$(RUNDIR)/$(NAME)/pids"
install --directory "$(DESTDIR)$(TMPDIR)/$(NAME)/repositories"
.PHONY: check_format
check_format:
shfmt --diff ./src ./tests
.PHONY: check_linting
check_linting:
shfmt --find ./src ./tests | while read f; do bash -o noexec $$f; done
shfmt --find ./src ./tests | while read f; do \
shellcheck --external-sources $$f; done
.PHONY: unit_test
unit_test:
bats ./tests