| 1 |
buildroot = / |
| 2 |
docdir = /usr/share/doc/packages |
| 3 |
python_version = 3 |
| 4 |
python_lookup_name = python$(python_version) |
| 5 |
python = $(shell which $(python_lookup_name)) |
| 6 |
sc_disable = SC1091,SC1090,SC2001,SC2174,SC1117,SC2048,SC2004,SC2317 |
| 7 |
|
| 8 |
LC = LC_MESSAGES |
| 9 |
|
| 10 |
version := $(shell \ |
| 11 |
$(python) -c \ |
| 12 |
'from kiwi.version import __version__; print(__version__)'\ |
| 13 |
) |
| 14 |
|
| 15 |
install_dracut: |
| 16 |
for dracut in dracut/modules.d/*; do \ |
| 17 |
${MAKE} -C $$dracut install ;\ |
| 18 |
done |
| 19 |
|
| 20 |
install_package_docs: |
| 21 |
install -d -m 755 ${buildroot}${docdir}/python-kiwi |
| 22 |
install -m 644 LICENSE \ |
| 23 |
${buildroot}${docdir}/python-kiwi/LICENSE |
| 24 |
install -m 644 README.rst \ |
| 25 |
${buildroot}${docdir}/python-kiwi/README |
| 26 |
|
| 27 |
install: |
| 28 |
# apart from python sources there are also |
| 29 |
# the manual pages and the completion |
| 30 |
# Note: These information will be missing when installed from pip |
| 31 |
# manual pages |
| 32 |
install -d -m 755 ${buildroot}usr/share/man/man8 |
| 33 |
for man in doc/build/man/*.8; do \ |
| 34 |
install -m 644 $$man ${buildroot}usr/share/man/man8 ;\ |
| 35 |
done |
| 36 |
# completion |
| 37 |
install -d -m 755 ${buildroot}usr/share/bash-completion/completions |
| 38 |
install -m 644 completions/bash-completion \ |
| 39 |
${buildroot}usr/share/bash-completion/completions/kiwi-ng |
| 40 |
# kiwi default configuration |
| 41 |
install -d -m 755 ${buildroot}usr/share/kiwi |
| 42 |
install -d -m 755 ${buildroot}usr/share/kiwi/kiwi.yml.d |
| 43 |
install -d -m 755 ${buildroot}etc/kiwi.yml.d |
| 44 |
install -m 644 kiwi.yml ${buildroot}usr/share/kiwi/kiwi.yml.example |
| 45 |
# kiwi old XSL stylesheets for upgrade |
| 46 |
cp -a helper/xsl_to_v74 ${buildroot}usr/share/kiwi/ |
| 47 |
|
| 48 |
kiwi/schema/kiwi.rng: kiwi/schema/kiwi.rnc |
| 49 |
# whenever the schema is changed this target will convert |
| 50 |
# the short form of the RelaxNG schema to the format used |
| 51 |
# in code and auto generates the python data structures |
| 52 |
@type -p trang &>/dev/null || \ |
| 53 |
(echo "ERROR: trang not found in path: $(PATH)"; exit 1) |
| 54 |
trang -I rnc -O rng kiwi/schema/kiwi.rnc kiwi/schema/kiwi.rng |
| 55 |
# XML parser code is auto generated from schema using generateDS |
| 56 |
# http://pythonhosted.org/generateDS |
| 57 |
# --- |
| 58 |
# a) modify arch-name xsd:token pattern to be generic because |
| 59 |
# generateDS translates the regular expression into another |
| 60 |
# expression which is different and wrong compared to the |
| 61 |
# expression in the schema |
| 62 |
cat kiwi/schema/kiwi.rnc | sed -e \ |
| 63 |
s'@arch-name = xsd:token.*@arch-name = xsd:token {pattern = ".*"}@' >\ |
| 64 |
kiwi/schema/kiwi_modified_for_generateDS.rnc |
| 65 |
# convert schema rnc format into xsd format and call generateDS |
| 66 |
trang -I rnc -O xsd kiwi/schema/kiwi_modified_for_generateDS.rnc \ |
| 67 |
kiwi/schema/kiwi_for_generateDS.xsd |
| 68 |
generateDS.py -f --external-encoding='utf-8' --no-dates --no-warnings \ |
| 69 |
-o kiwi/xml_parse.py kiwi/schema/kiwi_for_generateDS.xsd |
| 70 |
rm kiwi/schema/kiwi_for_generateDS.xsd |
| 71 |
rm kiwi/schema/kiwi_modified_for_generateDS.rnc |
| 72 |
|
| 73 |
obs_test_status: |
| 74 |
./.obs_test_status |
| 75 |
|
| 76 |
valid: |
| 77 |
for i in `find build-tests test kiwi -name *.xml -o -name *.kiwi`; do \ |
| 78 |
if [ ! -L $$i ];then \ |
| 79 |
xsltproc -o $$i.converted kiwi/xsl/master.xsl $$i && \ |
| 80 |
mv $$i.converted $$i ;\ |
| 81 |
fi \ |
| 82 |
done |
| 83 |
|
| 84 |
setup: |
| 85 |
poetry install --all-extras |
| 86 |
|
| 87 |
docs: setup |
| 88 |
poetry run make -C doc man html |
| 89 |
|
| 90 |
ghpages: setup |
| 91 |
poetry run sphinx-build doc/source doc/build |
| 92 |
|
| 93 |
docs_suse: setup |
| 94 |
sed -ie "s@:hidden:@@" doc/source/index.rst |
| 95 |
rm -f doc/source/index.rste |
| 96 |
poetry run make -C doc xml_suse |
| 97 |
git checkout doc/source/index.rst |
| 98 |
rm -rf doc/build/restxml |
| 99 |
mv doc/build/xml doc/build/restxml |
| 100 |
poetry run pip uninstall --yes rstxml2docbook || true |
| 101 |
poetry run pip install \ |
| 102 |
git+https://github.com/openSUSE/rstxml2docbook.git@feature/kiwi |
| 103 |
poetry run bash -c 'pushd doc && rstxml2docbook \ |
| 104 |
-v --no-split -o build/xml/book.xml build/restxml/index.xml' |
| 105 |
bash -c 'mkdir -p doc/build/images/src/png && \ |
| 106 |
cp -a doc/source/.images/* doc/build/images/src/png' |
| 107 |
cp doc/DC-kiwi doc/build/ |
| 108 |
bash -c 'pushd doc/build && daps -d DC-kiwi html' |
| 109 |
|
| 110 |
test_scripts: setup |
| 111 |
poetry run bash -c 'pushd test/scripts && sudo pytest -s -vv' |
| 112 |
|
| 113 |
check: setup |
| 114 |
# shell code checks |
| 115 |
find build-tests -name config.sh | xargs shellcheck |
| 116 |
bash -c 'shellcheck -e ${sc_disable} dracut/modules.d/*/*.sh -s bash' |
| 117 |
bash -c 'shellcheck -e ${sc_disable} kiwi/config/functions.sh -s bash' |
| 118 |
bash -c 'shellcheck -e ${sc_disable} boxes/*/*.sh -s bash' |
| 119 |
bash -c 'shellcheck -e ${sc_disable} boxes/images.sh -s bash' |
| 120 |
bash -c 'shellcheck build-tests.sh' |
| 121 |
# python flake tests |
| 122 |
poetry run flake8 --statistics -j auto --count kiwi |
| 123 |
poetry run flake8 --statistics -j auto --count test/unit |
| 124 |
poetry run flake8 --statistics -j auto --count test/scripts |
| 125 |
|
| 126 |
test: setup |
| 127 |
# python static code checks |
| 128 |
poetry run mypy kiwi |
| 129 |
# unit tests |
| 130 |
poetry run bash -c 'pushd test/unit && pytest -n auto \ |
| 131 |
--doctest-modules --no-cov-on-fail --cov=kiwi \ |
| 132 |
--cov-report=term-missing --cov-fail-under=100 \ |
| 133 |
--cov-config .coveragerc' |
| 134 |
|
| 135 |
build: clean check test |
| 136 |
# build the sdist source tarball |
| 137 |
poetry build --format=sdist |
| 138 |
# provide rpm source tarball |
| 139 |
mv dist/kiwi-${version}.tar.gz dist/python-kiwi.tar.gz |
| 140 |
# update rpm changelog using reference file |
| 141 |
helper/update_changelog.py --since package/python-kiwi.changes --fix > \ |
| 142 |
dist/python-kiwi.changes |
| 143 |
helper/update_changelog.py --file package/python-kiwi.changes >> \ |
| 144 |
dist/python-kiwi.changes |
| 145 |
# update package version in spec file |
| 146 |
cat package/python-kiwi-spec-template | sed -e s'@%%VERSION@${version}@' \ |
| 147 |
> dist/python-kiwi.spec |
| 148 |
# update package version in PKGBUILD file |
| 149 |
md5sums=$$(md5sum dist/python-kiwi.tar.gz | cut -d" " -f1); \ |
| 150 |
cat package/python-kiwi-pkgbuild-template | sed \ |
| 151 |
-e s'@%%VERSION@${version}@' \ |
| 152 |
-e s"@%%MD5SUM@$${md5sums}@" > dist/PKGBUILD |
| 153 |
# provide rpm rpmlintrc |
| 154 |
cp package/python-kiwi-rpmlintrc dist |
| 155 |
# provide additional source files |
| 156 |
cp package/systemd-tmpfiles-for-suse.conf dist |
| 157 |
|
| 158 |
prepare_for_pypi: clean setup |
| 159 |
# documentation render and tests |
| 160 |
poetry run make -C doc man |
| 161 |
# sdist tarball, the actual publishing happens via the |
| 162 |
# ci-publish-to-pypi.yml github action |
| 163 |
poetry build --format=sdist |
| 164 |
|
| 165 |
clean: |
| 166 |
rm -rf dist |
| 167 |
rm -rf doc/build |
| 168 |
rm -rf doc/dist |