-
Notifications
You must be signed in to change notification settings - Fork 64
/
Makefile
214 lines (157 loc) · 7.26 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
ifneq (,)
.error This Makefile requires GNU Make.
endif
# -------------------------------------------------------------------------------------------------
# Default configuration
# -------------------------------------------------------------------------------------------------
.PHONY: help lint lint-file lint-shell test clean _populate
SHELL := /bin/bash
TEMP = temp
SRC := $(TEMP)/source
DST := $(TEMP)/dest
FL_VERSION = 0.3
FL_IGNORES = .git/,.github/
# -------------------------------------------------------------------------------------------------
# Default targets
# -------------------------------------------------------------------------------------------------
help:
@echo
@echo "# -------------------------------------------------------------------- #"
@echo "# Linux timemachine Makefile #"
@echo "# -------------------------------------------------------------------- #"
@echo
@echo "install Install to /usr/local/bin/timemachine (requires root)"
@echo "uninstall Remove /usr/local/bin/timemachine (requires root)"
@echo
@echo "help Show this help"
@echo "lint Run shellcheck linting"
@echo "test Run integration test"
@echo
# -------------------------------------------------------------------------------------------------
# System targets
# -------------------------------------------------------------------------------------------------
install: timemachine
install -d /usr/local/bin
install -m 755 timemachine /usr/local/bin/timemachine
uninstall:
rm /usr/local/bin/timemachine
# -------------------------------------------------------------------------------------------------
# Lint targets
# -------------------------------------------------------------------------------------------------
lint: lint-file lint-shell
lint-file:
@echo "# -------------------------------------------------------------------- #"
@echo "# Lint files #"
@echo "# -------------------------------------------------------------------- #"
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORES)' --path .
# -------------------------------------------------------------------------------------------------
# Test targets
# -------------------------------------------------------------------------------------------------
lint-shell:
@echo "# -------------------------------------------------------------------- #"
@echo "# Lint shellcheck #"
@echo "# -------------------------------------------------------------------- #"
@docker run --rm -v $(PWD):/mnt koalaman/shellcheck:stable --shell=sh timemachine
test: test-local-default-abs-noslash-noslash
test: test-local-default-abs-noslash-slash
test: test-local-default-abs-slash-noslash
test: test-local-default-abs-slash-slash
test: test-local-default-rel-noslash-noslash
test: test-local-default-rel-noslash-slash
test: test-local-default-rel-slash-noslash
test: test-local-default-rel-slash-slash
test: test-local-no_perms
test: test-local-no_times
test: test-local-copy_links
test: test-local-crazy-filename-chars
test: test-local-crazy-pathname-chars
test: test-remote-default-abs
test: test-remote-default-rel
test: test-remote-ssh_1111_port-nouser
test: test-remote-ssh_1111_port-user
test: test-remote-ssh_22_port-nouser
test: test-remote-ssh_22_port-user
test: test-remote-ssh_def_port-nouser
test: test-remote-ssh_def_port-user
test: test-remote-ssh_config-default
test: test-remote-ssh_config-port_1111
test: test-remote-ssh_config-port_overwrite
test: test-remote-ssh_crazy-source-pathname-chars
test-local-default-abs-noslash-noslash:
./tests/01-run-local-default-abs-noslash-noslash.sh
test-local-default-abs-noslash-slash:
./tests/01-run-local-default-abs-noslash-slash.sh
test-local-default-abs-slash-noslash:
./tests/01-run-local-default-abs-slash-noslash.sh
test-local-default-abs-slash-slash:
./tests/01-run-local-default-abs-slash-slash.sh
test-local-default-rel-noslash-noslash:
./tests/02-run-local-default-rel-noslash-noslash.sh
test-local-default-rel-noslash-slash:
./tests/02-run-local-default-rel-noslash-slash.sh
test-local-default-rel-slash-noslash:
./tests/02-run-local-default-rel-slash-noslash.sh
test-local-default-rel-slash-slash:
./tests/02-run-local-default-rel-slash-slash.sh
test-local-no_perms:
./tests/03-run-local-no_perms.sh
test-local-no_times:
./tests/04-run-local-no_times.sh
test-local-copy_links:
./tests/05-run-local-copy_links.sh
test-local-crazy-filename-chars:
./tests/06-run-local-crazy-filename-chars.sh
test-local-crazy-pathname-chars:
./tests/06-run-local-crazy-pathname-chars.sh
test-remote-default-abs:
./tests/10-run-remote-default-abs.sh
test-remote-default-rel:
./tests/10-run-remote-default-rel.sh
test-remote-ssh_1111_port-nouser:
./tests/11-run-remote-ssh_port_1111-nouser.sh
test-remote-ssh_1111_port-user:
./tests/11-run-remote-ssh_port_1111-user.sh
test-remote-ssh_22_port-nouser:
./tests/11-run-remote-ssh_port_22-nouser.sh
test-remote-ssh_22_port-user:
./tests/11-run-remote-ssh_port_22-user.sh
test-remote-ssh_def_port-nouser:
./tests/11-run-remote-ssh_port_def-nouser.sh
test-remote-ssh_def_port-user:
./tests/11-run-remote-ssh_port_def-user.sh
test-remote-ssh_config-default:
./tests/12-run-remote-ssh_config-default.sh
test-remote-ssh_config-port_1111:
./tests/12-run-remote-ssh_config-port_1111.sh
test-remote-ssh_config-port_overwrite:
./tests/12-run-remote-ssh_config-port_overwrite.sh
test-remote-ssh_crazy-source-pathname-chars:
./tests/13-run-remote-crazy-source-pathname-chars.sh
# -------------------------------------------------------------------------------------------------
# Helper targets
# -------------------------------------------------------------------------------------------------
clean:
@rm -rf $(TEMP)
_populate: clean
@mkdir -p "$(DST)"
@mkdir -p "$(SRC)"
@echo "a" > "$(SRC)/a"
@echo "b" > "$(SRC)/b"
@echo "c" > "$(SRC)/c"
@chmod -w "$(SRC)/a"
@chmod +x "$(SRC)/b"
pull-docker-lint-file:
docker pull cytopia/file-lint:$(FL_VERSION)
pull-docker-lint-shell:
docker pull koalaman/shellcheck:stable
pull-docker-ssh-base:
docker pull debian:buster-slim
build-docker-ssh-server:
docker build -t cytopia/ssh-server -f "$(PWD)/tests/docker-ssh-server/Dockerfile" "$(PWD)/tests/docker-ssh-server"
build-docker-ssh-client:
docker build -t cytopia/ssh-client -f "$(PWD)/tests/docker-ssh-client/Dockerfile" "$(PWD)/tests/docker-ssh-client"