1CWD=$(shell pwd) 2 3YAML_FILES=$(shell find cloudinit tests tools -name "*.yaml" -type f ) 4YAML_FILES+=$(shell find doc/examples -name "cloud-config*.txt" -type f ) 5 6PYTHON = python3 7PIP_INSTALL := pip3 install 8 9ifeq ($(distro),) 10 distro = redhat 11endif 12 13READ_VERSION=$(shell $(PYTHON) $(CWD)/tools/read-version || echo read-version-failed) 14CODE_VERSION=$(shell $(PYTHON) -c "from cloudinit import version; print(version.version_string())") 15 16 17all: check 18 19check: check_version test yaml 20 21style-check: flake8 22 23flake8: 24 @$(CWD)/tools/run-flake8 25 26unittest: clean_pyc 27 python3 -m pytest -v tests/unittests cloudinit 28 29ci-deps-ubuntu: 30 @$(PYTHON) $(CWD)/tools/read-dependencies --distro ubuntu --test-distro 31 32ci-deps-centos: 33 @$(PYTHON) $(CWD)/tools/read-dependencies --distro centos --test-distro 34 35pip-requirements: 36 @echo "Installing cloud-init dependencies..." 37 $(PIP_INSTALL) -r "$@.txt" -q 38 39pip-test-requirements: 40 @echo "Installing cloud-init test dependencies..." 41 $(PIP_INSTALL) -r "$@.txt" -q 42 43test: unittest 44 45check_version: 46 @if [ "$(READ_VERSION)" != "$(CODE_VERSION)" ]; then \ 47 echo "Error: read-version version '$(READ_VERSION)'" \ 48 "not equal to code version '$(CODE_VERSION)'"; exit 2; \ 49 else true; fi 50 51config/cloud.cfg: 52 $(PYTHON) ./tools/render-cloudcfg config/cloud.cfg.tmpl config/cloud.cfg 53 54clean_pyc: 55 @find . -type f -name "*.pyc" -delete 56 @find . -type d -name __pycache__ -delete 57 58clean: clean_pyc 59 rm -rf doc/rtd_html .tox .coverage 60 61yaml: 62 @$(PYTHON) $(CWD)/tools/validate-yaml.py $(YAML_FILES) 63 64rpm: 65 $(PYTHON) ./packages/brpm --distro=$(distro) 66 67srpm: 68 $(PYTHON) ./packages/brpm --srpm --distro=$(distro) 69 70deb: 71 @which debuild || \ 72 { echo "Missing devscripts dependency. Install with:"; \ 73 echo sudo apt-get install devscripts; exit 1; } 74 75 $(PYTHON) ./packages/bddeb 76 77deb-src: 78 @which debuild || \ 79 { echo "Missing devscripts dependency. Install with:"; \ 80 echo sudo apt-get install devscripts; exit 1; } 81 $(PYTHON) ./packages/bddeb -S -d 82 83doc: 84 tox -e doc 85 86.PHONY: test flake8 clean rpm srpm deb deb-src yaml 87.PHONY: check_version pip-test-requirements pip-requirements clean_pyc 88.PHONY: unittest style-check doc 89