forked from podengo-project/ipa-hcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
218 lines (185 loc) · 7.56 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
215
216
217
218
VERSION = 0.11
srcdir = .
abs_srcdir = $(shell pwd)
DEST = /
# /etc
SYSCONFDIR := $(shell rpm --eval '%{_sysconfdir}')
# /usr
PREFIX = $(shell rpm --eval '%{_prefix}')
# /usr/share
DATADIR := $(shell rpm --eval '%{_datadir}')
# /usr/bin/pythonX
PYTHON := /usr/bin/python3
# /usr/lib/pythonX.Y/site-packages
PYTHON_SITELIB := $(shell $(PYTHON) -c 'from sys import version_info as v; print("/usr/lib/python{}.{}/site-packages".format(v.major, v.minor))')
# /usr/sbin
SBINDIR := $(shell rpm --eval '%{_sbindir}')
# /usr/libexec
LIBEXECDIR := $(shell rpm --eval '%{_libexecdir}')
# /usr/lib/systemd/system
UNITDIR:= $(shell rpm --eval '%{_unitdir}')
# /usr/share/man
MANDIR:= $(shell rpm --eval '%{_mandir}')
# /var/lib
SHAREDSTATEDIR := $(shell rpm --eval '%{_sharedstatedir}')
# /var
LOCALSTATEDIR := $(shell rpm --eval '%{_localstatedir}')
INSTALL = install
INSTALL_DATAFILE = $(INSTALL) -d -m644
INSTALL_EXE = $(INSTALL) -D -m755
MKDIR_P = mkdir -p -m755
CP_PD = cp -p -d
CP_CONFIG = $(CP_PD) -n
# rpkg --outdir must be an absolute path
RPKGDIR=$(abs_srcdir)/build/rpkg
CERT = tests/clients/3ecb23bf-c99b-40ec-bec5-d884a63ddf12.pem
OPENAPI_YAML = api/public.openapi.yaml
VENV = .venv
.PHONY: all
all: test rehash lint version $(VENV)
.PHONY: clean-idm-ci
clean-idm-ci:
rm -rf config credentials
rm -f mrack.* runner.log
rm -f host-info.txt
.PHONY: clean
clean:
find -name __pycache__ | xargs rm -rf
rm -f .coverage*
rm -rf htmlcov
rm -rf .mypy_cache
rm -rf $(RPKGDIR)
rm -rf dist build *.egg-info *.dist-info
rm -rf $(VENV)
.PHONY: cleanall
cleanall: clean clean-idm-ci
rm -rf .tox .ruff_cache .mypy_cache
rm -rf ipahcc ipaserver
$(OPENAPI_YAML):
git submodule update --init
ipahcc/server/schema/%.json: contrib/convert_schema.py $(OPENAPI_YAML)
contrib/convert_schema.py
.PHONY: generate-api
generate-api:
rm -f ipahcc/server/schema/*.json
$(MAKE) ipahcc/server/schema/defs.json
.PHONY: update-api
update-api:
git submodule update --remote
$(MAKE) generate-api
.PHONY: tox
tox:
tox -p auto
.PHONY: lint
lint: ruff
tox -e format,yamllint
.PHONY: ruff
ruff:
tox -e ruff
.PHONY: version
version:
sed -i 's/^VERSION\ =\ ".*\"/VERSION = "$(VERSION)"/g' \
$(srcdir)/src/ipahcc/hccplatform.py \
$(srcdir)/src/ipahcc_auto_enrollment.py
sed -i 's/^version\ =\ ".*/version = "$(VERSION)"/g' \
$(srcdir)/pyproject.toml
sed -i 's/^version\ =\ .*/version = $(VERSION)/g' \
$(srcdir)/setup.cfg
.PHONY: rpkg
rpkg: $(OPENAPI_YAML)
@if ! test -d .git; then echo "rpkg requires a git repository" >&2; exit 2; fi
@rm -rf $(RPKGDIR)
@mkdir -p $(RPKGDIR)
rpkg local --outdir $(RPKGDIR)
rpmlint --ignore-unused-rpmlintrc --strict -r ipa-hcc.rpmlintrc $(RPKGDIR)
.PHONY: test
test:
openssl verify -purpose sslclient -CApath $(srcdir)/install/server/cacerts/ $(CERT)
.PHONY: run-idm-ci
run-idm-ci:
@# tmpfs at /root/.ansible is needed to work around an SELinux violation
@# when copying files from fusefs to mount point.
podman run -ti --rm \
-v $(PWD):/ipa-hcc:Z \
-w /ipa-hcc \
--tmpfs /root/.ansible:rw,mode=750 \
quay.io/idmops/idm-ci:latest /bin/bash
.PHONY: rehash
rehash:
openssl rehash install/server/cacerts
$(VENV):
$(PYTHON) -m venv --system-site-packages $(VENV)
$(VENV)/bin/python -m pip install --editable .
.PHONY: stubgen
stubgen:
stubgen src/ipaserver/plugins/ -o stubs/ipaserver/plugins/
stubgen src/ipaserver/install/plugins/ -o stubs/ipaserver/install/plugins/
.PHONY: install_python
install_python:
@# $(PYTHON) -m pip install -I $(srcdir) --root $(DEST) --prefix $(PREFIX) --no-deps --no-index --no-warn-script-location
$(PYTHON) setup.py install -O1 --root $(DEST) --prefix $(PREFIX)
sed -i 's/^VERSION\ =\ ".*\"/VERSION = "$(VERSION)"/g' $(DEST)$(PYTHON_SITELIB)/ipahcc/hccplatform.py
sed -i 's/^VERSION\ =\ ".*\"/VERSION = "$(VERSION)"/g' $(DEST)$(PYTHON_SITELIB)/ipahcc_auto_enrollment.py
sed -i -e "1 s|^#!.*\bpython[^ ]*|#!$(PYTHON)|" $(DEST)$(PYTHON_SITELIB)/ipahcc_auto_enrollment.py
.PHONY: install_client
install_client:
$(MKDIR_P) $(DEST)$(LIBEXECDIR)/ipa-hcc
$(CP_PD) $(DEST)$(PYTHON_SITELIB)/ipahcc_auto_enrollment.py $(DEST)$(LIBEXECDIR)/ipa-hcc/ipa-hcc-auto-enrollment
chmod 755 $(DEST)$(LIBEXECDIR)/ipa-hcc/ipa-hcc-auto-enrollment
$(MKDIR_P) $(DEST)$(UNITDIR)
$(CP_PD) $(srcdir)/install/client/systemd/ipa-hcc-auto-enrollment.service $(DEST)$(UNITDIR)/
$(MKDIR_P) $(DEST)$(SYSCONFDIR)/sysconfig
$(CP_CONFIG) $(srcdir)/install/client/sysconfig/ipa-hcc-auto-enrollment $(DEST)$(SYSCONFDIR)/sysconfig/
.PHONY: install_server_plugin
install_server_plugin:
$(MKDIR_P) $(DEST)$(SYSCONFDIR)/ipa
$(CP_CONFIG) $(srcdir)/install/server/ipa/hcc.conf $(DEST)$(SYSCONFDIR)/ipa/
$(MKDIR_P) $(DEST)$(SYSCONFDIR)/ipa/hcc
$(MKDIR_P) $(DEST)$(SBINDIR)
$(CP_PD) $(srcdir)/install/server/ipa-hcc $(DEST)$(SBINDIR)/
sed -i -e "1 s|^#!.*\bpython[^ ]*|#!$(PYTHON)|" $(DEST)$(SBINDIR)/ipa-hcc
chmod 755 $(DEST)$(SBINDIR)/ipa-hcc
$(MKDIR_P) $(DEST)$(DATADIR)/ipa-hcc/cacerts
$(CP_PD) $(srcdir)/install/server/cacerts/* $(DEST)$(DATADIR)/ipa-hcc/cacerts/
$(MKDIR_P) $(DEST)$(UNITDIR)
$(CP_PD) $(srcdir)/install/server/systemd/ipa-hcc-update.* $(DEST)$(UNITDIR)/
$(CP_PD) $(srcdir)/install/server/systemd/ipa-hcc-dbus.service $(DEST)$(UNITDIR)/
$(MKDIR_P) $(DEST)$(DATADIR)/dbus-1/system.d
$(CP_PD) $(srcdir)/install/server/dbus-1/system.d/com.redhat.console.ipahcc.conf $(DEST)$(DATADIR)/dbus-1/system.d/
$(MKDIR_P) $(DEST)$(DATADIR)/dbus-1/system-services
$(CP_PD) $(srcdir)/install/server/dbus-1/system-services/com.redhat.console.ipahcc.service $(DEST)$(DATADIR)/dbus-1/system-services/
$(MKDIR_P) $(DEST)$(LIBEXECDIR)/ipa-hcc
$(CP_PD) $(srcdir)/install/server/ipa-hcc-dbus $(DEST)$(LIBEXECDIR)/ipa-hcc/ipa-hcc-dbus
sed -i -e "1 s|^#!.*\bpython[^ ]*|#!$(PYTHON)|" $(DEST)$(LIBEXECDIR)/ipa-hcc/ipa-hcc-dbus
$(MKDIR_P) $(DEST)$(MANDIR)/man1
$(CP_PD) $(srcdir)/install/server/man/*.1 $(DEST)$(MANDIR)/man1/
$(MKDIR_P) $(DEST)$(DATADIR)/ipa/updates/
$(CP_PD) $(srcdir)/install/server/updates/85-hcc.update $(DEST)$(DATADIR)/ipa/updates/
$(MKDIR_P) $(DEST)$(DATADIR)/ipa/schema.d
$(CP_PD) $(srcdir)/install/server/schema.d/85-hcc.ldif $(DEST)$(DATADIR)/ipa/schema.d/
$(MKDIR_P) $(DEST)$(DATADIR)/ipa/ui/js/plugins/hccconfig
$(CP_PD) $(srcdir)/install/server/ui/js/plugins/hccconfig/hccconfig.js $(DEST)$(DATADIR)/ipa/ui/js/plugins/hccconfig/
$(MKDIR_P) $(DEST)$(DATADIR)/ipa/ui/js/plugins/hcchost/
$(CP_PD) $(srcdir)/install/server/ui/js/plugins/hcchost/hcchost.js $(DEST)$(DATADIR)/ipa/ui/js/plugins/hcchost/
.PHONY: install_registration_service
install_registration_service:
$(MKDIR_P) $(DEST)$(DATADIR)/ipa-hcc
$(CP_PD) $(srcdir)/install/registration/wsgi/hcc_registration_service.py $(DEST)$(DATADIR)/ipa-hcc/
$(MKDIR_P) $(DEST)$(LOCALSTATEDIR)/cache/ipa-hcc
$(MKDIR_P) $(DEST)$(SHAREDSTATEDIR)/ipa/gssproxy
$(MKDIR_P) $(DEST)$(DATADIR)/ipa/updates
$(CP_PD) $(srcdir)/install/registration/updates/86-hcc-registration-service.update $(DEST)$(DATADIR)/ipa/updates/
$(MKDIR_P) $(DEST)$(SYSCONFDIR)/httpd/conf.d
$(CP_CONFIG) $(srcdir)/install/registration/httpd/ipa-hcc.conf $(DEST)$(SYSCONFDIR)/httpd/conf.d/
$(MKDIR_P) $(DEST)$(SYSCONFDIR)/gssproxy
$(CP_CONFIG) $(srcdir)/install/registration/gssproxy/85-ipa-hcc.conf $(DEST)$(SYSCONFDIR)/gssproxy/
.PHONY: install_mockapi
install_mockapi:
$(MKDIR_P) $(DEST)$(DATADIR)/ipa-hcc
$(CP_PD) $(srcdir)/install/mockapi/wsgi/hcc_mockapi.py $(DEST)$(DATADIR)/ipa-hcc/
$(MKDIR_P) $(DEST)$(SYSCONFDIR)/httpd/conf.d
$(CP_CONFIG) $(srcdir)/install/mockapi/httpd/ipa-hcc-mockapi.conf $(DEST)$(SYSCONFDIR)/httpd/conf.d/
.PHONY: install_server
install_server: install_server_plugin install_registration_service
.PHONY: install
install: install_python install_client install_server