2013-07-24 20:41:03 +00:00
|
|
|
PYTHON ?= /usr/bin/python
|
2010-12-08 13:16:13 +00:00
|
|
|
DESTDIR ?= /
|
2018-12-12 11:38:09 +00:00
|
|
|
DOCKER ?= docker
|
2008-10-05 05:51:17 +00:00
|
|
|
|
2018-08-21 17:15:57 +00:00
|
|
|
PKGNAME = lorax-composer
|
2010-12-02 12:36:22 +00:00
|
|
|
VERSION = $(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec)
|
|
|
|
RELEASE = $(shell awk '/Release:/ { print $$2 }' $(PKGNAME).spec | sed -e 's|%.*$$||g')
|
2013-02-28 19:53:34 +00:00
|
|
|
TAG = lorax-$(VERSION)-$(RELEASE)
|
2010-12-02 12:36:22 +00:00
|
|
|
|
2018-12-12 11:38:09 +00:00
|
|
|
IMAGE_RELEASE = $(shell awk -F: '/FROM/ { print $$2}' Dockerfile.test)
|
2010-12-02 12:36:22 +00:00
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
ifeq ($(TEST_OS),)
|
|
|
|
TEST_OS = rhel-7-7
|
|
|
|
endif
|
|
|
|
export TEST_OS
|
|
|
|
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
|
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
default: all
|
2008-10-05 05:51:17 +00:00
|
|
|
|
2018-06-19 16:37:18 +00:00
|
|
|
src/composer/version.py:
|
2018-03-10 00:42:42 +00:00
|
|
|
echo "num = '$(VERSION)-$(RELEASE)'" > src/composer/version.py
|
|
|
|
|
2018-06-19 16:37:18 +00:00
|
|
|
src/pylorax/version.py:
|
2011-10-24 22:49:39 +00:00
|
|
|
echo "num = '$(VERSION)-$(RELEASE)'" > src/pylorax/version.py
|
|
|
|
|
2018-08-21 17:15:57 +00:00
|
|
|
src/pylorax/api/version.py:
|
|
|
|
echo "num = '$(VERSION)-$(RELEASE)'" > src/pylorax/api/version.py
|
|
|
|
|
|
|
|
all: src/pylorax/version.py src/pylorax/api/version.py src/composer/version.py
|
2008-10-05 05:51:17 +00:00
|
|
|
$(PYTHON) setup.py build
|
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
install: all
|
|
|
|
$(PYTHON) setup.py install --root=$(DESTDIR)
|
2013-07-26 22:01:14 +00:00
|
|
|
mkdir -p $(DESTDIR)/$(mandir)/man1
|
2017-11-16 20:14:19 +00:00
|
|
|
install -m 644 docs/man/lorax.1 $(DESTDIR)/$(mandir)/man1
|
|
|
|
install -m 644 docs/man/livemedia-creator.1 $(DESTDIR)/$(mandir)/man1
|
2018-07-31 13:39:38 +00:00
|
|
|
mkdir -p $(DESTDIR)/etc/bash_completion.d
|
2018-10-08 23:55:57 +00:00
|
|
|
install -m 644 etc/bash_completion.d/composer-cli $(DESTDIR)/etc/bash_completion.d
|
2008-10-05 05:51:17 +00:00
|
|
|
|
2017-10-04 19:11:10 +00:00
|
|
|
check:
|
|
|
|
@echo "*** Running pylint ***"
|
|
|
|
PYTHONPATH=$(PYTHONPATH):./src/ ./tests/pylint/runpylint.py
|
|
|
|
|
2018-12-13 10:32:24 +00:00
|
|
|
test: docs
|
2017-10-05 12:44:39 +00:00
|
|
|
@echo "*** Running tests ***"
|
2018-12-12 11:38:09 +00:00
|
|
|
PYTHONPATH=$(PYTHONPATH):./src/ $(PYTHON) -m nose -v --with-coverage --cover-erase --cover-branches \
|
|
|
|
--cover-package=pylorax --cover-inclusive \
|
|
|
|
./tests/pylorax/ ./tests/composer/
|
2017-10-21 20:41:39 +00:00
|
|
|
|
2017-10-05 12:44:39 +00:00
|
|
|
coverage report -m
|
|
|
|
[ -f "/usr/bin/coveralls" ] && [ -n "$(COVERALLS_REPO_TOKEN)" ] && coveralls || echo
|
2018-12-12 11:38:09 +00:00
|
|
|
|
|
|
|
# need `losetup`, which needs Docker to be in privileged mode (--privileged)
|
|
|
|
# but even so fails in Travis CI
|
|
|
|
test_images:
|
2019-02-21 14:34:37 +00:00
|
|
|
sudo -E ./tests/test_cli.sh tests/cli/test_compose_ext4-filesystem.sh \
|
2019-02-18 17:17:31 +00:00
|
|
|
tests/cli/test_compose_partitioned-disk.sh \
|
2019-02-21 14:34:37 +00:00
|
|
|
tests/cli/test_compose_tar.sh \
|
2019-02-27 13:01:28 +00:00
|
|
|
tests/cli/test_compose_qcow2.sh \
|
|
|
|
tests/cli/test_compose_live-iso.sh
|
2018-12-12 11:38:09 +00:00
|
|
|
|
|
|
|
test_aws:
|
|
|
|
sudo -E ./tests/test_cli.sh tests/cli/test_build_and_deploy_aws.sh
|
|
|
|
|
|
|
|
test_azure:
|
|
|
|
sudo -E ./tests/test_cli.sh tests/cli/test_build_and_deploy_azure.sh
|
|
|
|
|
|
|
|
test_openstack:
|
|
|
|
sudo -E ./tests/test_cli.sh tests/cli/test_build_and_deploy_openstack.sh
|
|
|
|
|
|
|
|
test_vmware:
|
|
|
|
sudo -E ./tests/test_cli.sh tests/cli/test_build_and_deploy_vmware.sh
|
2017-10-05 12:44:39 +00:00
|
|
|
|
2008-10-05 05:51:17 +00:00
|
|
|
clean:
|
2011-10-24 22:49:39 +00:00
|
|
|
-rm -rf build src/pylorax/version.py
|
2018-08-21 17:15:57 +00:00
|
|
|
-rm -rf build src/pylorax/api/version.py
|
2018-03-10 00:42:42 +00:00
|
|
|
-rm -rf build src/composer/version.py
|
2010-10-12 16:23:29 +00:00
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
tag:
|
|
|
|
git tag -f $(TAG)
|
|
|
|
|
2017-11-16 20:14:19 +00:00
|
|
|
docs:
|
|
|
|
$(MAKE) -C docs apidoc html
|
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
archive: tag
|
|
|
|
@git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(TAG) > $(PKGNAME)-$(VERSION).tar
|
2019-06-17 12:35:31 +00:00
|
|
|
@gzip -f $(PKGNAME)-$(VERSION).tar
|
2013-02-28 20:11:05 +00:00
|
|
|
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
|
2010-10-19 15:35:50 +00:00
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
srpm: archive $(PKGNAME).spec
|
|
|
|
rpmbuild -bs \
|
|
|
|
--define "_sourcedir $(CURDIR)" \
|
|
|
|
--define "_srcrpmdir $(CURDIR)" \
|
|
|
|
lorax-composer.spec
|
|
|
|
|
2010-12-02 12:36:22 +00:00
|
|
|
local:
|
2013-02-28 20:11:05 +00:00
|
|
|
@rm -rf $(PKGNAME)-$(VERSION).tar.gz
|
|
|
|
@rm -rf /var/tmp/$(PKGNAME)-$(VERSION)
|
|
|
|
@dir=$$PWD; cp -a $$dir /var/tmp/$(PKGNAME)-$(VERSION)
|
|
|
|
@rm -rf /var/tmp/$(PKGNAME)-$(VERSION)/.git
|
|
|
|
@dir=$$PWD; cd /var/tmp; tar --gzip -cSpf $$dir/$(PKGNAME)-$(VERSION).tar.gz $(PKGNAME)-$(VERSION)
|
|
|
|
@rm -rf /var/tmp/$(PKGNAME)-$(VERSION)
|
|
|
|
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
|
2017-10-05 12:44:39 +00:00
|
|
|
|
2018-12-12 11:38:09 +00:00
|
|
|
test-in-copy:
|
|
|
|
rsync -aP --exclude=.git /lorax-ro/ /lorax/
|
2019-03-06 11:59:17 +00:00
|
|
|
make -C /lorax/ ci
|
2018-12-12 11:38:09 +00:00
|
|
|
cp /lorax/.coverage /test-results/
|
|
|
|
|
2017-12-14 10:24:57 +00:00
|
|
|
test-in-docker:
|
2018-12-12 11:38:09 +00:00
|
|
|
sudo $(DOCKER) build -t welder/lorax-tests:$(IMAGE_RELEASE) -f Dockerfile.test .
|
|
|
|
sudo $(DOCKER) run --rm -it -v `pwd`/.test-results/:/test-results -v `pwd`:/lorax-ro:ro --security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make test-in-copy
|
|
|
|
|
|
|
|
docs-in-docker:
|
|
|
|
sudo $(DOCKER) run -it --rm -v `pwd`/docs/html/:/lorax/docs/html/ --security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make docs
|
2017-12-14 10:24:57 +00:00
|
|
|
|
2017-10-05 12:44:39 +00:00
|
|
|
ci: check test
|
2017-11-16 20:14:19 +00:00
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
$(VM_IMAGE): TAG=HEAD
|
|
|
|
$(VM_IMAGE): srpm bots
|
|
|
|
srpm=$(shell rpm --qf '%{Name}-%{Version}-%{Release}.src.rpm\n' -q --specfile lorax-composer.spec | head -n1) ; \
|
|
|
|
bots/image-customize -v \
|
|
|
|
--resize 20G \
|
|
|
|
--upload $$srpm:/var/tmp \
|
|
|
|
--upload $(CURDIR)/test/vm.install:/var/tmp/vm.install \
|
|
|
|
--upload $(realpath tests):/ \
|
|
|
|
--run-command "chmod +x /var/tmp/vm.install" \
|
|
|
|
--run-command "cd /var/tmp; /var/tmp/vm.install $$srpm" \
|
|
|
|
$(TEST_OS)
|
|
|
|
[ -f ~/.config/lorax-test-env ] && bots/image-customize \
|
|
|
|
--upload ~/.config/lorax-test-env:/var/tmp/lorax-test-env \
|
|
|
|
$(TEST_OS) || echo
|
|
|
|
|
|
|
|
# convenience target for the above
|
|
|
|
vm: $(VM_IMAGE)
|
|
|
|
echo $(VM_IMAGE)
|
|
|
|
|
|
|
|
vm-reset:
|
|
|
|
rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2
|
|
|
|
|
|
|
|
# checkout Cockpit's bots/ directory for standard test VM images and API to launch them
|
|
|
|
# must be from cockpit's master, as only that has current and existing images; but testvm.py API is stable
|
|
|
|
bots:
|
|
|
|
git fetch --depth=1 https://github.com/cockpit-project/cockpit.git
|
|
|
|
git checkout --force FETCH_HEAD -- bots/
|
|
|
|
git reset bots
|
|
|
|
|
2017-11-16 20:14:19 +00:00
|
|
|
.PHONY: all install check test clean tag docs archive local
|
2018-12-12 11:38:09 +00:00
|
|
|
|
|
|
|
.PHONY: ci_after_success
|
|
|
|
ci_after_success:
|
|
|
|
# nothing to do here, but Jenkins expects this to be present, otherwise fails
|