2022-10-08 19:37:22 +03:00
|
|
|
SRC_DIR := ./src
|
|
|
|
DOCS_DIR := ./docs
|
|
|
|
TESTS_DIR := ./tests
|
|
|
|
BUILD_DIR := ./dist
|
2022-05-14 00:20:02 +03:00
|
|
|
|
2022-10-08 19:37:22 +03:00
|
|
|
.PHONY: help tests manpages install uninstall fixpath
|
2022-05-14 00:20:02 +03:00
|
|
|
|
2022-10-09 03:29:35 +03:00
|
|
|
all: help
|
2022-08-13 19:35:11 +03:00
|
|
|
|
2022-05-14 00:20:02 +03:00
|
|
|
help:
|
2022-10-08 19:37:22 +03:00
|
|
|
@echo 'Usage: make TARGET'
|
|
|
|
@echo ' make prefix=/path install'
|
|
|
|
@echo ' make prefix=/path uninstall'
|
2022-05-14 00:20:02 +03:00
|
|
|
@echo
|
|
|
|
@echo Available targets:
|
|
|
|
@echo
|
2022-10-08 19:37:22 +03:00
|
|
|
@echo ' help print this help message'
|
|
|
|
@echo ' tests run tests from $(TESTS_DIR)'
|
|
|
|
@echo ' lint run shellcheck'
|
|
|
|
@echo ' manpages build manual pages from $(DOCS_DIR)'
|
2022-10-08 21:26:08 +03:00
|
|
|
@echo ' install install boring_backup with prefix'
|
|
|
|
@echo ' uninstall uninstall boring_backup with prefix'
|
2022-05-14 00:20:02 +03:00
|
|
|
@echo
|
2022-10-08 19:37:22 +03:00
|
|
|
@echo 'prefix examples: $$HOME/.local, /usr/local, /usr/bin'
|
|
|
|
@echo See README for more info.
|
2022-05-14 00:20:02 +03:00
|
|
|
|
2022-08-21 21:11:07 +03:00
|
|
|
tests:
|
2022-05-14 00:20:02 +03:00
|
|
|
# See bats(1), https://bats-core.readthedocs.io/en/latest/index.html
|
2022-08-21 21:11:07 +03:00
|
|
|
for test in $(TESTS_DIR)/*.bats; do \
|
2022-08-13 19:35:11 +03:00
|
|
|
bats --verbose-run --print-output-on-failure "$$test"; \
|
|
|
|
done
|
2022-05-14 00:20:02 +03:00
|
|
|
|
2022-05-14 20:06:20 +03:00
|
|
|
lint:
|
2022-10-08 21:26:08 +03:00
|
|
|
shellcheck $(SRC_DIR)/boring_backup
|
2022-08-21 21:11:07 +03:00
|
|
|
shellcheck $(SRC_DIR)/lib/*.sh
|
|
|
|
shellcheck $(SRC_DIR)/lib/handlers/sources/*.sh
|
|
|
|
shellcheck $(SRC_DIR)/lib/handlers/targets/*.sh
|
2022-05-14 20:06:20 +03:00
|
|
|
|
2022-10-08 19:37:22 +03:00
|
|
|
manpages:
|
|
|
|
mkdir -pv $(BUILD_DIR)/share/man/ru/man1
|
|
|
|
# See rst2man(1)
|
2022-08-13 19:35:11 +03:00
|
|
|
# https://docutils.sourceforge.io/docs/index.html
|
2022-10-08 21:26:08 +03:00
|
|
|
rst2man -v $(DOCS_DIR)/manpages/boring_backup.ru.1.rst \
|
|
|
|
> $(BUILD_DIR)/share/man/ru/man1/boring_backup.1
|
2022-08-13 19:35:11 +03:00
|
|
|
sed -e 's/.SH NAME/.SH ИМЯ/' \
|
|
|
|
-e 's/.SH AUTHOR/.SH АВТОРЫ/' \
|
|
|
|
-e 's/.SH COPYRIGHT/.SH АВТОРСКИЕ ПРАВА/' \
|
2022-10-08 21:26:08 +03:00
|
|
|
-i $(BUILD_DIR)/share/man/ru/man1/boring_backup.1
|
|
|
|
gzip -vf9 $(BUILD_DIR)/share/man/ru/man1/boring_backup.1
|
2022-05-14 00:20:02 +03:00
|
|
|
|
2022-10-08 19:37:22 +03:00
|
|
|
html: manpages
|
2022-10-08 21:26:08 +03:00
|
|
|
mkdir -p $(BUILD_DIR)/share/doc/boring_backup
|
|
|
|
zcat $(BUILD_DIR)/share/man/ru/man1/boring_backup.1.gz | \
|
2022-10-08 19:37:22 +03:00
|
|
|
groff -man -Kutf8 -Thtml \
|
2022-10-08 21:26:08 +03:00
|
|
|
> $(BUILD_DIR)/share/doc/boring_backup/boring_backup.1.html 2>/dev/null
|
2022-10-08 19:37:22 +03:00
|
|
|
rm -v grohtml-*.png
|
2022-08-21 21:11:07 +03:00
|
|
|
|
2022-10-09 03:29:35 +03:00
|
|
|
install: html
|
2022-10-08 19:37:22 +03:00
|
|
|
@echo prefix: $$prefix
|
2022-10-08 21:26:08 +03:00
|
|
|
install -Dm755 $(SRC_DIR)/boring_backup $$prefix/bin/boring_backup
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/lib.sh $$prefix/share/boring_backup/lib.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/backup.sh $$prefix/share/boring_backup/backup.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/common.sh $$prefix/share/boring_backup/common.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/source.sh $$prefix/share/boring_backup/source.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/uri.sh $$prefix/share/boring_backup/uri.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/handlers/sources/tar.sh $$prefix/share/boring_backup/handlers/sources/tar.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/handlers/sources/mysqldump.sh $$prefix/share/boring_backup/handlers/sources/mysqldump.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/handlers/sources/pg_dump.sh $$prefix/share/boring_backup/handlers/sources/pg_dump.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/handlers/targets/cp.sh $$prefix/share/boring_backup/handlers/targets/cp.sh
|
|
|
|
install -Dm644 $(SRC_DIR)/lib/handlers/targets/s3cmd.sh $$prefix/share/boring_backup/handlers/targets/s3cmd.sh
|
|
|
|
sed -e "s%LIBRARY=\"\$${LIBRARY:-.\/lib}\"%LIBRARY=\"\$${LIBRARY:-$$prefix\/share\/boring_backup}\"%" \
|
|
|
|
-i $$prefix/share/boring_backup/lib.sh \
|
|
|
|
-i $$prefix/bin/boring_backup
|
2022-10-09 03:29:35 +03:00
|
|
|
sed -e "s%log_file=\"\$${log_file:-.\/log.txt}\"%log_file=\"\$${log_file:-\/var\/log\/boring_backup.log}\"%g" \
|
|
|
|
-i $$prefix/bin/boring_backup
|
|
|
|
install -Dm664 $(SRC_DIR)/completion $$prefix/share/bash-completion/completions/boring_backup
|
2022-10-08 21:26:08 +03:00
|
|
|
install -Dm664 $(BUILD_DIR)/share/man/ru/man1/boring_backup.1.gz $$prefix/share/man/ru/man1/boring_backup.1.gz
|
2022-10-09 03:29:35 +03:00
|
|
|
install -Dm644 $(BUILD_DIR)/share/doc/boring_backup/boring_backup.1.html $$prefix/share/doc/boring_backup/boring_backup.1.html
|
2022-08-21 21:11:07 +03:00
|
|
|
|
|
|
|
uninstall:
|
2022-10-08 19:37:22 +03:00
|
|
|
@echo prefix: $$prefix
|
2022-10-08 21:26:08 +03:00
|
|
|
rm $$prefix/bin/boring_backup
|
|
|
|
rm $$prefix/share/boring_backup/lib.sh
|
|
|
|
rm $$prefix/share/boring_backup/backup.sh
|
|
|
|
rm $$prefix/share/boring_backup/common.sh
|
|
|
|
rm $$prefix/share/boring_backup/source.sh
|
|
|
|
rm $$prefix/share/boring_backup/uri.sh
|
|
|
|
rm $$prefix/share/boring_backup/handlers/sources/tar.sh
|
|
|
|
rm $$prefix/share/boring_backup/handlers/sources/mysqldump.sh
|
|
|
|
rm $$prefix/share/boring_backup/handlers/sources/pg_dump.sh
|
|
|
|
rm $$prefix/share/boring_backup/handlers/targets/cp.sh
|
|
|
|
rm $$prefix/share/boring_backup/handlers/targets/s3cmd.sh
|
|
|
|
rm -rv $$prefix/share/boring_backup
|
|
|
|
rm $$prefix/share/man/ru/man1/boring_backup.1.gz
|
2022-10-09 03:29:35 +03:00
|
|
|
rm $$prefix/share/doc/boring_backup/boring_backup.1.html
|
|
|
|
rm $$prefix/share/bash-completion/completions/boring_backup
|
2022-08-21 21:11:07 +03:00
|
|
|
|
2022-10-08 19:37:22 +03:00
|
|
|
fixpath:
|
2022-10-08 21:26:08 +03:00
|
|
|
# Set boring_backup library path
|
2022-10-08 19:37:22 +03:00
|
|
|
@echo prefix: $$prefix
|
|
|
|
@echo path: $$path
|
2022-10-09 03:29:35 +03:00
|
|
|
sed -e "s%LIBRARY=\"\$${LIBRARY:-$$prefix\/share\/boring_backup}\"%LIBRARY=\"\$${LIBRARY:-$$path}\"%" \
|
2022-10-08 21:26:08 +03:00
|
|
|
-i $$prefix/share/boring_backup/lib.sh \
|
|
|
|
-i $$prefix/bin/boring_backup
|
2022-10-09 03:29:35 +03:00
|
|
|
|
|
|
|
deb:
|
|
|
|
test -d $(BUILD_DIR) && rm -rf $(BUILD_DIR) || true
|
|
|
|
make prefix=$(BUILD_DIR)/usr install
|
|
|
|
make prefix=$(BUILD_DIR)/usr path=/usr/share/boring_backup fixpath
|
|
|
|
install -Dm644 control $(BUILD_DIR)/DEBIAN/control
|
|
|
|
install -Dm644 copyright $(BUILD_DIR)/DEBIAN/copyright
|
|
|
|
install -Dm644 CHANGELOG $(BUILD_DIR)/DEBIAN/changelog
|
|
|
|
rm -rfv $(BUILD_DIR)/share
|
|
|
|
mkdir -p debian
|
|
|
|
version=$$(src/boring_backup -V) && dpkg-deb --build $(BUILD_DIR) debian/boring-backup_$$version.deb
|