Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
608 lines (508 loc) · 20.7 KB
/
Copy pathMakefile
File metadata and controls
608 lines (508 loc) · 20.7 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
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
ifeq ($(origin FEDORA_RELEASE), undefined)
else
FEDORA_RELEASE_ARGS = --release=${FEDORA_RELEASE}
endif
IGNORE_ARGS ?=
ifeq ($(origin PROFILE), undefined)
else
PROFILE_FLAGS = -C instrument-coverage
endif
ifeq ($(origin CAP_LINTS), undefined)
else
CAP_LINTS_FLAGS = --cap-lints=${CAP_LINTS}
endif
RUSTFLAGS = ${PROFILE_FLAGS} ${CAP_LINTS_FLAGS}
ifneq ($(origin AUDITABLE), undefined)
BUILD = auditable build
CLIPPY = clippy
RUSTC = auditable rustc
TEST = test
else ifneq ($(origin MINIMAL), undefined)
BUILD = minimal-versions build --direct
CLIPPY = minimal-versions clippy --direct
RUSTC = rustc
TEST = minimal-versions test --direct
else
BUILD = build
CLIPPY = clippy
RUSTC = rustc
TEST = test
endif
ifeq ($(origin CLIPPY_FIX), undefined)
CLIPPY_OPTS = --all-targets --no-deps
else
CLIPPY_OPTS = --fix --allow-dirty --allow-staged
endif
ifeq ($(origin TARGET), undefined)
else
TARGET_ARGS = --target=${TARGET}
endif
.DEFAULT_GOAL := help
COMPARE_FEDORA_VERSIONS ?=
INSTALL ?= /usr/bin/install
DESTDIR ?=
PREFIX ?= /usr
LIBEXECDIR ?= $(PREFIX)/libexec
DATADIR ?= $(PREFIX)/share
UDEVDIR ?= $(PREFIX)/lib/udev
MANDIR ?= $(DATADIR)/man
UNITDIR ?= $(PREFIX)/lib/systemd/system
UNITEXECDIR ?= $(PREFIX)/lib/systemd
UNITGENDIR ?= $(PREFIX)/lib/systemd/system-generators
DRACUTDIR ?= $(PREFIX)/lib/dracut
BINDIR ?= $(PREFIX)/bin
# alternative is "debug"
PROFILEDIR ?= release
ifeq ($(PROFILEDIR), debug)
RELEASE_FLAG =
STATIC_CARGO_FLAGS = CARGO_PROFILE_DEV_LTO=thin
else
RELEASE_FLAG = --release
STATIC_CARGO_FLAGS = CARGO_PROFILE_RELEASE_LTO=thin
endif
MIN_FEATURES = --no-default-features --features engine,min
NO_IPC_FEATURES = --no-default-features --features engine
SYSTEMD_FEATURES = --no-default-features --features engine,min,systemd_compat
EXTRAS_FEATURES = --no-default-features --features engine,extras
UDEV_FEATURES = --no-default-features --features udev_scripts
UTILS_FEATURES = --no-default-features --features dbus_enabled,engine,systemd_compat
STATIC_CFLAGS = -C target-feature=+crt-static
.PHONY: actionlint
## Lint Github Workflows files
actionlint:
actionlint
.PHONY: audit
## Run cargo audit
audit:
cargo audit
.PHONY: audit-all-rust
## Audit Rust executables
audit-all-rust: build-all-rust
cargo audit bin \
./target/${PROFILEDIR}/stratisd \
./target/${PROFILEDIR}/stratisd-min \
./target/${PROFILEDIR}/stratis-min \
./target/${PROFILEDIR}/stratis-utils \
./target/${PROFILEDIR}/stratis-str-cmp \
./target/${PROFILEDIR}/stratis-base32-decode \
./target/${PROFILEDIR}/stratisd-tools
.PHONY: build-all
## Build all stratisd binaries and configuration necessary for install
build-all: build-all-rust build-all-man
.PHONY: build-all-man
## Build all man pages
build-all-man: docs/stratisd.8 docs/stratis-dumpmetadata.8
.PHONY: build-all-rust
## Build all Rust artifacts
build-all-rust: stratisd build-min build-utils build-udev-utils stratisd-tools
.PHONY: build-min
## Build stratisd-min and stratis-min for early userspace
build-min:
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratis-min --bin=stratisd-min \
${SYSTEMD_FEATURES} ${TARGET_ARGS}
.PHONY: build-min-no-systemd
## Build min targets without systemd support enabled
build-min-no-systemd:
PKG_CONFIG_ALLOW_CROSS=1 \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratis-min --bin=stratisd-min \
${MIN_FEATURES} ${TARGET_ARGS}
.PHONY: build-no-ipc
## Build stratisd-min and stratis-min for early userspace
build-no-ipc:
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratisd \
${NO_IPC_FEATURES} \
${TARGET_ARGS}
.PHONY: build-tests
## Build the stratisd test suite
build-tests:
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${TEST} --no-run ${RELEASE_FLAG} ${TARGET_ARGS}
.PHONY: build-udev-utils
## Build stratis-base32-decode and stratis-str-cmp statically
build-udev-utils: stratis-str-cmp stratis-base32-decode
.PHONY: build-utils
## Build stratis-utils only
build-utils:
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratis-utils \
${UTILS_FEATURES} ${TARGET_ARGS}
.PHONY: build-utils-no-systemd
## Build stratis-utils without systemd
build-utils-no-systemd:
PKG_CONFIG_ALLOW_CROSS=1 \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratis-utils \
${NO_IPC_FEATURES} ${TARGET_ARGS}
.PHONY: check-fedora-versions
## Verify that the dependency specs are satisfied in Fedora
check-fedora-versions: test-compare-fedora-versions
${COMPARE_FEDORA_VERSIONS} ${FEDORA_RELEASE_ARGS} ${IGNORE_ARGS}
.PHONY: check-typos
## Check for spelling errors
check-typos:
typos
.PHONY: clean
## Remove installed items
clean: clean-cfg clean-ancillary clean-primary
.PHONY: clean-ancillary
## Remove installed non-primary tools generated by the build process
clean-ancillary:
rm -fv $(DESTDIR)$(UDEVDIR)/stratis-str-cmp
rm -fv $(DESTDIR)$(UDEVDIR)/stratis-base32-decode
rm -fv $(DESTDIR)$(BINDIR)/stratis-predict-usage
rm -fv $(DESTDIR)$(BINDIR)/stratisd-tools
rm -fv $(DESTDIR)$(BINDIR)/stratis-dumpmetadata
rm -fv $(DESTDIR)$(BINDIR)/stratis-decode-dm
rm -fv $(DESTDIR)$(UNITGENDIR)/stratis-setup-generator
rm -fv $(DESTDIR)$(UNITGENDIR)/stratis-clevis-setup-generator
rm -fv $(DESTDIR)$(UNITEXECDIR)/stratis-fstab-setup
.PHONY: clean-cfg
## Remove installed configuration files
clean-cfg:
rm -fv $(DESTDIR)$(DATADIR)/dbus-1/system.d/stratisd.conf
rm -fv $(DESTDIR)$(MANDIR)/man8/stratisd.8
rm -fv $(DESTDIR)$(MANDIR)/man8/stratis-dumpmetadata.8
rm -fv $(DESTDIR)$(UDEVDIR)/rules.d/*-stratisd.rules
rm -fv $(DESTDIR)$(UNITDIR)/stratisd.service
rm -rfv $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis
rm -rfv $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis-clevis
rm -fv $(DESTDIR)$(UNITDIR)/stratisd-min-postinitrd.service
rm -fv $(DESTDIR)$(UNITDIR)/stratis-fstab-setup@.service
rm -fv $(DESTDIR)$(UNITDIR)/stratis-fstab-setup-with-network@.service
.PHONY: clean-primary
## Remove installed command-line tools and daemons generated by the build process
clean-primary:
rm -fv $(DESTDIR)$(LIBEXECDIR)/stratisd
rm -fv $(DESTDIR)$(BINDIR)/stratis-min
rm -fv $(DESTDIR)$(LIBEXECDIR)/stratisd-min
.PHONY: clippy
## Run clippy on the current source tree
clippy: clippy-macros clippy-min clippy-udev-utils clippy-no-ipc clippy-utils
cargo ${CLIPPY} ${CLIPPY_OPTS}
.PHONY: clippy-macros
## Run clippy on stratisd_proc_macros
clippy-macros:
cd stratisd_proc_macros && cargo ${CLIPPY} --all-features ${CLIPPY_OPTS}
.PHONY: clippy-min
## Run clippy on the -min build
clippy-min:
cargo ${CLIPPY} ${CLIPPY_OPTS} ${MIN_FEATURES}
cargo ${CLIPPY} ${CLIPPY_OPTS} ${SYSTEMD_FEATURES}
cargo ${CLIPPY} ${CLIPPY_OPTS} ${EXTRAS_FEATURES}
.PHONY: clippy-no-ipc
## Run clippy on no-ipc-build
clippy-no-ipc:
cargo ${CLIPPY} ${CLIPPY_OPTS} ${NO_IPC_FEATURES}
.PHONY: clippy-udev-utils
## Run clippy on the udev utils
clippy-udev-utils:
cargo ${CLIPPY} ${CLIPPY_OPTS} ${UDEV_FEATURES}
.PHONY: clippy-utils
## Run clippy on the utils binary
clippy-utils:
cargo ${CLIPPY} ${CLIPPY_OPTS} ${UTILS_FEATURES}
.PHONY: docs-ci
## Build docs-rust for CI
docs-ci: docs-rust
.PHONY: docs-rust
## Build rust documentation
docs-rust:
cargo doc --no-deps
docs/%.8: docs/%.txt
a2x -f manpage $<
.PHONY: fix-typos
## Fix spelling errors
fix-typos:
typos -w
.PHONY: fmt
## Run cargo fmt
fmt: fmt-macros
cargo fmt
.PHONY: fmt-ci
## Run cargo fmt for CI jobs
fmt-ci: fmt-macros-ci
cargo fmt -- --check
.PHONY: fmt-macros
## Run cargo fmt for stratisd_proc_macros
fmt-macros:
cd stratisd_proc_macros && cargo fmt
.PHONY: fmt-macros-ci
## Run cargo fmt on stratisd_proc_macros for CI jobs
fmt-macros-ci:
cd stratisd_proc_macros && cargo fmt -- --check
.PHONY: fmt-shell
## Check shell formatting with shfmt
fmt-shell:
shfmt -l -w .
.PHONY: fmt-shell-ci
## Check shell formatting with shfmt for CI
fmt-shell-ci:
shfmt -d .
.PHONY: install
## Install all stratisd files
install: install-programs install-man-cfg
.PHONY: install-binaries
## Install binaries
install-binaries:
mkdir -p $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(UNITGENDIR)
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(BINDIR) target/$(PROFILEDIR)/stratis-min
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(BINDIR) target/$(PROFILEDIR)/stratisd-tools
ln --force --verbose $(DESTDIR)$(BINDIR)/stratisd-tools $(DESTDIR)$(BINDIR)/stratis-dumpmetadata
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(BINDIR) target/$(PROFILEDIR)/stratis-utils
mv --force --verbose $(DESTDIR)$(BINDIR)/stratis-utils $(DESTDIR)$(BINDIR)/stratis-predict-usage
ln --force --verbose $(DESTDIR)$(BINDIR)/stratis-predict-usage $(DESTDIR)$(UNITGENDIR)/stratis-clevis-setup-generator
ln --force --verbose $(DESTDIR)$(BINDIR)/stratis-predict-usage $(DESTDIR)$(UNITGENDIR)/stratis-setup-generator
ln --force --verbose $(DESTDIR)$(BINDIR)/stratis-predict-usage $(DESTDIR)$(BINDIR)/stratis-decode-dm
.PHONY: install-daemons
## Install daemons
install-daemons:
mkdir -p $(DESTDIR)$(LIBEXECDIR)
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(LIBEXECDIR) target/$(PROFILEDIR)/stratisd
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(LIBEXECDIR) target/$(PROFILEDIR)/stratisd-min
.PHONY: install-dbus-cfg
## Install dbus config
install-dbus-cfg:
mkdir -p $(DESTDIR)$(DATADIR)/dbus-1/system.d
$(INSTALL) -Dpm0644 -t $(DESTDIR)$(DATADIR)/dbus-1/system.d stratisd.conf
.PHONY: install-dracut-cfg
## Install dracut modules
install-dracut-cfg:
mkdir -p $(DESTDIR)$(DRACUTDIR)/modules.d
$(INSTALL) -Dpm0755 -d $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis
sed 's|@LIBEXECDIR@|$(LIBEXECDIR)|' dracut/50stratis/stratisd-min.service.in > $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis/stratisd-min.service
sed 's|@LIBEXECDIR@|$(LIBEXECDIR)|' dracut/50stratis/module-setup.sh.in > $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis/module-setup.sh
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis dracut/50stratis/stratis-rootfs-setup
$(INSTALL) -Dpm0644 -t $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis dracut/50stratis/61-stratisd.rules
$(INSTALL) -Dpm0755 -d $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis-clevis
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis-clevis dracut/50stratis-clevis/module-setup.sh
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(DRACUTDIR)/modules.d/50stratis-clevis dracut/50stratis-clevis/stratis-clevis-rootfs-setup
.PHONY: install-fstab-script
## Install fstab script
install-fstab-script:
mkdir -p $(DESTDIR)$(UNITEXECDIR)
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(UNITEXECDIR) systemd/stratis-fstab-setup
.PHONY: install-man-cfg
## Install man pages
install-man-cfg:
mkdir -p $(DESTDIR)$(MANDIR)/man8
$(INSTALL) -Dpm0644 -t $(DESTDIR)$(MANDIR)/man8 docs/stratisd.8
$(INSTALL) -Dpm0644 -t $(DESTDIR)$(MANDIR)/man8 docs/stratis-dumpmetadata.8
.PHONY: install-programs
## Install all stratisd programs and config files
install-programs: install-udev-cfg install-dbus-cfg install-dracut-cfg install-systemd-cfg install-binaries install-udev-binaries install-fstab-script install-daemons
.PHONY: install-systemd-cfg
## Install systemd configuration
install-systemd-cfg:
mkdir -p $(DESTDIR)$(UNITDIR)
sed 's|@LIBEXECDIR@|$(LIBEXECDIR)|' systemd/stratisd.service.in > $(DESTDIR)$(UNITDIR)/stratisd.service
sed 's|@LIBEXECDIR@|$(LIBEXECDIR)|' systemd/stratisd-min-postinitrd.service.in > $(DESTDIR)$(UNITDIR)/stratisd-min-postinitrd.service
sed 's|@UNITEXECDIR@|$(UNITEXECDIR)|' systemd/stratis-fstab-setup@.service.in > $(DESTDIR)$(UNITDIR)/stratis-fstab-setup@.service
sed 's|@UNITEXECDIR@|$(UNITEXECDIR)|' systemd/stratis-fstab-setup-with-network@.service.in > $(DESTDIR)$(UNITDIR)/stratis-fstab-setup-with-network@.service
.PHONY: install-udev-binaries
## Install udev binaries
install-udev-binaries:
mkdir -p $(DESTDIR)$(UDEVDIR)
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(UDEVDIR) target/$(PROFILEDIR)/stratis-base32-decode
$(INSTALL) -Dpm0755 -t $(DESTDIR)$(UDEVDIR) target/$(PROFILEDIR)/stratis-str-cmp
.PHONY: install-udev-cfg
## Install udev configuration
install-udev-cfg:
mkdir -p $(DESTDIR)$(UDEVDIR)/rules.d
$(INSTALL) -Dpm0644 -t $(DESTDIR)$(UDEVDIR)/rules.d udev/61-stratisd.rules
.PHONY: stratis-base32-decode
## Build stratis-base32-decode binary
stratis-base32-decode:
PKG_CONFIG_ALLOW_CROSS=1 \
${STATIC_CARGO_FLAGS} \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${RUSTC} ${RELEASE_FLAG} \
--bin=stratis-base32-decode \
${UDEV_FEATURES} \
${TARGET_ARGS} \
-- ${STATIC_CFLAGS}
@ldd target/${PROFILEDIR}/stratis-base32-decode|grep --quiet --silent "statically linked" || (echo "stratis-base32-decode is not statically linked" && exit 1)
.PHONY: stratis-min
## Build stratis-min for early userspace
stratis-min:
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratis-min ${MIN_FEATURES} ${TARGET_ARGS}
.PHONY: stratis-str-cmp
## Build stratis-str-cmp binary
stratis-str-cmp:
PKG_CONFIG_ALLOW_CROSS=1 \
${STATIC_CARGO_FLAGS} \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${RUSTC} ${RELEASE_FLAG} \
--bin=stratis-str-cmp \
${UDEV_FEATURES} \
${TARGET_ARGS} \
-- ${STATIC_CFLAGS}
@ldd target/${PROFILEDIR}/stratis-str-cmp|grep --quiet --silent "statically linked" || (echo "stratis-str-cmp is not statically linked" && exit 1)
.PHONY: stratisd
## Build stratisd
stratisd:
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratisd \
${TARGET_ARGS}
.PHONY: stratisd-min
## Build stratisd-min for early userspace
stratisd-min:
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratisd-min ${SYSTEMD_FEATURES} ${TARGET_ARGS}
.PHONY: stratisd-tools
## Build the stratisd-tools program
stratisd-tools:
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS="${RUSTFLAGS}" \
cargo ${BUILD} ${RELEASE_FLAG} \
--bin=stratisd-tools ${EXTRAS_FEATURES} ${TARGET_ARGS}
.PHONY: systemd-lint
## Statically lint systemd configuration files after install step
systemd-lint:
systemd-analyze verify $$(ls /usr/lib/systemd/system/stratis*.service)
.PHONY: test
## Basic tests
test:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 cargo test --all-features -- --skip real_ --skip loop_ --skip clevis_ --skip test_stratis_min_ --skip test_stratisd_min_
.PHONY: test-clevis-loop
## Clevis tests with loop devices
test-clevis-loop:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test clevis_loop_ -- --skip clevis_loop_should_fail_
.PHONY: test-clevis-loop-root
## Clevis tests with loop devices as root
test-clevis-loop-root:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_loop_ -- --skip clevis_loop_should_fail_
.PHONY: test-clevis-loop-should-fail
## Clevis loop device tests that are expected to fail
test-clevis-loop-should-fail:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test clevis_loop_should_fail_
.PHONY: test-clevis-loop-should-fail-root
## Clevis loop device tests that are expected to fail as root
test-clevis-loop-should-fail-root:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_loop_should_fail_
.PHONY: test-clevis-loop-should-fail-valgrind
## Clevis loop device tests that are expected to fail run under valgrind
test-clevis-loop-should-fail-valgrind:
RUST_TEST_THREADS=1 sudo -E valgrind --leak-check=full --num-callers=500 $(shell cargo test --no-run --all-features --message-format=json 2>/dev/null | jq -r 'select(.target.src_path == "'${PWD}/src/lib.rs'") | select(.executable != null) | .executable') clevis_loop_should_fail_
.PHONY: test-clevis-loop-valgrind
## Clevis tests with loop devices with valgrind
test-clevis-loop-valgrind:
RUST_TEST_THREADS=1 sudo -E valgrind --leak-check=full --num-callers=500 $(shell cargo test --no-run --all-features --message-format=json 2>/dev/null | jq -r 'select(.target.src_path == "'${PWD}/src/lib.rs'") | select(.executable != null) | .executable') clevis_loop_ --skip clevis_loop_should_fail_
.PHONY: test-clevis-real
## Clevis tests with real devices
test-clevis-real:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test clevis_real_ -- --skip clevis_real_should_fail
.PHONY: test-clevis-real-root
## Clevis tests with real devices as root
test-clevis-real-root:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_real_ -- --skip clevis_real_should_fail
.PHONY: test-clevis-real-should-fail
## Clevis real device tests that are expected to fail
test-clevis-real-should-fail:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test clevis_real_should_fail
.PHONY: test-clevis-real-should-fail-root
## Clevis real device tests that are expected to fail as root
test-clevis-real-should-fail-root:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_real_should_fail
.PHONY: test-compare-fedora-versions
## Verify that a script for comparing version specs with Fedora is available
test-compare-fedora-versions:
echo "Testing that COMPARE_FEDORA_VERSIONS environment variable is set to a valid path"
test -e "${COMPARE_FEDORA_VERSIONS}"
.PHONY: test-loop
## Tests with loop devices
test-loop:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test loop_ -- --skip clevis_loop_
.PHONY: test-loop-root
## Tests with loop devices as root
test-loop-root:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test loop_ -- --skip clevis_loop_
.PHONY: test-loop-valgrind
## Tests run under valgrind with loop devices
test-loop-valgrind:
RUST_TEST_THREADS=1 sudo -E valgrind --leak-check=full --num-callers=500 $(shell cargo test --no-run --all-features --message-format=json 2>/dev/null | jq -r 'select(.target.src_path == "'${PWD}/src/lib.rs'") | select(.executable != null) | .executable') loop_ --skip real_ --skip clevis_
.PHONY: test-real
## Tests with real devices
test-real:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test real_ -- --skip clevis_real_
.PHONY: test-real-root
## Tests with real devices as root
test-real-root:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test real_ -- --skip clevis_real_
.PHONY: test-stratis-min
## Test stratis-min CLI
test-stratis-min:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test --no-default-features --features "engine,min" test_stratis_min
.PHONY: test-stratis-min-root
## Test stratis-min CLI as root
test-stratis-min-root:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --no-default-features --features "engine,min" test_stratis_min
.PHONY: test-stratis-utils
## Test stratis-utils
test-stratis-utils:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --no-default-features --features "dbus_enabled,engine" test_stratis_utils
.PHONY: test-stratisd-min
## Test stratisd-min CLI
test-stratisd-min:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test --no-default-features --features "engine,min" test_stratisd_min
.PHONY: test-stratisd-min-root
## Test stratisd-min CLI as root
test-stratisd-min-root:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --no-default-features --features "engine,min" test_stratisd_min
.PHONY: test-stratisd-tools
## Test stratisd-tools CLI
test-stratisd-tools:
RUSTFLAGS="${RUSTFLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --no-default-features --features "engine,extras" test_stratisd_tools
.PHONY: test-valgrind
## Basic tests run under valgrind
test-valgrind:
RUST_TEST_THREADS=1 valgrind --leak-check=full --num-callers=500 $(shell cargo test --no-run --all-features --message-format=json 2>/dev/null | jq -r 'select(.target.src_path == "'${PWD}/src/lib.rs'") | select(.executable != null) | .executable') --skip real_ --skip loop_ --skip clevis_
.PHONY: tmtlint
## Run tmt lint
tmtlint:
tmt lint
.PHONY: yamllint
## Run yamllint on workflow files
yamllint:
yamllint --strict .github/workflows/*.yml
yamllint --strict .packit.yaml
yamllint --strict .yamllint.yaml
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
TARGET_MAX_CHARS=30
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-_0-9]+:/ { \
targetHelp = match(lastLine, /^## (.*)/); \
if (targetHelp) { \
target = substr($$1, 0, index($$1, ":")-1); \
targetHelp = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHARS)s${RESET} ${GREEN}%s${RESET}\n", target, targetHelp; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)