From 7d52a8388479bc66cbf2b902a2c0823717166de2 Mon Sep 17 00:00:00 2001 From: George Rawlinson Date: Thu, 22 Jul 2021 09:16:41 +0000 Subject: [PATCH] build: add Makefile --- Makefile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ba69e49 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +# Terminal Colours +RED?=$(shell tput setaf 1) +GREEN?=$(shell tput setaf 2) +YELLOW?=$(shell tput setaf 3) +BLUE?=$(shell tput setaf 4) +BOLD?=$(shell tput bold) +RST?=$(shell tput sgr0) + +# Local Repository +REPO_NAME=grawlinson +REPO_PATH=/var/lib/repo/${REPO_NAME} + +# Remote Repository +REMOTE_USER=$(shell pass rsyncd/mirror-${REPO_NAME}-user) +REMOTE_HOST=$(shell pass rsyncd/mirror-${REPO_NAME}-host) +REMOTE_PATH=${REPO_NAME} +RSYNC_OPTS=-lrhvPt --delete +RSYNC_PASSWORD=$(shell pass rsyncd/mirror-${REPO_NAME}) + +##@ Package +.PHONY: check +check: ## Check for package updates + @echo "$(BOLD)$(GREEN)[*] $(RST)$(BOLD)Checking for package updates…$(RST)" + @nvchecker -c .repo/nvchecker.toml + @nvtake -c .repo/nvchecker.toml --all + +##@ Repository + +.PHONY: sync +sync: push ## An alias for push + +.PHONY: pull +pull: ## Sync remote repository with local repository + @echo "$(BOLD)$(GREEN)[*] $(RST)$(BOLD)Syncing remote with local repository…$(RST)" + @RSYNC_PASSWORD=$(RSYNC_PASSWORD) rsync $(RSYNC_OPTS) rsync://$(REMOTE_USER)@$(REMOTE_HOST)/$(REMOTE_PATH) $(REPO_PATH)/ + +.PHONY: push +push: ## Sync local repository with remote repository + @echo "$(BOLD)$(GREEN)[*] $(RST)$(BOLD)Syncing local with remote repository…$(RST)" + @RSYNC_PASSWORD=$(RSYNC_PASSWORD) rsync $(RSYNC_OPTS) $(REPO_PATH)/ rsync://$(REMOTE_USER)@$(REMOTE_HOST)/$(REMOTE_PATH) + +##@ Utility +.DEFAULT_GOAL = help +.PHONY: help +help: ## Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n $(YELLOW)make$(RST) $(BLUE)command$(RST)\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " $(BLUE)%-15s$(RST) %s\n", $$1, $$2 } /^##@/ { printf "\n$(BOLD)%s$(RST)\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +rewrite: ## Rewrite .gitmodules + @.repo/rewrite-gitmodules +