agaric-coop/Makefile

49 lines
1.6 KiB
Makefile
Raw Normal View History

2019-01-22 16:55:30 +00:00
# Identify tasks which do not have output files:
.PHONY: help synclivetotest
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
# Perl to convert target docs (following ##@).
# Example:
# mytarget: ##@group description
# Group items under @group in output,
# And show target<tab>description
HELPME = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (20 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }
# Should always be the first target (as this will run with just `make`):
help: ##@Targets Show this text (or just run make)
@perl -e '$(HELPME)' Makefile
# Configure sync'
ALIAS_LIVE := @live.live
ALIAS_TEST := @test.test
SRV_TEST := root@elizabeth.mayfirst.org
SRV_LIVE := $(SRV_TEST)
2019-02-20 20:59:47 +00:00
FILES_LIVE := /home/agaric_live/files
FILES_TEST := /home/agaric_test/files
2019-01-22 16:55:30 +00:00
ECHO := $(if $(TEST),@echo)
synclivetotest: ##@Targets Sync live environment to test (pass TEST=true to echo commands)
2019-01-22 16:55:30 +00:00
$(ECHO) drush -y $(ALIAS_TEST) sql-drop
$(ECHO) drush -y sql-sync $(ALIAS_LIVE) $(ALIAS_TEST)
ifeq ($(SRV_TEST), $(SRV_LIVE))
$(ECHO) ssh -A $(SRV_LIVE) rsync -rz --stats --exclude styles \
--exclude css --exclude js $(FILES_LIVE) \
--delete ${FILES_TEST}
else
$(ECHO) drush -y sync $(ALIAS_LIVE)/public/%files $(ALIAS_TEST)/public/%files
endif