.PHONY: all
all:
	@echo
	@echo "For initial setup, run"
	@echo "  sudo ./initial-setup.sh"
	@echo
	@echo "Or run borg commands with e.g.:"
	@echo "  ./borg.sh info"
	@echo "  ./borg.sh list"
	@echo

.PHONY: ctrl
ctrl: test-backup

.venv:
	mkdir .venv
	pipenv install --dev

.PHONY: test-backup
test-backup: .venv
	.venv/bin/mypy backup.py
	./backup.py -n

.PHONY: test-setup
test-setup:
	shellcheck -f gcc initial-setup.sh
	rm -rf /tmp/test-borg
	mkdir /tmp/test-borg
	git clone . /tmp/test-borg
	#: "normally this would be a git clone, but we want the working tree..."
	#git ls-files -z | tar --null -T - -cf - | tar -C /tmp/test-borg -xvf -
	/tmp/test-borg/initial-setup.sh

# Pull master and rebase "setup-$HOSTNAME" branch onto it
.PHONY: rebase
rebase:
	git checkout master
	git pull
	git checkout -
	git rebase master
	systemctl daemon-reload

.PHONY: clean
clean:
	rm -f README.html
