Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
197 lines (174 loc) · 6.99 KB
/
Copy pathMakefile
File metadata and controls
197 lines (174 loc) · 6.99 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
buildroot = /
docdir = /usr/share/doc/packages
python_version = 3
python_lookup_name = python$(python_version)
python = $(shell which $(python_lookup_name))
sc_disable = SC1091,SC1090,SC2001,SC2174,SC1117,SC2048,SC2004,SC2317,SC2329
LC = LC_MESSAGES
boxbuild_dir = tools/kiwi-boxbuild
# Select dependency versions which are compatible with the
# rust-version of kiwi-boxbuild when the Cargo.lock is created
boxbuild_cargo = CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo
version := $(shell \
$(python) -c \
'from kiwi.version import __version__; print(__version__)'\
)
install_dracut:
for dracut in dracut/modules.d/*; do \
${MAKE} -C $$dracut install ;\
done
install_package_docs:
install -d -m 755 ${buildroot}${docdir}/python-kiwi
install -m 644 LICENSE \
${buildroot}${docdir}/python-kiwi/LICENSE
install -m 644 README.rst \
${buildroot}${docdir}/python-kiwi/README
boxbuild:
# compile kiwi-boxbuild, calls kiwi-ng system boxbuild in the
# boxbuild runtime container and only requires podman on the host.
# If present, the vendored crates are used, see boxbuild_vendor
cd ${boxbuild_dir} && ${boxbuild_cargo} build --release
install_boxbuild:
install -d -m 755 ${buildroot}usr/bin
install -m 755 ${boxbuild_dir}/target/release/kiwi-boxbuild \
${buildroot}usr/bin/kiwi-boxbuild
install -d -m 755 ${buildroot}usr/share/bash-completion/completions
install -m 644 ${boxbuild_dir}/completion/kiwi-boxbuild \
${buildroot}usr/share/bash-completion/completions/kiwi-boxbuild
boxbuild_test:
cd ${boxbuild_dir} && ${boxbuild_cargo} test
boxbuild_vendor:
# provide the crates kiwi-boxbuild depends on along with the
# Cargo.lock as tarball, such that kiwi-boxbuild compiles
# offline, e.g in the Open Build Service
rm -rf dist/kiwi-boxbuild-vendor
mkdir -p dist/kiwi-boxbuild-vendor/.cargo
cd ${boxbuild_dir} && ${boxbuild_cargo} vendor --quiet \
../../dist/kiwi-boxbuild-vendor/vendor > /dev/null
cp ${boxbuild_dir}/Cargo.lock dist/kiwi-boxbuild-vendor
cp package/kiwi-boxbuild-cargo-config \
dist/kiwi-boxbuild-vendor/.cargo/config.toml
tar -C dist/kiwi-boxbuild-vendor -czf dist/kiwi-boxbuild-vendor.tar.gz \
vendor Cargo.lock .cargo
rm -rf dist/kiwi-boxbuild-vendor
install:
# apart from python sources there are also
# the manual pages and the completion
# Note: These information will be missing when installed from pip
# manual pages
install -d -m 755 ${buildroot}usr/share/man/man8
for man in doc/build/man/*.8; do \
install -m 644 $$man ${buildroot}usr/share/man/man8 ;\
done
# completion
install -d -m 755 ${buildroot}usr/share/bash-completion/completions
install -m 644 completions/bash-completion \
${buildroot}usr/share/bash-completion/completions/kiwi-ng
# kiwi default configuration
install -d -m 755 ${buildroot}usr/share/kiwi
install -d -m 755 ${buildroot}usr/share/kiwi/kiwi.yml.d
install -d -m 755 ${buildroot}etc/kiwi.yml.d
install -m 644 kiwi.yml ${buildroot}usr/share/kiwi/kiwi.yml.example
# kiwi old XSL stylesheets for upgrade
cp -a helper/xsl_to_v74 ${buildroot}usr/share/kiwi/
kiwi/schema/kiwi.rng: kiwi/schema/kiwi.rnc
# whenever the schema is changed this target will convert
# the short form of the RelaxNG schema to the format used
# in code and auto generates the python data structures
@type -p trang &>/dev/null || \
(echo "ERROR: trang not found in path: $(PATH)"; exit 1)
trang -I rnc -O rng kiwi/schema/kiwi.rnc kiwi/schema/kiwi.rng
# XML parser code is auto generated from schema using generateDS
# http://pythonhosted.org/generateDS
# ---
# a) modify arch-name xsd:token pattern to be generic because
# generateDS translates the regular expression into another
# expression which is different and wrong compared to the
# expression in the schema
cat kiwi/schema/kiwi.rnc | sed -e \
s'@arch-name = xsd:token.*@arch-name = xsd:token {pattern = ".*"}@' >\
kiwi/schema/kiwi_modified_for_generateDS.rnc
# convert schema rnc format into xsd format and call generateDS
trang -I rnc -O xsd kiwi/schema/kiwi_modified_for_generateDS.rnc \
kiwi/schema/kiwi_for_generateDS.xsd
generateDS.py -f --external-encoding='utf-8' --no-dates --no-warnings \
-o kiwi/xml_parse.py kiwi/schema/kiwi_for_generateDS.xsd
rm kiwi/schema/kiwi_for_generateDS.xsd
rm kiwi/schema/kiwi_modified_for_generateDS.rnc
obs_test_status:
./.obs_test_status
valid:
for i in `find build-tests test kiwi -name *.xml -o -name *.kiwi`; do \
if [ ! -L $$i ];then \
xsltproc -o $$i.converted kiwi/xsl/master.xsl $$i && \
mv $$i.converted $$i ;\
fi \
done
setup:
poetry install --all-extras
docs: setup
poetry run make -C doc man html
ghpages: setup
poetry run sphinx-build doc/source doc/build
test_scripts: setup
poetry run bash -c 'pushd test/scripts && sudo pytest -s -vv'
check: setup
# shell code checks
find build-tests -name config.sh | xargs shellcheck
bash -c 'shellcheck -e ${sc_disable} dracut/modules.d/*/*.sh -s bash'
bash -c 'shellcheck -e ${sc_disable} kiwi/config/functions.sh -s bash'
bash -c 'shellcheck -e ${sc_disable} boxes/*/*.sh -s bash'
bash -c 'shellcheck -e ${sc_disable} boxes/images.sh -s bash'
bash -c 'shellcheck build-tests.sh'
bash -c 'shellcheck -s bash ${boxbuild_dir}/completion/kiwi-boxbuild'
# python flake tests
poetry run flake8 --statistics -j auto --count kiwi
poetry run flake8 --statistics -j auto --count test/unit
poetry run flake8 --statistics -j auto --count test/scripts
test: setup
# python static code checks
poetry run mypy kiwi
# unit tests
poetry run bash -c 'pushd test/unit && pytest -n auto \
--doctest-modules --no-cov-on-fail --cov=kiwi \
--cov-report=term-missing --cov-fail-under=100 \
--cov-config .coveragerc'
black: setup
poetry run black \
--skip-string-normalization \
--line-length 80 kiwi test/unit/
build: clean check test boxbuild_test
# build the sdist source tarball
poetry build --format=sdist
# provide rpm source tarball
mv dist/kiwi-${version}.tar.gz dist/python-kiwi.tar.gz
# update rpm changelog using reference file
helper/update_changelog.py --since package/python-kiwi.changes --fix > \
dist/python-kiwi.changes
helper/update_changelog.py --file package/python-kiwi.changes >> \
dist/python-kiwi.changes
# update package version in spec file
cat package/python-kiwi-spec-template | sed -e s'@%%VERSION@${version}@' \
> dist/python-kiwi.spec
# update package version in PKGBUILD file
md5sums=$$(md5sum dist/python-kiwi.tar.gz | cut -d" " -f1); \
cat package/python-kiwi-pkgbuild-template | sed \
-e s'@%%VERSION@${version}@' \
-e s"@%%MD5SUM@$${md5sums}@" > dist/PKGBUILD
# provide rpm rpmlintrc
cp package/python-kiwi-rpmlintrc dist
# provide additional source files
cp package/systemd-tmpfiles-for-suse.conf dist
# provide vendored crates of kiwi-boxbuild
${MAKE} boxbuild_vendor
prepare_for_pypi: clean setup
# documentation render and tests
poetry run make -C doc man
# sdist tarball, the actual publishing happens via the
# ci-publish-to-pypi.yml github action
poetry build --format=sdist
clean:
rm -rf dist
rm -rf ${boxbuild_dir}/target
rm -rf doc/build
rm -rf doc/dist