myos/make/common.mk

83 lines
2.4 KiB
Makefile
Raw Normal View History

2021-02-09 17:05:00 +01:00
##
2021-06-09 00:44:36 +02:00
# COMMON
# target $(APP): Call update-app
.PHONY: $(APP)
$(APP): APP_DIR := $(RELATIVE)$(APP)
$(APP): myos-user
2021-06-09 00:44:36 +02:00
$(call update-app)
2021-06-07 22:39:57 +02:00
# target install-app install-apps: Call install-app for each ARGS
.PHONY: install-app install-apps
install-app install-apps: myos-user install-app-required
2021-06-07 22:39:57 +02:00
$(foreach url,$(ARGS),$(call install-app,$(url)))
2021-06-09 00:44:36 +02:00
# target install-app-required: Call install-app for each APP_REQUIRED
.PHONY: install-app-required
install-app-required: myos-user
2021-06-09 00:44:36 +02:00
$(foreach url,$(APP_REQUIRED),$(call install-app,$(url)))
2021-06-16 13:19:52 +02:00
# target install-bin-%; Call ansible-run-localhost when bin % is not available
.PHONY: install-bin-%
install-bin-%:;
$(if $(shell type $* 2>/dev/null),,$(call make,ansible-run-localhost))
2021-06-09 00:44:36 +02:00
# target $(SHARED): Create SHARED folder
$(SHARED):
2021-06-12 03:13:01 +02:00
$(RUN) mkdir -p $(SHARED)
2021-06-07 22:39:57 +02:00
2021-06-02 00:54:33 +02:00
# target update-apps: Call update-app target for each APPS
2021-06-01 00:52:21 +02:00
.PHONY: update-apps
update-apps:
$(foreach app,$(APPS),$(call make,update-app APP_NAME=$(app)))
2021-05-31 22:29:12 +02:00
2021-06-02 00:54:33 +02:00
# target update-app: Fire update-app-% for APP_NAME
2021-06-01 00:52:21 +02:00
.PHONY: update-app
2021-06-02 00:54:33 +02:00
update-app: update-app-$(APP_NAME) ;
2021-06-01 00:52:21 +02:00
2021-06-09 00:44:36 +02:00
# target update-app-%: Fire %
2021-06-01 00:52:21 +02:00
.PHONY: update-app-%
2021-06-09 00:44:36 +02:00
update-app-%: % ;
2021-06-01 00:52:21 +02:00
2021-06-09 03:41:47 +02:00
# target update-config: Update config files
2021-06-09 00:44:36 +02:00
.PHONY: update-config
update-config: myos-user
2021-06-09 03:41:47 +02:00
$(call update-app,$(CONFIG_REPOSITORY),$(CONFIG))
2021-05-31 22:29:12 +02:00
2021-06-02 00:54:33 +02:00
# target update-hosts: Update /etc/hosts
# on local host
## it reads .env files to extract applications hostnames and add it to /etc/hosts
2021-02-09 17:05:00 +01:00
.PHONY: update-hosts
update-hosts:
2021-06-14 12:52:48 +02:00
ifneq (,$(filter $(ENV),local))
2021-06-16 13:19:52 +02:00
cat .env */.env 2>/dev/null |grep -Eo 'urlprefix-[^/]+' |sed 's/urlprefix-//' |while read host; do \
grep $$host /etc/hosts >/dev/null 2>&1 || { \
printf "Adding $$host to /etc/hosts\n"; \
printf "127.0.0.1 $$host\n" |$(RUN) sudo tee -a /etc/hosts >/dev/null; \
}; \
done
2021-02-09 17:05:00 +01:00
endif
2021-06-02 00:54:33 +02:00
# target update-remote-%: fetch git remote %
2021-02-09 17:05:00 +01:00
.PHONY: update-remote-%
update-remote-%: myos-user
2021-06-16 13:19:52 +02:00
$(RUN) git fetch --prune --tags $*
2021-02-09 17:05:00 +01:00
2021-06-02 00:54:33 +02:00
# target update-remotes: fetch all git remotes
2021-05-31 22:29:12 +02:00
.PHONY: update-remotes
update-remotes: myos-user
2021-06-16 13:19:52 +02:00
$(RUN) git fetch --all --prune --tags
2021-05-31 22:29:12 +02:00
2021-06-02 00:54:33 +02:00
# target update-upstream: fetch git remote upstream
2021-02-09 17:05:00 +01:00
.PHONY: update-upstream
update-upstream: myos-user .git/refs/remotes/upstream/master
2021-06-16 13:19:52 +02:00
$(RUN) git fetch --prune --tags upstream
2021-02-09 17:05:00 +01:00
2021-06-16 13:19:52 +02:00
# target .git/refs/remotes/upstream/master: add git upstream APP_UPSTREAM_REPOSITORY
2021-06-09 00:44:36 +02:00
.git/refs/remotes/upstream/master:
2021-06-16 13:19:52 +02:00
$(RUN) git remote add upstream $(APP_UPSTREAM_REPOSITORY)
2021-06-01 01:50:11 +02:00
2021-06-02 00:54:33 +02:00
# target shared: Fire SHARED
2021-06-01 01:50:11 +02:00
.PHONY: update-shared
update-shared: $(SHARED)