|
| 1 | +#!/usr/bin/make |
| 2 | +# pyenv is a requirement, with 3.10, 3.13 python versions, and virtualenv installed in each version |
| 3 | +# plone parameter must be passed to create environment 'make setup plone=6.0' or after a make cleanall |
| 4 | +# The original Makefile can be found on https://github.com/IMIO/scripts-buildout |
| 5 | + |
| 6 | +SHELL=/bin/bash |
| 7 | +plones=4.3 5.2 6.0 6.1 |
| 8 | +b_o= |
| 9 | +old_plone=$(shell [ -e .plone-version ] && cat .plone-version) |
| 10 | + |
| 11 | +ifeq (, $(shell which pyenv)) |
| 12 | + $(error "pyenv command not found! Aborting") |
| 13 | +endif |
| 14 | + |
| 15 | +ifndef plone |
| 16 | +ifeq (,$(filter setup,$(MAKECMDGOALS))) |
| 17 | + plone=$(old_plone) |
| 18 | +endif |
| 19 | +endif |
| 20 | + |
| 21 | +ifneq ($(wildcard bin/instance),) |
| 22 | + b_o=-N |
| 23 | +endif |
| 24 | + |
| 25 | +ifndef python |
| 26 | +ifeq ($(plone),6.0) |
| 27 | + python=3.10 |
| 28 | +endif |
| 29 | +ifeq ($(plone),6.1) |
| 30 | + python=3.13 |
| 31 | +endif |
| 32 | +endif |
| 33 | + |
| 34 | +all: buildout |
| 35 | + |
| 36 | +.PHONY: help |
| 37 | +help: |
| 38 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) |
| 39 | + |
| 40 | +.python-version: ## Setups pyenv version |
| 41 | + @pyenv local `pyenv versions |grep " $(python)" |tail -1 |xargs` |
| 42 | + @echo "Local pyenv version is `cat .python-version`" |
| 43 | + @ if [[ `pyenv which virtualenv` != `pyenv prefix`* ]] ; then echo "You need to install virtualenv in `cat .python-version` pyenv python (pip install virtualenv)"; exit 1; fi |
| 44 | + |
| 45 | +bin/buildout: .python-version ## Setups environment |
| 46 | + virtualenv . |
| 47 | + ./bin/pip install --upgrade pip |
| 48 | + ./bin/pip install -r requirements-$(plone).txt |
| 49 | + @echo "$(plone)" > .plone-version |
| 50 | + |
| 51 | +.PHONY: setup |
| 52 | +setup: oneof-plone backup cleanall bin/buildout restore ## Setups environment |
| 53 | + |
| 54 | +.PHONY: buildout |
| 55 | +buildout: oneof-plone bin/buildout ## Runs setup and buildout |
| 56 | + rm -f .installed.cfg .mr.developer.cfg |
| 57 | + bin/buildout -t 5 -c test-$(plone).cfg ${b_o} |
| 58 | + |
| 59 | +.PHONY: test |
| 60 | +test: oneof-plone bin/buildout ## run bin/test without robot |
| 61 | + # can be run by example with: make test opt='-t "settings"' |
| 62 | + bin/test -t \!robot ${opt} |
| 63 | + |
| 64 | +.PHONY: cleanall |
| 65 | +cleanall: ## Cleans all installed buildout files |
| 66 | + rm -fr bin include lib local share develop-eggs downloads eggs parts .installed.cfg .mr.developer.cfg .python-version pyvenv.cfg |
| 67 | + |
| 68 | +.PHONY: backup |
| 69 | +backup: ## Backups db files |
| 70 | + @if [ '$(old_plone)' != '' ] && [ -f var/filestorage/Data.fs ]; then mv var/filestorage/Data.fs var/filestorage/Data.fs.$(old_plone); mv var/blobstorage var/blobstorage.$(old_plone); fi |
| 71 | + |
| 72 | +.PHONY: restore |
| 73 | +restore: ## Restores db files |
| 74 | + @if [ '$(plone)' != '' ] && [ -f var/filestorage/Data.fs.$(plone) ]; then mv var/filestorage/Data.fs.$(plone) var/filestorage/Data.fs; mv var/blobstorage.$(plone) var/blobstorage; fi |
| 75 | + |
| 76 | +.PHONY: which-python |
| 77 | +which-python: oneof-plone ## Displays versions information |
| 78 | + @echo "current plone = $(old_plone)" |
| 79 | + @echo "current python = `cat .python-version`" |
| 80 | + @echo "plone var = $(plone)" |
| 81 | + @echo "python var = $(python)" |
| 82 | + |
| 83 | +.PHONY: vcr |
| 84 | +vcr: ## Shows requirements in checkversion-r.html |
| 85 | + @bin/versioncheck -rbo checkversion-r-$(plone).html test-$(plone).cfg |
| 86 | + |
| 87 | +.PHONY: vcn |
| 88 | +vcn: ## Shows newer packages in checkversion-n.html |
| 89 | + @bin/versioncheck -npbo checkversion-n-$(plone).html test-$(plone).cfg |
| 90 | + |
| 91 | +.PHONY: guard-% |
| 92 | +guard-%: |
| 93 | + @ if [ "${${*}}" = "" ]; then echo "You must give a value for variable '$*' : like $*=xxx"; exit 1; fi |
| 94 | + |
| 95 | +.PHONY: oneof-% |
| 96 | +oneof-%: |
| 97 | + @ if ! echo "${${*}s}" | tr " " '\n' |grep -Fqx "${${*}}"; then echo "Invalid '$*' parameter ('${${*}}') : must be one of '${${*}s}'"; exit 1; fi |
0 commit comments