1+ # !/usr/bin/make
2+ # pyenv is a requirement, with 2.7, 3.7, 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
15
2- .PHONY : cleanall
3- cleanall :
4- rm -rf bin develop-eggs include lib parts .installed.cfg .mr.developer.cfg pyvenv.cfg
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 ) ,4.3)
27+ python =2.7
28+ endif
29+ ifeq ($(plone ) ,5.2)
30+ python =3.8
31+ endif
32+ ifeq ($(plone ) ,6.0)
33+ python =3.10
34+ endif
35+ ifeq ($(plone ) ,6.1)
36+ python =3.13
37+ endif
38+ endif
39+
40+ all : buildout
41+
42+ .PHONY : help
43+ help :
44+ @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 )
45+
46+ .python-version : # # Setups pyenv version
47+ @pyenv local ` pyenv versions | grep " $( python) " | tail -1 | xargs`
48+ @echo " Local pyenv version is ` cat .python-version` "
49+ @ 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
50+
51+ bin/buildout : .python-version # # Setups environment
52+ virtualenv .
53+ ./bin/pip install --upgrade pip
54+ ./bin/pip install -r requirements-$(plone ) .txt
55+ @echo " $( plone) " > .plone-version
56+
57+ .PHONY : setup
58+ setup : oneof-plone backup cleanall bin/buildout restore # # Setups environment
559
660.PHONY : buildout
7- buildout :
8- virtualenv -p python2 .
9- bin/pip install -r requirements.txt
10- bin/buildout
61+ buildout : oneof-plone bin/buildout # # Runs setup and buildout
62+ rm -f .installed.cfg .mr.developer.cfg
63+ bin/buildout -t 5 -c test-$(plone ) .cfg ${b_o}
64+
65+ .PHONY : test
66+ test : oneof-plone bin/buildout # # run bin/test without robot
67+ # can be run by example with: make test opt='-t "settings"'
68+ bin/test -t \! robot ${opt}
69+
70+ .PHONY : cleanall
71+ cleanall : # # Cleans all installed buildout files
72+ rm -fr bin include lib local share develop-eggs downloads eggs parts .installed.cfg .mr.developer.cfg .python-version pyvenv.cfg
73+
74+ .PHONY : backup
75+ backup : # # Backups db files
76+ @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
77+
78+ .PHONY : restore
79+ restore : # # Restores db files
80+ @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
81+
82+ .PHONY : which-python
83+ which-python : oneof-plone # # Displays versions information
84+ @echo " current plone = $( old_plone) "
85+ @echo " current python = ` cat .python-version` "
86+ @echo " plone var = $( plone) "
87+ @echo " python var = $( python) "
88+
89+ .PHONY : vcr
90+ vcr : # # Shows requirements in checkversion-r.html
91+ @bin/versioncheck -rbo checkversion-r-$(plone ) .html test-$(plone ) .cfg
92+
93+ .PHONY : vcn
94+ vcn : # # Shows newer packages in checkversion-n.html
95+ @bin/versioncheck -npbo checkversion-n-$(plone ) .html test-$(plone ) .cfg
96+
97+ .PHONY : guard-%
98+ guard-% :
99+ @ if [ " ${${* } } " = " " ]; then echo " You must give a value for variable '$* ' : like $* =xxx" ; exit 1; fi
100+
101+ .PHONY : oneof-%
102+ oneof-% :
103+ @ if ! echo " ${${* } s} " | tr " " ' \n' | grep -Fqx " ${${* } } " ; then echo " Invalid '$* ' parameter ('${${* } } ') : must be one of '${${* } s} '" ; exit 1; fi
0 commit comments