|
1 | 1 | #!/usr/bin/make |
2 | | -# |
3 | | -lo_version="7.3" |
| 2 | +# pyenv is a requirement, with the 3.13 python version, and virtualenv installed in it |
| 3 | +# plone parameter must be passed to create environment 'make setup plone=6.1' or after a make cleanall |
| 4 | +# The original Makefile can be found on https://github.com/IMIO/scripts-buildout |
4 | 5 |
|
5 | | -args = $(filter-out $@,$(MAKECMDGOALS)) |
| 6 | +SHELL=/bin/bash |
| 7 | +plones=6.1 |
| 8 | +lo_version=7.3 |
| 9 | +b_o= |
| 10 | +old_plone=$(shell [ -e .plone-version ] && cat .plone-version) |
| 11 | + |
| 12 | +ifeq (, $(shell which pyenv)) |
| 13 | + $(error "pyenv command not found! Aborting") |
| 14 | +endif |
| 15 | + |
| 16 | +ifndef plone |
| 17 | +ifeq (,$(filter setup,$(MAKECMDGOALS))) |
| 18 | + plone=$(old_plone) |
| 19 | +endif |
| 20 | +endif |
| 21 | + |
| 22 | +ifneq ($(wildcard bin/instance),) |
| 23 | + b_o=-N |
| 24 | +endif |
| 25 | + |
| 26 | +ifndef python |
| 27 | +ifeq ($(plone),6.1) |
| 28 | + python=3.13 |
| 29 | +endif |
| 30 | +endif |
6 | 31 |
|
7 | 32 | all: run |
8 | | -py:=3.9 |
9 | 33 |
|
10 | | -.PHONY: bootstrap buildout run test cleanall startlibreoffice stoplibreoffice |
11 | | -bootstrap: |
12 | | - virtualenv -p python$(py) . |
13 | | - bin/pip install -r requirements.txt |
| 34 | +.PHONY: help |
| 35 | +help: |
| 36 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) |
14 | 37 |
|
15 | | -buildout: |
16 | | - if ! test -f bin/buildout;then make bootstrap;fi |
17 | | - bin/buildout -Nt 5 |
| 38 | +.python-version: ## Setups pyenv version |
| 39 | + @pyenv local `pyenv versions |grep " $(python)" |tail -1 |xargs` |
| 40 | + @echo "Local pyenv version is `cat .python-version`" |
| 41 | + @ 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 |
18 | 42 |
|
19 | | -run: |
20 | | - if ! test -f bin/instance;then make buildout;fi |
| 43 | +bin/buildout: .python-version ## Setups environment |
| 44 | + virtualenv . |
| 45 | + ./bin/pip install --upgrade pip |
| 46 | + ./bin/pip install -r requirements-$(plone).txt |
| 47 | + @echo "$(plone)" > .plone-version |
| 48 | + |
| 49 | +.PHONY: setup |
| 50 | +setup: oneof-plone backup cleanall bin/buildout restore ## Setups environment for the given plone= version |
| 51 | + |
| 52 | +.PHONY: buildout |
| 53 | +buildout: oneof-plone bin/buildout ## Runs setup and buildout |
| 54 | + bin/buildout -t 5 -c test-$(plone).cfg ${b_o} |
| 55 | + |
| 56 | +.PHONY: run |
| 57 | +run: buildout ## Starts the instance in foreground |
21 | 58 | mkdir -p var/tmp |
22 | | - make startlibreoffice |
| 59 | + $(MAKE) startlibreoffice |
23 | 60 | bin/instance fg |
24 | 61 |
|
25 | | -test: |
26 | | - if ! test -f bin/test;then make buildout;fi |
27 | | - make startlibreoffice |
| 62 | +.PHONY: test |
| 63 | +test: oneof-plone bin/buildout ## Runs the tests without robot |
| 64 | + # can be run by example with: make test opt='-t "settings"' |
| 65 | + $(MAKE) startlibreoffice |
28 | 66 | rm -fr htmlcov |
29 | 67 | bin/translation-manage -c |
30 | | - if test -z "$(args)" ;then bin/test;else bin/test -t $(args);fi |
31 | | - make stoplibreoffice |
32 | | - |
33 | | -cleanall: |
34 | | - rm -fr bin develop-eggs devel htmlcov include .installed.cfg lib .mr.developer.cfg parts downloads eggs local |
35 | | - |
36 | | -startlibreoffice: |
37 | | - make stoplibreoffice |
38 | | - docker run -p 2002:2002\ |
39 | | - -d \ |
40 | | - --rm \ |
41 | | - --pull always \ |
42 | | - --name="oo_server" \ |
43 | | - -v /tmp:/tmp \ |
44 | | - -v /var/tmp:/var/tmp \ |
45 | | - harbor.imio.be/library/libreoffice:$(lo_version) |
| 68 | + bin/test -t \!robot ${opt} |
| 69 | + $(MAKE) stoplibreoffice |
| 70 | + |
| 71 | +.PHONY: cleanall |
| 72 | +cleanall: ## Cleans all installed buildout files |
| 73 | + rm -fr bin include lib local share develop-eggs downloads eggs parts htmlcov .installed.cfg .mr.developer.cfg .python-version pyvenv.cfg |
| 74 | + |
| 75 | +.PHONY: backup |
| 76 | +backup: ## Backups db files |
| 77 | + @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 |
| 78 | + |
| 79 | +.PHONY: restore |
| 80 | +restore: ## Restores db files |
| 81 | + @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 |
| 82 | + |
| 83 | +.PHONY: which-python |
| 84 | +which-python: oneof-plone ## Displays versions information |
| 85 | + @echo "current plone = $(old_plone)" |
| 86 | + @echo "current python = `cat .python-version`" |
| 87 | + @echo "plone var = $(plone)" |
| 88 | + @echo "python var = $(python)" |
| 89 | + |
| 90 | +.PHONY: vcr |
| 91 | +vcr: ## Shows requirements in checkversion-r.html |
| 92 | + @bin/versioncheck -rbo checkversion-r-$(plone).html test-$(plone).cfg |
| 93 | + |
| 94 | +.PHONY: vcn |
| 95 | +vcn: ## Shows newer packages in checkversion-n.html |
| 96 | + @bin/versioncheck -npbo checkversion-n-$(plone).html test-$(plone).cfg |
| 97 | + |
| 98 | +.PHONY: startlibreoffice |
| 99 | +startlibreoffice: ## Starts the LibreOffice server container |
| 100 | + $(MAKE) stoplibreoffice |
| 101 | + docker run -p 2002:2002 -d --rm --pull always --name="oo_server" \ |
| 102 | + -v /tmp:/tmp -v /var/tmp:/var/tmp \ |
| 103 | + harbor.imio.be/library/libreoffice:$(lo_version) |
46 | 104 | docker ps |
47 | 105 |
|
48 | | -stoplibreoffice: |
| 106 | +.PHONY: stoplibreoffice |
| 107 | +stoplibreoffice: ## Stops the LibreOffice server container |
49 | 108 | if docker ps | grep oo_server;then docker stop oo_server;fi |
| 109 | + |
| 110 | +.PHONY: guard-% |
| 111 | +guard-%: |
| 112 | + @ if [ "${${*}}" = "" ]; then echo "You must give a value for variable '$*' : like $*=xxx"; exit 1; fi |
| 113 | + |
| 114 | +.PHONY: oneof-% |
| 115 | +oneof-%: |
| 116 | + @ if ! echo "${${*}s}" | tr " " '\n' |grep -Fqx "${${*}}"; then echo "Invalid '$*' parameter ('${${*}}') : must be one of '${${*}s}'"; exit 1; fi |
0 commit comments