-
Notifications
You must be signed in to change notification settings - Fork 407
Expand file tree
/
Copy pathMakefile
More file actions
524 lines (481 loc) · 24.8 KB
/
Makefile
File metadata and controls
524 lines (481 loc) · 24.8 KB
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
F= files/docker/systemctl.py
ORIGYEAR=2016
BASEYEAR=2025
FOR=today
# 'make version FOR=yesterday' or 'make version DAY=0'
default: help nam ver
-include Make_detect_py.mk
UBUNTU=ubuntu:18.04
PYTHON2 = python2
PYTHON3 = python3
PYTHON39 = python$(PY39)
PYTHON_VERSION = 3.9
COVERAGE3 = $(PYTHON3) -m coverage
GIT=git
VERFILES = files/docker/systemctl3.py tests/*tests.py tests/*.dockerfile pyproject.toml
VV=-vv
version:
@ grep -l __version__ $(VERFILES) | { while read f; do : \
; B="$(BASEYEAR)"; C=$$B; test -z "$(ORIGYEAR)" || C="$(ORIGYEAR)" \
; Y=`date +%Y -d "$(FOR)"` ; X=$$(expr $$Y - $$B) \
; W=`date +%W -d "$(FOR)"` \
; D=`date +%u -d "$(FOR)"` ; sed -i \
-e "/^ *version = /s/[.]-*[0123456789][0123456789][0123456789]*/.$$X$$W$$D/" \
-e "/^ *__version__/s/[.]-*[0123456789][0123456789][0123456789]*\"/.$$X$$W$$D\"/" \
-e "/^ *__version__/s/[.]\\([0123456789]\\)\"/.\\1.$$X$$W$$D\"/" \
-e "/^ *__copyright__/s/(C) [0123456789]*-[0123456789]*/(C) $$C-$$Y/" \
-e "/^ *__copyright__/s/(C) [0123456789]* /(C) $$Y /" \
$$f; done; }
@ grep ^__version__ $(VERFILES)
@ grep ^version.= $(VERFILES)
@ $(GIT) add $(VERFILES) || true
@ ver=`sed -e '/^version *=/!d' -e 's/.*= *"//' -e 's/".*//' -e q pyproject.toml` \
; echo "# $(GIT) commit -m v$$ver"
nam: ; @ sed -e '/^name *=/!d' -e 's/.*= *"//' -e 's/".*//' -e q pyproject.toml
ver: ; @ sed -e '/^version *=/!d' -e 's/.*= *"//' -e 's/".*//' -e q pyproject.toml
help:
$(PYTHON3) files/docker/systemctl3.py help
.PHONY: build tests src files notes tmp
FUNCTEST_PY = tests/functests.py
FUNCTEST = $(PYTHON3) $(FUNCTEST_PY) $(FUNCTEST_OPTIONS)
EXECTEST_PY = tests/exectests.py
EXECTEST = $(PYTHON3) $(EXECTEST_PY) $(EXECTEST_OPTIONS)
DOCKTEST_PY = tests/docktests.py
DOCKTEST = $(PYTHON3) $(DOCKTEST_PY) $(TESTS_OPTIONS)
BUILD_PY = tests/buildtests.py
BUILD = $(PYTHON3) $(BUILD_PY) -C tests $(BUILD_OPTIONS)
# python2 is not available on standard Linux distros after 2024 (so these are obsolete make targets)
WITH2 = --python=/usr/bin/python2 --with=tmp/systemctl.py
WITH3 = --python=/usr/bin/python3 --with=files/docker/systemctl3.py
todo/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) --todo
15.6/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.6
15.5/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.5
15.4/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.4
15.2/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.2
15.1/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.1
15.0/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.0
42.3/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=opensuse:42.3
42.2/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=opensuse:42.2
24.04/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:24.04
22.04/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:22.04
20.04/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:20.04
19.10/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:19.10
18.04/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:18.04
16.04/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:16.04
9.4/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=almalinux:9.4
9.3/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=almalinux:9.3
9.1/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=almalinux:9.1
8.1/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=centos:8.1.1911
8.0/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=centos:8.0.1905
7.7/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=centos:7.7.1908
7.6/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=centos:7.6.1810
7.5/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=centos:7.5.1804
7.4/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=centos:7.4.1708
7.3/test_%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $(FORCE) --image=centos:7.3.1611
15.4/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.4 $(WITH2)
15.2/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.2 $(WITH2)
15.1/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.1 $(WITH2)
15.0/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=opensuse/leap:15.0 $(WITH2)
42.3/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=opensuse:42.3 $(WITH2)
42.2/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=opensuse:42.2 $(WITH2)
22.04/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:22.04 $(WITH2)
20.04/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:20.04 $(WITH2)
18.04/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:18.04 $(WITH2)
16.04/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=ubuntu:16.04 $(WITH2)
8.1/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=centos:8.1.1911 $(WITH2)
8.0/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=centos:8.0.1905 $(WITH2)
7.7/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=centos:7.7.1908 $(WITH2)
7.6/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=centos:7.6.1810 $(WITH2)
7.5/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=centos:7.5.1804 $(WITH2)
7.4/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=centos:7.4.1708 $(WITH2)
7.3/st_%: ; $(MAKE) 2 && $(DOCKTEST) "te$(notdir $@)" $(VV) $(FORCE) --image=centos:7.3.1611 $(WITH2)
# testbuilds run with a stripped systemctl.py variant to cover both python2/python3 example (meanwhile testing strip_python3 to work correctly)
builds testbuilds: ; $(MAKE) tmp/systemctl.py tmp/systemctl3.py; $(BUILD) $(VV) $V $E --systemctl=tmp/systemctl.py --systemctl3=tmp/systemctl3.py
build3 testonly3: ; $(BUILD) $(VV) $V $E # defaults to files/docker/systemctl3.py # skipping python2 tests and the stripping tool
local3: ; $(MAKE) builds3 E=--local
t_%: ; $(MAKE) $@/s
t_%/s: ; $(MAKE) tmp/systemctl.py tmp/systemctl3.py; $(BUILD) "tes$(dir $@)" $(VV) $V $E --systemctl=tmp/systemctl.py --systemctl3=tmp/systemctl3.py
t_%/9: ; $(BUILD) "tes$(dir $@)" $(VV) $V $E --python=$(PYTHON39)
t_%/3: ; $(BUILD) "tes$(dir $@)" $(VV) $V $E --python=python$(notdir $@)
t_%/3.6: ; $(BUILD) "tes$(dir $@)" $(VV) $V $E --python=python$(notdir $@)
t_%/3.11: ; $(BUILD) "tes$(dir $@)" $(VV) $V $E --python=python$(notdir $@)
t_%/3.12: ; $(BUILD) "tes$(dir $@)" $(VV) $V $E --python=python$(notdir $@)
# 'make test9' or 'make test_9*' if you want to testbuilds to use the unstripped python3 script (same as 'make build3')
LOCALPACKAGES=
ifeq ("$(wildcard /usr/lib/rpm/suse/macros)","/usr/lib/rpm/suse/macros")
ifeq ("$(wildcard /dock/docker-mirror-packages/opensuse.15.6.disk)","/dock/docker-mirror-packages/opensuse.15.6.disk")
LOCALPACKAGES=--local
endif
endif
ESTCOVERAGE=--coverage --coverage
st_1%: ; rm -rf tmp/tmp.t$(notdir $@); $(EXECTEST) "te$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep --python=$(PYTHON39)
st_2%: ; rm -rf tmp/tmp.t$(notdir $@); $(EXECTEST) "te$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep --python=$(PYTHON39)
st_3%: ; rm -rf tmp/tmp.t$(notdir $@); $(EXECTEST) "te$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep --python=$(PYTHON39)
st_4%: ; rm -rf tmp/tmp.t$(notdir $@); $(EXECTEST) "te$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep --python=$(PYTHON39)
st_5%: ; rm -rf tmp/tmp.t$(notdir $@); $(DOCKTEST) "te$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep --python=$(PYTHON39) $(LOCALPACKAGES)
st_6%: ; rm -rf tmp/tmp.t$(notdir $@); $(DOCKTEST) "te$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep --python=$(PYTHON39) $(LOCALPACKAGES)
st_7%: ; rm -rf tmp/tmp.t$(notdir $@); $(DOCKTEST) "te$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep --python=$(PYTHON39) $(LOCALPACKAGES)
st_8%: ; rm -rf tmp/tmp.t$(notdir $@); $(DOCKTEST) "te$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep --python=$(PYTHON39) $(LOCALPACKAGES)
est_1%: ; rm -rf tmp/tmp.t$(notdir $@); $(EXECTEST) "t$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep
est_2%: ; rm -rf tmp/tmp.t$(notdir $@); $(EXECTEST) "t$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep
est_3%: ; rm -rf tmp/tmp.t$(notdir $@); $(EXECTEST) "t$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep
est_4%: ; rm -rf tmp/tmp.t$(notdir $@); $(EXECTEST) "t$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep
est_5%: ; rm -rf tmp/tmp.t$(notdir $@); $(DOCKTEST) "t$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep $(LOCALPACKAGES)
est_6%: ; rm -rf tmp/tmp.t$(notdir $@); $(DOCKTEST) "t$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep $(LOCALPACKAGES)
est_7%: ; rm -rf tmp/tmp.t$(notdir $@); $(DOCKTEST) "t$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep $(LOCALPACKAGES)
est_8%: ; rm -rf tmp/tmp.t$(notdir $@); $(DOCKTEST) "t$(notdir $@)" $(VV) $V $(ESTCOVERAGE) --keep $(LOCALPACKAGES)
est_9%: ; $(MAKE) tmp/systemctl3.py; $(BUILD) "t$(notdir $@)" $(VV) $V --keep --systemctl3=tmp/systemctl3.py $(LOCALPACKAGES)
st_9%: ; $(MAKE) tmp/systemctl3.py; $(BUILD) "te$(notdir $@)" $(VV) $V --todo --systemctl3=tmp/systemctl3.py # stripped
test_0%: ; $(FUNCTEST) "$(notdir $@)" $(VV) $V
test_1%: ; $(EXECTEST) "$(notdir $@)" $(VV) $V
test_2%: ; $(EXECTEST) "$(notdir $@)" $(VV) $V
test_3%: ; $(EXECTEST) "$(notdir $@)" $(VV) $V
test_4%: ; $(EXECTEST) "$(notdir $@)" $(VV) $V
test_5%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $V
test_6%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $V
test_7%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $V
test_8%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $V
test_9%: ; $(MAKE) src/systemctl3.py; $(BUILD) "$(notdir $@)" $(VV) $V --systemctl3=src/systemctl3.py
real_1%: ; $(EXECTEST) "$(notdir $@)" $(VV) $V
real_2%: ; $(EXECTEST) "$(notdir $@)" $(VV) $V
real_3%: ; $(EXECTEST) "$(notdir $@)" $(VV) $V
real_4%: ; $(EXECTEST) "$(notdir $@)" $(VV) $V
real_5%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $V
real_6%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $V
real_7%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $V
real_8%: ; $(DOCKTEST) "$(notdir $@)" $(VV) $V
t0 test0: ; $(MAKE) test_0*
t1 test1: ; $(MAKE) test_1*
t2 test2: ; $(MAKE) test_2*
t3 test3: ; $(MAKE) test_3*
t4 test4: ; $(MAKE) test_4*
t9 test9: ; $(MAKE) test_9*
exectestlist = test_[1234]
docktestlist = test_[567]
docktestlist2 = st_[567]
func functests: ; $(MAKE) "test_0*"
exec exectests: ; $(MAKE) test_1* test_2* test_3* test_4*
dock docktests: ; $(MAKE) test_5* test_6* test_7*
15.6/tests: ; $(MAKE) "15.6/$(docktestlist)"
15.5/tests: ; $(MAKE) "15.5/$(docktestlist)"
15.4/tests: ; $(MAKE) "15.4/$(docktestlist)"
15.2/tests: ; $(MAKE) "15.2/$(docktestlist)"
15.1/tests: ; $(MAKE) "15.1/$(docktestlist)"
15.0/tests: ; $(MAKE) "15.0/$(docktestlist)"
42.3/tests: ; $(MAKE) "42.3/$(docktestlist)"
42.2/tests: ; $(MAKE) "42.2/$(docktestlist)"
22.04/tests: ; $(MAKE) "22.04/$(docktestlist)"
20.04/tests: ; $(MAKE) "20.04/$(docktestlist)"
19.10/tests: ; $(MAKE) "19.10/$(docktestlist)"
18.04/tests: ; $(MAKE) "18.04/$(docktestlist)"
16.04/tests: ; $(MAKE) "16.04/$(docktestlist)"
9.4/tests: ; $(MAKE) "9.4/$(docktestlist)"
9.3/tests: ; $(MAKE) "9.3/$(docktestlist)"
9.1/tests: ; $(MAKE) "9.1/$(docktestlist)"
8.5/tests: ; $(MAKE) "8.5/$(docktestlist)"
8.1/tests: ; $(MAKE) "8.1/$(docktestlist)"
8.0/tests: ; $(MAKE) "8.0/$(docktestlist)"
7.9/tests: ; $(MAKE) "7.9/$(docktestlist)"
7.7/tests: ; $(MAKE) "7.7/$(docktestlist)"
7.6/tests: ; $(MAKE) "7.6/$(docktestlist)"
7.5/tests: ; $(MAKE) "7.5/$(docktestlist)"
7.4/tests: ; $(MAKE) "7.4/$(docktestlist)"
7.3/tests: ; $(MAKE) "7.3/$(docktestlist)"
# python2 has been phased out by newer distros
15.2/test2: ; $(MAKE) "15.2/$(docktestlist2)"
15.1/test2: ; $(MAKE) "15.1/$(docktestlist2)"
15.0/test2: ; $(MAKE) "15.0/$(docktestlist2)"
42.3/test2: ; $(MAKE) "42.3/$(docktestlist2)"
42.2/test2: ; $(MAKE) "42.2/$(docktestlist2)"
22.04/test2: ; $(MAKE) "22.04/$(docktestlist2)"
20.04/test2: ; $(MAKE) "20.04/$(docktestlist2)"
18.04/test2: ; $(MAKE) "18.04/$(docktestlist2)"
16.04/test2: ; $(MAKE) "16.04/$(docktestlist2)"
8.5/test2: ; $(MAKE) "8.5/$(docktestlist2)"
8.1/test2: ; $(MAKE) "8.1/$(docktestlist2)"
8.0/test2: ; $(MAKE) "8.0/$(docktestlist2)"
7.9/test2: ; $(MAKE) "7.9/$(docktestlist2)"
7.7/test2: ; $(MAKE) "7.7/$(docktestlist2)"
7.6/test2: ; $(MAKE) "7.6/$(docktestlist2)"
7.5/test2: ; $(MAKE) "7.5/$(docktestlist2)"
7.4/test2: ; $(MAKE) "7.4/$(docktestlist2)"
7.3/test2: ; $(MAKE) "7.3/$(docktestlist2)"
check: functests exectests check2025
@ echo please run 'make checks' now
25 check2025: ; $(DOCKTEST) $(VV) --opensuse=15.6 --ubuntu=ubuntu:24.04 --centos=almalinux:9.4
24 check2024: ; $(DOCKTEST) $(VV) --opensuse=15.6 --ubuntu=ubuntu:24.04 --centos=almalinux:9.3
23 check2023: ; $(DOCKTEST) $(VV) --opensuse=15.5 --ubuntu=ubuntu:22.04 --centos=almalinux:9.1
22 check2022: ; $(DOCKTEST) $(VV) --opensuse=15.3 --ubuntu=ubuntu:22.04 --centos=almalinux:9.1
19 check2019: ; $(DOCKTEST) $(VV) --opensuse=15.1 --ubuntu=ubuntu:18.04 --centos=centos:7.7
18 check2018: ; $(DOCKTEST) $(VV) --opensuse=15.0 --ubuntu=ubuntu:18.04 --centos=centos:7.5
17 check2017: ; $(DOCKTEST) $(VV) --opensuse=42.3 --ubuntu=ubuntu:16.04 --centos=centos:7.4
16 check2016: ; $(DOCKTEST) $(VV) --opensuse=42.2 --ubuntu=ubuntu:16.04 --centos=centos:7.3
nightrun: checkall
$(MAKE) checks
checkall: checkall2019
checkall2: checkall2024.2
checkall2024:
$(MAKE) -j1 tests checkall2023.3 checkall2023.2
checkall2024.3:
$(MAKE) -j1 9.3/tests 8.5/tests 7.9/tests
$(MAKE) -j1 24.04/tests 22.04/test2 18.04/tests
$(MAKE) -j1 15.6/tests 15.5/tests 15.4/tests 15.2/tests
checkall2024.2:
: $(MAKE) -j1 8.5/test2 7.9/test2
$(MAKE) -j1 22.04/test2 18.04/test2
$(MAKE) -j1 15.6/test2 15.5/test2 15.4/test2 15.2/test2
checkall2023:
$(MAKE) -j1 tests checkall2023.3 checkall2023.2
checkall2023.3:
$(MAKE) -j1 9.1/tests 8.5/tests 7.9/tests
$(MAKE) -j1 22.04/test2 20.04/tests 18.04/tests
$(MAKE) -j1 15.5/tests 15.4/tests 15.2/tests
checkall2023.2:
$(MAKE) -j1 8.5/test2 7.9/test2
$(MAKE) -j1 22.04/test2 20.04/test2 18.04/test2
$(MAKE) -j1 15.5/test2 15.4/test2 15.2/test2
checkall2019:
$(MAKE) -j1 tests checkall2019.3 checkall2019.2
checkall2019.3:
$(MAKE) -j1 8.0/tests
$(MAKE) -j1 18.04/tests 16.04/tests
$(MAKE) -j1 15.1/tests 15.0/tests 42.3/tests
checkall2019.2:
$(MAKE) -j1 7.7/test2 7.5/test2 7.4/test2 7.3/test2
$(MAKE) -j1 18.04/test2 16.04/test2
$(MAKE) -j1 15.1/test2 15.0/test2 42.3/test2
checkall2018:
$(MAKE) -j1 tests
$(MAKE) -j1 7.5/tests 7.4/tests 7.3/tests
$(MAKE) -j1 18.04/tests 16.04/tests
$(MAKE) -j1 15.0/tests 42.3/tests
$(MAKE) -j1 18.04/test2 16.04/test2
$(MAKE) -j1 15.0/test2 42.3/test2
# with python2 being usually not available the coverage is actually just python3 tests now
COVERAGETESTS = test
COVERSRC=src/systemctl3.py
coverage:
- rm .coverage*
$(MAKE) $(COVERSRC)
touch $(COVERSRC)
$(PYTHON3) -m coverage run "--omit=$(FUNCTEST_PY)" $(FUNCTEST_PY) $(FUNCTEST_OPTIONS) --with=$(COVERSRC) && mv -v .coverage .coverage.0
$(EXECTEST) $(VV) --coverage $(COVERAGETESTS) --with=$(COVERSRC) --python=$(PYTHON3)
$(DOCKTEST) $(VV) --coverage $(COVERAGETESTS) --with=$(COVERSRC) --python=$(PYTHON3) $(LOCALPACKAGES)
$(PYTHON3) -m coverage combine && $(PYTHON3) -m coverage report && $(PYTHON3) -m coverage annotate
- $(PYTHON3) -m coverage xml -o tmp/coverage.xml
ls -l $(COVERSRC),cover
@ echo = $$(expr $$(expr $$(stat -c %Y $(COVERSRC),cover) - $$(stat -c %Y $(COVERSRC))) / 60) "mins"
@ echo = $$(grep "def test_" $(FUNCTEST_PY) $(EXECTEST_PY) $(DOCKTEST_PY) | wc -l) "tests"
coveragetime mins:
echo === $$(expr $$(expr $$(stat -c %Y $(COVERSRC),cover) - $$(stat -c %Y $(COVERSRC))) / 60) "mins"
coverage0:
rm .coverage* ; $(MAKE) $(COVERSRC)
$(PYTHON3) -m coverage run "--omit=$(FUNCTEST_PY)" $(FUNCTEST_PY) $(FUNCTEST_OPTIONS) --with=$(COVERSRC) $(VV)
$(PYTHON3) -m coverage combine; $(PYTHON3) -m coverage report && $(PYTHON3) -m coverage annotate
coverage2: ; $(MAKE) coverage COVERAGESRC=tmp/systemctl.py # stripped
coverage3: ; $(MAKE) coverage COVERAGESRC=tmp/systemctl3.py # stripped
coverage9: ; $(MAKE) coverage PYTHON3=$(PYTHON39) LOCALPACKAGES=--local
# these should show different coverage percentage results
coveragetest1: ; $(MAKE) coverage COVERAGETESTS=test_101*;
coveragetest2: ; $(MAKE) coverage COVERAGETESTS=test_5002
coveragetest3: ; $(MAKE) coverage COVERAGETESTS=test_101*,test_5002
coveragetests:
@ echo === $$(grep "def test_" $(FUNCTEST_PY) $(EXECTEST_PY) $(DOCKTEST_PY) | wc -l) "tests"
tmp_ubuntu:
if docker ps | grep $(UBU); then : ; else : \
; docker run --name $(UBU) -d $(UBUNTU) sleep 3333 \
; docker exec $(UBU) apt-get update -y --fix-missing \
; docker exec $(UBU) apt-get install -y --fix-broken --ignore-missing python3-coverage mypy \
; fi
docker cp files $(UBU):/root/
docker cp tests/*tests.py $(UBU):/root/
docker cp tests/reply.py $(UBU):/root/
UBU=test_ubuntu
ubu/test_%:
$(MAKE) tmp_ubuntu
docker exec $(UBU) python3 /root/testsuite.py -C /root $(VV) $(notdir $@)
ubu/st_%:
$(MAKE) tmp_ubuntu
docker exec $(UBU) python3 /root/testsuite.py -C /root $(VV) te$(notdir $@)
clean:
- rm .coverage*
- rm -rf tmp/tmp.test_*
- rm -rf tmp/systemctl.py
- rm -rf tmp.* types/tmp.*
- rm -rf .mypy_cache files/docker/.mypy_cache
- rm -rf src
- rm -rf build
copy:
cp -v ../docker-mirror-packages-repo/docker_mirror.py tests/
cp -v ../docker-mirror-packages-repo/docker_mirror.pyi tests/
############## https://pypi.org/...
src/README.md: README.md Makefile
test -d $(dir $@) || mkdir -v $(dir $@)
cat README.md | sed -e "/\\/badge/d" -e /^---/q > $@
src/py.typed: files/docker/py.typed
test -d $(dir $@) || mkdir -v $(dir $@)
cp $< $@
src/systemctl3.py: files/docker/systemctl3.py
test -d $(dir $@) || mkdir -v $(dir $@)
cp $< $@
src/journalctl3.py: files/docker/journalctl3.py
test -d $(dir $@) || mkdir -v $(dir $@)
cp $< $@
src/__main__.py: Makefile
{ echo '#! /usr/bin/env python3'; echo 'import sys' \
; echo 'from .systemctl3 import main'; echo 'sys.exit(main())' \
; } > $@
# package sources - both stripped and unstripped python scripts and a README without github badges
SRC= src/README.md src/systemctl3.py src/journalctl3.py src/py.typed src/systemctl.py src/journalctl.py src/__main__.py
src: src/README.md src/systemctl3.py src/journalctl3.py src/py.typed src/systemctl.py src/journalctl.py src/__main__.py
buildclean bb rm-src:
- rm -r src/*.egg-info src/__pycache__
@ for src in $(SRC); do test ! -f $$src || rm -v $$src*; done
distclean dd:
- rm -rf build dist *.egg-info src/*.egg-info
# packaging needs python3.9+ for strip_python3 to work (should actually be common after 2025)
PIP3 = $(PYTHON3) -m pip
TWINE3 = $(PYTHON3) -m twine
pkg package: ; $(MAKE) pkg9 PYTHON3=$(PYTHON39)
pkg9 package3:
$(MAKE) distclean
$(MAKE) $(SRC)
# pip install --root=~/local . -v
$(PYTHON3) -m build
$(MAKE) buildclean
$(MAKE) fix-metadata-version
$(TWINE3) check dist/*
: $(TWINE3) upload dist/*
ins install: ; $(MAKE) install3 PYTHON3=$(PYTHON39)
install3:
$(MAKE) distclean
$(MAKE) $(SRC)
$(PIP3) install --no-compile --user .
$(MAKE) buildclean
$(MAKE) show3 | sed -e "s|[.][.]/[.][.]/[.][.]/bin|$$HOME/.local/bin|"
uns uninstall: ; $(MAKE) uninstall3 PYTHON3=$(PYTHON39)
uninstall3:
test -d tmp || mkdir -v tmp
set -x; $(PIP3) uninstall -y `sed -e '/^name *=/!d' -e 's/name *= *"//' -e 's/".*//' pyproject.toml`
show: ; $(MAKE) show3 PYTHON3=$(PYTHON39)
show3:
@ $(PIP3) show --files `sed -e '/^name *=/!d' -e 's/name *= *"//' -e 's/".*//' pyproject.toml` \
| sed -e "s:[^ ]*/[.][.]/\\([a-z][a-z]*\\)/:~/.local/\\1/:"
tag:
@ ver=`sed -e '/^version *=/!d' -e 's/version *= *"//' -e 's/".*//' pyproject.toml` \
; rev=`$(GIT) rev-parse --short HEAD` \
; if test -f tmp.changes.txt \
; then echo ": ${GIT} tag -F tmp.changes.txt v$$ver $$rev" \
; elif test -f RELEASENOTES.md \
; then echo ": ${GIT} tag -F RELEASENOTES.md v$$ver $$rev" \
; else echo ": ${GIT} tag v$$ver $$rev"; fi
fix-metadata-version:
ls dist/*
rm -rf dist.tmp; mkdir dist.tmp
cd dist.tmp; for z in ../dist/*; do case "$$z" in *.whl) unzip $$z ;; *) tar xzvf $$z;; esac \
; ( find . -name PKG-INFO ; find . -name METADATA ) | while read f; do echo FOUND $$f; sed -i -e "s/Metadata-Version: 2.4/Metadata-Version: 2.2/" $$f; done \
; case "$$z" in *.whl) zip -r $$z * ;; *) tar czvf $$z *;; esac ; ls -l $$z; done
####### autopep8
AUTOPEP8=autopep8
AUTOPEP8_WITH=
PYLINT = pylint
PYLINT_OPTIONS =
autopep8: ; $${PKG:-zypper} install -y python3-autopep8
%.py.pep8: %.py
$(AUTOPEP8) $(AUTOPEP8_WITH) ${@:.pep8=} --in-place
git --no-pager diff ${@:.pep8=}
%.pyi.pep8: %.pyi
$(AUTOPEP8) $(AUTOPEP8_WITH) ${@:.pep8=} --in-place
git --no-pager diff ${@:.pep8=}
%.py.style: %.py
$(AUTOPEP8) $(AUTOPEP8_WITH) ${@:.style=} --diff
%.pyi.style: %.pyi
$(AUTOPEP8) $(AUTOPEP8_WITH) ${@:.style=} --diff
%.py.lint:
$(PYLINT) $(PYLINT_OPTIONS) $(@:.lint=)
lint:
$(MAKE) files/docker/systemctl3.py.lint
$(MAKE) tests/testsuite.py.lint
pep8 style:
$(MAKE) files/docker/systemctl3.py.pep8
$(MAKE) types/systemctl3.pyi.pep8
$(MAKE) testsuite.py.pep8
pep style.d:
$(MAKE) files/docker/systemctl3.py.style
$(MAKE) types/systemctl3.pyi.style
$(MAKE) testsuite.py.style
####### strip-hints
STRIPHINTS_GIT_URL = https://github.com/abarker/strip-hints.git
STRIP_HINTS = ../strip-hints
STRIP_HINTS_PY = $(STRIP_HINTS)/bin/strip_hints.py
striphints.git:
set -ex ; if test -d $(STRIPHINTS_GIT); then cd $(STRIPHINTS_GIT) && git pull; else : \
; cd $(dir $(STRIPHINTS_GIT)) && git clone $(STRIPHINTS_GIT_URL) $(notdir $(STRIPHINTS_GIT)) \
; fi
echo "def test(a: str) -> str: return a" > tmp.striphints.py
$(PYTHON) $(STRIPHINTS) --to-empty tmp.striphints.py | tee tmp.striphints.py.out
test "def test(a ) : return a" = "`cat tmp.striphints.py.out`"
rm tmp.striphints.*
STRIP_PYTHON3_GIT_URL = https://github.com/gdraheim/strip_python3
STRIP_PYTHON3_GIT = ../strip_python3
STRIP_PYTHON3_PY = $(STRIP_PYTHON3_GIT)/tool/strip_python3.py
ifeq ("$(wildcard $(STRIP_PYTHON3_PY))", "$(STRIP_PYTHON3_PY)")
STRIP_PYTHON3_SRC = $(STRIP_PYTHON3_PY)
STRIP_PYTHON3_RUN = $(STRIP_PYTHON3_PY)
else
STRIP_PYTHON3_SRC =
STRIP_PYTHON3_RUN = -m strip_python3
endif
STRIP_PYTHON3 = $(PYTHON39) $(STRIP_PYTHON3_RUN) $(STRIP_PYTHON3_OPTIONS)
strip_python3.git:
set -ex ; if test -d $(STRIP_PYTHON3_GIT); then cd $(STRIP_PYTHON3_GIT) && git pull; else : \
; cd $(dir $(STRIPHINTS_GIT)) && git clone $(STRIP_PYTHON3_GIT_URL) $(notdir $(STRIP_PYTHON3_GIT)) \
; fi
echo "def test(a: str) -> str: return a" > tmp.strip_python3.py
$(PYTHON39) $(STRIP_PYTHON3_PY) tmp.strip_python3.py -o tmp.strip_python3.py.out $(VV)
cat tmp.strip_python3.py.out | tr '\\\n' '|' && echo
test "def test(a):| return a|" = "`cat tmp.strip_python3.py.out | tr '\\\\\\n' '|'`"
rm tmp.strip_python3.*
strip_python3:
$(PYTHON39) -m pip install $@
1: src/systemctl.py
src/systemctl.py: files/docker/systemctl3.py $(STRIP_PYTHON3_SRC) Makefile
test -d $(dir $@) || mkdir -v $(dir $@)
@ $(STRIP_PYTHON3) $< -o $@ $V --old-python --make-pyi
chmod +x $@
src/journalctl.py: files/docker/journalctl3.py $(STRIP_PYTHON3_SRC) Makefile
test -d $(dir $@) || mkdir -v $(dir $@)
@ $(STRIP_PYTHON3) $< -o $@ $V --old-python --make-pyi
chmod +x $@
strip: tmp/systemctl_2.py
tmp/systemctl_2.py: files/docker/systemctl3.py $(STRIP_PYTHON3_SRC) Makefile
test -d $(dir $@) || mkdir -v $(dir $@)
@ $(STRIP_PYTHON3) $< -o $@ $V --old-python
chmod +x $@
2: tmp/systemctl.py
tmp/systemctl.py: files/docker/systemctl3.py $(STRIP_PYTHON3_SRC) Makefile
test -d $(dir $@) || mkdir -v $(dir $@)
$(STRIP_PYTHON3) $< -o $@ $V --no-comments --run-python=python2
chmod +x $@
3: tmp/systemctl3.py
tmp/systemctl3.py: files/docker/systemctl3.py $(STRIP_PYTHON3_SRC) Makefile
test -d $(dir $@) || mkdir -v $(dir $@)
@ $(STRIP_PYTHON3) $< -o $@ $V --no-comments --run-python=python3
chmod +x $@
MYPY = mypy
MYPY_WITH = --strict --show-error-codes --show-error-context
MYPY_OPTIONS = --no-warn-unused-ignores --python-version $(PYTHON_VERSION)
mypy:
zypper install -y mypy
zypper install -y python3-click python3-pathspec
cd .. && git clone git@github.com:ambv/retype.git
cd ../retype && git checkout 17.12.0
type:; $(MYPY) $(MYPY_WITH) $(MYPY_OPTIONS) files/docker/systemctl3.py
ttype:; $(MYPY) $(MYPY_WITH) $(MYPY_OPTIONS) testsuite.py
####### box test
box:
docker rm -f $@ ; docker run -d --name $@ --rm=true centos:centos7 sleep 600
docker cp files/docker/systemctl.py box:/usr/bin/systemctl
docker exec box systemctl daemon-reload $(VV)
@ echo : docker exec -it box bash
-include Makefile.tmp.mk