Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (84 loc) · 4.33 KB
/
Copy pathMakefile
File metadata and controls
97 lines (84 loc) · 4.33 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
# CCFE developer tasks. Standard Debian/Ubuntu packages only, listed in
# docker/ci/packages.txt (the same list CI installs).
#
# make check THE GATE: test + critic + tidy-check + shellcheck. CI runs
# exactly this. A different perlcritic/PPI/perltidy can
# still disagree with the local one: ./scripts/ci-local runs
# the gate on CI's toolchain (an ubuntu:latest image, no
# network) before you push. It sets
# CCFE_REQUIRE_PTY=1, so a test that would skip (no pty, no
# Curses, no installer, failed install, root) fails instead:
# a green gate never means "skipped quietly".
# make test run the test suite only, four files at a time (a missing
# pty skips, not fails; each test file has its own temp HOME)
# make critic Perl::Critic: modules + test helpers + ccfe-gen (sev 3), ccfe.pl
# (.perlcriticrc-ccfe, legacy)
# make tidy reformat the modules and ccfe.pl in place (keeps .bak)
# make tidy-check fail if the modules or ccfe.pl are not tidy (same file list
# as `make tidy`)
# make shellcheck shellcheck src/tools/* (POSIX sh; ccfe-gen is Perl and left
# out), scripts/* and the CI image's entry point
# make deb build the .deb and store it (with .buildinfo/.changes)
# under dist/, which is tracked in git
# make rpm build the .rpm (needs rpmbuild) and store it under dist/
#
# Environment:
# CCFE_REQUIRE_PTY=1 strict mode: a test that would skip fails instead
# (a run-time optional module excepted); set by `make check`
SRC = src
# Everything held to the perltidy house style: the modules and the main script.
TIDY_FILES = $(SRC)/lib/CCFE/*.pm $(SRC)/lib/CCFE/*/*.pm $(SRC)/ccfe.pl $(SRC)/tools/ccfe-gen
# Package version, read from debian/changelog.
VERSION = $(shell dpkg-parsechangelog -SVersion 2>/dev/null)
.PHONY: test critic tidy tidy-check shellcheck check deb rpm
# The gate requires a pty (see the header); target-specific, so it also covers
# the prerequisites of check.
check: export CCFE_REQUIRE_PTY = 1
test:
cd $(SRC) && prove -j4 -lr t/
critic:
perlcritic --profile .perlcriticrc $(SRC)/lib $(SRC)/t/lib $(SRC)/tools/ccfe-gen
perlcritic --profile .perlcriticrc-ccfe $(SRC)/ccfe.pl
tidy:
perltidy --profile=.perltidyrc -b $(TIDY_FILES)
# CI installs Ubuntu's perltidy, which can differ from a developer's: a diff
# that only CI reports means the two versions format differently; reformat with
# the CI version (or loosen .perltidyrc) rather than hand-editing around it.
tidy-check:
@status=0; \
for f in $(TIDY_FILES); do \
perltidy --profile=.perltidyrc -st $$f 2>/dev/null | diff -q - $$f >/dev/null \
|| { echo "Not tidy: $$f (run: make tidy)"; status=1; }; \
done; \
exit $$status
# ccfe-gen is Perl, checked by critic and tidy-check.
shellcheck:
shellcheck $(filter-out $(SRC)/tools/ccfe-gen,$(wildcard $(SRC)/tools/*)) \
$(wildcard scripts/*) docker/ci/ci-run
check: test critic tidy-check shellcheck
# Build the binary package (unsigned) and collect the artifacts in dist/.
# dpkg-buildpackage writes to the parent dir; we move them in and then clean
# the regenerated debian/ build tree.
deb:
dpkg-buildpackage -b -us -uc
mkdir -p dist
mv ../ccfe_$(VERSION)_*.deb ../ccfe_$(VERSION)_*.buildinfo \
../ccfe_$(VERSION)_*.changes dist/
rm -rf debian/ccfe debian/.debhelper debian/debhelper-build-stamp \
debian/files debian/*.substvars debian/*.debhelper.log
@echo "Packages in dist/:" && ls dist/ccfe_$(VERSION)_*
# Build the .rpm from the committed tree via the bundled spec and collect it in
# dist/. Needs rpmbuild (the Debian 'rpm' package). The version comes from
# debian/changelog, matching the spec's Version:, so the two stay in step.
rpm:
@command -v rpmbuild >/dev/null 2>&1 || \
{ echo "rpmbuild not found -- install the 'rpm' package"; exit 1; }
rm -rf rpmbuild
mkdir -p rpmbuild/SOURCES
git archive --format=tar.gz --prefix=ccfe-$(VERSION)/ \
-o rpmbuild/SOURCES/ccfe-$(VERSION).tar.gz HEAD
rpmbuild --define "_topdir $(CURDIR)/rpmbuild" -ba packaging/rpm/ccfe.spec
mkdir -p dist
cp rpmbuild/RPMS/noarch/ccfe-$(VERSION)-*.rpm dist/
rm -rf rpmbuild
@echo "Packages in dist/:" && ls dist/ccfe-$(VERSION)-*.rpm