-
Notifications
You must be signed in to change notification settings - Fork 533
Expand file tree
/
Copy pathMakefile
More file actions
210 lines (180 loc) · 8.31 KB
/
Makefile
File metadata and controls
210 lines (180 loc) · 8.31 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
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
#
include defines.make
include artifacts.make
TAROPTS := --owner=root --group=root \
--wildcards \
--exclude .git --exclude .gitignore --exclude .gitmodules --exclude .gitattributes \
--exclude=.svn \
--exclude=~* --exclude=*~ --exclude=*.swp \
--exclude=.f12 --exclude=OWNERS \
--exclude=__pycache__ --exclude=*.pyc
UVENV := scripts/run-uvenv
# The CI environment variable should only be set by Jenkins
CI ?= false
.PHONY: announcement all build \
clean dist documentation \
format \
help install mrproper mrclean \
packages setup setversion version openapi \
requirements.txt .venv
help:
@echo "setup --> Prepare system for development and building"
@echo "make dist --> Create source tgz for later building of rpm/deb and livestatus tgz"
@echo "make version --> Switch to new version"
$(SOURCE_BUILT_LINUX_AGENTS):
$(MAKE) -C agents $@
ifneq ($(EDITION),community)
$(SOURCE_BUILT_AGENT_UPDATER):
@echo "ERROR: Should have already been built by artifact providing jobs"
@echo "If you don't need the artifacts, you can use "
@echo "'scripts/fake-artifacts' to continue with stub files"
@exit 1
endif
# Is executed by our build environment from a "git archive" snapshot and during
# RPM building to create the source tar.gz for the RPM build process.
# Would use --exclude-vcs-ignores but that's available from tar 1.29 which
# is currently not used by most distros
# Would also use --exclude-vcs, but this is also not available
# And --transform is also missing ...
dist: $(SOURCE_BUILT_AGENTS) $(SOURCE_BUILT_AGENT_UPDATER)
if [ -z "$(EDITION)" ]; then \
echo "EDITION is not set!" ; exit 1 ; \
fi ; \
set -e -o pipefail ; EXCLUDES= ; \
# COMMIT can be created in bazel via "//omd:hash_file_pkg"
git rev-parse HEAD > COMMIT ; \
for X in $$(git ls-files --directory --others -i --exclude-standard) ; do \
EXCLUDES+=" --exclude $${X%*/}" ; \
done ; \
if [ -d check-mk-$(EDITION)-$(VERSION) ]; then \
rm -rf check-mk-$(EDITION)-$(VERSION) ; \
fi ; \
mkdir check-mk-$(EDITION)-$(VERSION) ; \
# TODO: as soon as the source tar gz build is in bazel, filename_from_flag will handle this renaming \
# Safety net: ensure we use the correct version - should not be an issue tho because we start from a clean workspace \
rpm -qi agents/check-mk-agent.noarch.rpm | grep $$(echo $(VERSION) | tr '-' '_') || exit 1; \
dpkg-deb -I agents/check-mk-agent_all.deb | grep $(VERSION) || exit 1; \
mv agents/check-mk-agent.noarch.rpm agents/check-mk-agent-$(VERSION)-1.noarch.rpm ; \
mv agents/check-mk-agent_all.deb agents/check-mk-agent_$(VERSION)-1_all.deb ; \
tar -c \
$(TAROPTS) \
--exclude check-mk-$(EDITION)-$(VERSION) \
--exclude non-free \
--exclude tests/qa-test-data \
$$EXCLUDES \
* .werks | tar x -C check-mk-$(EDITION)-$(VERSION)
if [ -f COMMIT ]; then \
rm COMMIT ; \
fi
bazel build //omd/dependency_management:license_info && tar xf "$$(bazel cquery --output=files //omd/dependency_management:license_info)" --strip 2 --touch -C check-mk-$(EDITION)-$(VERSION)/omd/
tar -cz -f check-mk-$(EDITION)-$(VERSION).tar.gz \
$(TAROPTS) \
--exclude=bazel-* \
check-mk-$(EDITION)-$(VERSION)
rm -rf check-mk-$(EDITION)-$(VERSION)
announcement:
mkdir -p $(CHECK_MK_ANNOUNCE_FOLDER)
bazel run //cmk/utils:werks_bin -- announce "$$(pwd)/.werks" $(VERSION) --format=md > $(CHECK_MK_ANNOUNCE_MD)
bazel run //cmk/utils:werks_bin -- announce "$$(pwd)/.werks" $(VERSION) --format=txt > $(CHECK_MK_ANNOUNCE_TXT)
tar -czf $(CHECK_MK_ANNOUNCE_TAR) -C $(CHECK_MK_ANNOUNCE_FOLDER) .
packages:
$(MAKE) -C agents packages
version:
[ "$$(head -c 6 /etc/issue)" = "Ubuntu" \
-o "$$(head -c 16 /etc/issue)" = "Debian GNU/Linux" ] \
|| { echo 'You are not on the reference system!' ; exit 1; }
@newversion=$$(dialog --stdout --inputbox "New Version:" 0 0 "$(VERSION)") ; \
if [ -n "$$newversion" ] ; then $(MAKE) NEW_VERSION=$$newversion setversion ; fi
# NOTE: CMake accepts only up to 4 non-negative integer version parts, so we
# replace any character (like 'p' or 'b') with a dot. Not completely correct,
# but better than nothing. We have to rethink this setversion madness, anyway.
setversion:
# IMPORTANT do not version bazelized packages here. Bazel can set the
# version natively.
sed -ri 's/^(VERSION[[:space:]]*:?= *).*/\1'"$(NEW_VERSION)/" defines.make
sed -i 's/^__version__ = ".*"$$/__version__ = "$(NEW_VERSION)"/' packages/cmk-ccc/cmk/ccc/version.py bin/livedump
$(MAKE) -C agents NEW_VERSION=$(NEW_VERSION) setversion
sed -i 's/^ARG CMK_VERSION=.*$$/ARG CMK_VERSION="$(NEW_VERSION)"/g' docker_image/Dockerfile
ifneq ($(EDITION),community)
sed -i 's/^__version__ = ".*/__version__ = "$(NEW_VERSION)"/' non-free/packages/cmk-update-agent/cmk_update_agent.py
endif
# TODO(sp) The target below is not correct, we should not e.g. remove any stuff
# which is needed to run configure, this should live in a separate target. In
# fact, we should really clean up all this cleaning-chaos and finally follow the
# GNU standards here (see "Standard Targets for Users",
# https://www.gnu.org/prep/standards/html_node/Standard-Targets.html).
clean:
rm -rf *.rpm *.deb *.exe \
*~ counters autochecks \
precompiled cache announce*
EXCLUDE_PROPER= \
--exclude="**/.vscode" \
--exclude="**/*.code-workspace" \
--exclude="**/.idea" \
--exclude=".werks/.last" \
--exclude=".werks/.my_ids" \
--exclude="user.bazelrc" \
--exclude="remote.bazelrc"
EXCLUDE_CLEAN=$(EXCLUDE_PROPER) \
--exclude=".venv" \
--exclude=".cargo" \
--exclude="node_modules" \
--exclude=".cache"
# The list of files and folders to be protected from remove after "buildclean" is called
# Rust dirs are kept due to heavy load when compiled: .cargo, controller
HOST_PACKAGES_TARGET_PATH=packages/target
EXCLUDE_BUILD_CLEAN=$(EXCLUDE_CLEAN) \
--exclude=".cargo" \
--exclude=$(HOST_PACKAGES_TARGET_PATH)
mrproper:
git clean -d --force -x $(EXCLUDE_PROPER)
mrclean:
git clean -d --force -x $(EXCLUDE_CLEAN)
# Used by our version build (buildscripts/scripts/build-cmk-version.jenkins)
# for cleaning up while keeping some build artifacts between version builds.
# This helps to speed up "make dist"
buildclean:
git clean -d --force -x $(EXCLUDE_BUILD_CLEAN)
setup:
sudo buildscripts/infrastructure/build-nodes/scripts/install-development.sh --profile all
sudo bash -c 'usermod -a -G docker $$SUDO_USER'
linesofcode:
@wc -l $$(find -type f -name "*.py" -o -name "*.js" -o -name "*.cc" -o -name "*.h" -o -name "*.css" | grep -v openhardwaremonitor | grep -v jquery ) | sort -n
format:
bazel run //:format
what-gerrit-makes:
$(MAKE) -C tests what-gerrit-makes
documentation:
echo Nothing to do here remove this target
update_venv:
echo > requirements.txt
bazel run //:lock_python_requirements > /dev/null
relock_venv:
bazel run //:lock_python_requirements > /dev/null
ifeq ($(EDITION),community)
# Bazel cannot `select()` tests in a `test_suite` and cannot `alias` tests.
# See discussion under https://github.com/bazelbuild/bazel/issues/11458
PYTHON_REQUIREMENTS_TEST = //:py_requirements_test_gpl
else
PYTHON_REQUIREMENTS_TEST = //:py_requirements_test_nonfree
endif
check_python_requirements:
@set -e; \
if ! bazel test $(if $(EDITION),--cmk_edition=$(EDITION)) $(PYTHON_REQUIREMENTS_TEST); then \
if [ "${CI}" == "true" ]; then \
echo "A locking of python requirements is needed, but we're executed in the CI, where this should not be done."; \
echo "It seems you forgot to commit the new lock file. Regenerate with: bazel run //:lock_python_requirements"; \
exit 1; \
fi; \
fi;
# .venv is PHONY because the dependencies are resolved by bazel
.venv: check_python_requirements
bazel run //:create_venv
test-github-actions:
EDITION=community bazel run //:format.check
EDITION=community bazel lint --fixes=false ...
EDITION=community make -C tests test-unit
bazel build --config=mypy ...