| 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 |
| 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 | $(python) helper/completion_generator.py \ |
| 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 | git_attributes: |
| 85 | # the following is required to update the $Format:%H$ git attribute |
| 86 | # for details on when this target is called see setup.py |
| 87 | git archive HEAD kiwi/version.py | tar -x |
| 88 | |
| 89 | clean_git_attributes: |
| 90 | # cleanup version.py to origin state |
| 91 | # for details on when this target is called see setup.py |
| 92 | git checkout kiwi/version.py |
| 93 | |
| 94 | setup: |
| 95 | poetry install --all-extras |
| 96 | |
| 97 | docs: setup |
| 98 | poetry run make -C doc man html |
| 99 | |
| 100 | ghpages: setup |
| 101 | poetry run sphinx-build doc/source doc/build |
| 102 | poetry run pdoc kiwi \ |
| 103 | '!kiwi.cli' '!kiwi.tasks' '!kiwi.builder' '!kiwi.xml_parse' \ |
| 104 | '!kiwi.kiwi' '!kiwi.api_helper' \ |
| 105 | --logo https://osinside.github.io/kiwi/_static/kiwi-logo.png \ |
| 106 | --output-dir doc/build/api |
| 107 | |
| 108 | docs_suse: setup |
| 109 | sed -ie "s@:hidden:@@" doc/source/index.rst |
| 110 | rm -f doc/source/index.rste |
| 111 | poetry run make -C doc xml_suse |
| 112 | git checkout doc/source/index.rst |
| 113 | rm -rf doc/build/restxml |
| 114 | mv doc/build/xml doc/build/restxml |
| 115 | poetry run pip uninstall --yes rstxml2docbook || true |
| 116 | poetry run pip install \ |
| 117 | git+https://github.com/openSUSE/rstxml2docbook.git@feature/kiwi |
| 118 | poetry run bash -c 'pushd doc && rstxml2docbook \ |
| 119 | -v --no-split -o build/xml/book.xml build/restxml/index.xml' |
| 120 | bash -c 'mkdir -p doc/build/images/src/png && \ |
| 121 | cp -a doc/source/.images/* doc/build/images/src/png' |
| 122 | cp doc/DC-kiwi doc/build/ |
| 123 | bash -c 'pushd doc/build && daps -d DC-kiwi html' |
| 124 | |
| 125 | test_scripts: setup |
| 126 | poetry run bash -c 'pushd test/scripts && sudo pytest -s -vv' |
| 127 | |
| 128 | check: setup |
| 129 | # shell code checks |
| 130 | find build-tests -name config.sh | xargs shellcheck |
| 131 | bash -c 'shellcheck -e ${sc_disable} dracut/modules.d/*/*.sh -s bash' |
| 132 | bash -c 'shellcheck -e ${sc_disable} kiwi/config/functions.sh -s bash' |
| 133 | bash -c 'shellcheck build-tests.sh' |
| 134 | # python flake tests |
| 135 | poetry run flake8 --statistics -j auto --count kiwi |
| 136 | poetry run flake8 --statistics -j auto --count test/unit |
| 137 | poetry run flake8 --statistics -j auto --count test/scripts |
| 138 | |
| 139 | test: setup |
| 140 | # python static code checks |
| 141 | poetry run mypy kiwi |
| 142 | # unit tests |
| 143 | poetry run bash -c 'pushd test/unit && pytest -n 8 \ |
| 144 | --doctest-modules --no-cov-on-fail --cov=kiwi \ |
| 145 | --cov-report=term-missing --cov-fail-under=100 \ |
| 146 | --cov-config .coveragerc' |
| 147 | |
| 148 | build: clean check test |
| 149 | # build the sdist source tarball |
| 150 | poetry build --format=sdist |
| 151 | # provide rpm source tarball |
| 152 | mv dist/kiwi-${version}.tar.gz dist/python-kiwi.tar.gz |
| 153 | # update rpm changelog using reference file |
| 154 | helper/update_changelog.py --since package/python-kiwi.changes --fix > \ |
| 155 | dist/python-kiwi.changes |
| 156 | helper/update_changelog.py --file package/python-kiwi.changes >> \ |
| 157 | dist/python-kiwi.changes |
| 158 | # update package version in spec file |
| 159 | cat package/python-kiwi-spec-template | sed -e s'@%%VERSION@${version}@' \ |
| 160 | > dist/python-kiwi.spec |
| 161 | # update package version in PKGBUILD file |
| 162 | md5sums=$$(md5sum dist/python-kiwi.tar.gz | cut -d" " -f1); \ |
| 163 | cat package/python-kiwi-pkgbuild-template | sed \ |
| 164 | -e s'@%%VERSION@${version}@' \ |
| 165 | -e s"@%%MD5SUM@$${md5sums}@" > dist/PKGBUILD |
| 166 | # provide rpm rpmlintrc |
| 167 | cp package/python-kiwi-rpmlintrc dist |
| 168 | # provide patches |
| 169 | cp package/*.patch dist |
| 170 | # provide additional source files |
| 171 | cp package/systemd-tmpfiles-for-suse.conf dist |
| 172 | |
| 173 | prepare_for_pypi: clean setup |
| 174 | # documentation render and tests |
| 175 | poetry run make -C doc man |
| 176 | # sdist tarball, the actual publishing happens via the |
| 177 | # ci-publish-to-pypi.yml github action |
| 178 | poetry build --format=sdist |
| 179 | |
| 180 | clean: clean_git_attributes |
| 181 | rm -rf dist |
| 182 | rm -rf doc/build |
| 183 | rm -rf doc/dist |