-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathMakefile
107 lines (85 loc) · 4.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#######################################################################################################################
#
# Makefile for raspiBackup
#
# See http://www.linux-tips-and-tricks.de/raspiBackup for additional information
#
#######################################################################################################################
#
# Copyright (c) 2021-2024 framp at linux-tips-and-tricks dot de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.#
#
#######################################################################################################################
CURRENT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
PACKAGE_FILES = installation/install.sh installation/raspiBackupInstallUI.sh raspiBackup.sh extensions/raspiBackupSampleExtensions.tgz properties/raspiBackup.properties
PACKAGE_FILE_COLLECTIONS = config/*
PACKAGE_EXTENSION_DIRECTORY = extensions
PACKAGE_EXTENSION_FILES_PREFIX = raspiBackup_*
PACKAGE_EXTENSION_FILES = $(PACKAGE_EXTENSION_DIRECTORY)/$(PACKAGE_EXTENSION_FILES_PREFIX)
FILES_TO_SIGN = raspiBackup.sh raspiBackupInstallUI.sh
include $(CURRENT_DIR)/$(MAKEFILE).env
# Has to define following environment constants:
# 1) GITHUB_REPO - local directoy of github repo
# 2) LOCAL_REPO - local shadow repo
# 3) MASTER_BRANCH - should be master
# 4) BETA_BRANCH - should be beta
# 5) BUILD_LOCATION - local directory the code is built
# 6) DEPLOYMENT_LOCATION - directory the code is deployed
help: ## help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build: buildFiles
buildFiles: ## Build raspiBackup {BRANCH=<branchName>}
ifndef BUILD_LOCATION
$(error BUILD_LOCATION is not set)
endif
ifndef BRANCH
$(error BRANCH is not set)
endif
@echo "*** Building $(BRANCH) in $(BUILD_LOCATION) ***"
@$(foreach file, $(PACKAGE_FILES), rm -f $(file);)
@$(foreach file, $(wildcard $(PACKAGE_FILE_COLLECTIONS)), rm -f $(file);)
@$(foreach file, $(wildcard $(PACKAGE_EXTENSION_FILES)), rm -f $(file);)
@git checkout HEAD
@git checkout -f $(BRANCH)
@rm -f $(BUILD_LOCATION)/*
@$(foreach file, $(wildcard $(PACKAGE_FILE_COLLECTIONS)), cp -a $(file) $(BUILD_LOCATION)/$(notdir $(file));)
@cd $(PACKAGE_EXTENSION_DIRECTORY) && tar --owner=root --group =root -cvzf raspiBackupSampleExtensions.tgz $(PACKAGE_EXTENSION_FILES_PREFIX)
@$(foreach file, $(PACKAGE_FILES), cp -a $(file) $(BUILD_LOCATION)/$(notdir $(file));)
@rm $(PACKAGE_EXTENSION_DIRECTORY)/raspiBackupSampleExtensions.tgz
signFiles: # sign files
@$(foreach file, $(FILES_TO_SIGN), gpg --sign --default-key $(SIGNER_EMAIL) $(BUILD_LOCATION)/$(file);)
update: buildFiles ## Update one file {FILE=<filename>}
ifeq ("$(wildcard $(DEPLOYMENT_LOCATION))", "")
$(error Directory $(DEPLOYMENT_LOCATION) not mounted)
endif
@cp $(BUILD_LOCATION)/$(FILE) $(DEPLOYMENT_LOCATION)/$(notdir $(BUILD_LOCATION)/$(FILE)); echo "Updated $(FILE) on $(DEPLOYMENT_LOCATION)";
deploy: ## Deploy build {BRANCH=<branchName>}
ifndef DEPLOYMENT_LOCATION
$(error DEPLOYMENT_LOCATION is not set)
endif
ifndef BRANCH
$(error BRANCH is not set)
endif
@echo "*** Deploying $(BRANCH) in $(DEPLOYMENT_LOCATION) ***"
@$(foreach file, $(wildcard $(BUILD_LOCATION)/*), echo "Deploy $(file) "; cp $(file) $(DEPLOYMENT_LOCATION)/$(notdir $(file));)
syncLocal: ## Sync github to local shadow git
@$(foreach file, $(PACKAGE_FILES), echo "Copying $(file) "; cp -a $(GITHUB_REPO)/$(file) $(LOCAL_REPO)/$(file);)
@$(foreach file, $(wildcard $(PACKAGE_FILE_COLLECTIONS)), echo "Copying $(file) "; cp -a $(GITHUB_REPO)/$(file) $(LOCAL_REPO)/$(file);)
@$(foreach file, $(wildcard $(PACKAGE_EXTENSION_FILES)), echo "Copying $(file) "; cp -a $(GITHUB_REPO)/$(file) $(LOCAL_REPO)/$(file);)
syncRemote: ## Sync local git to github
@$(foreach file, $(PACKAGE_FILES), echo "Copying $(file) "; cp -a $(LOCAL_REPO)/$(file) $(GITHUB_REPO)/$(file) ;)
@$(foreach file, $(wildcard $(PACKAGE_FILE_COLLECTIONS)), echo "Copying $(file) "; cp -a $(LOCAL_REPO)/$(file) $(GITHUB_REPO)/$(file) ;)
@$(foreach file, $(wildcard $(PACKAGE_EXTENSION_FILES)), echo "Copying $(file) "; cp -a $(LOCAL_REPO)/$(file) $(GITHUB_REPO)/$(file) ;)