From: Stefan Bund Date: Thu, 22 Jul 2010 13:45:43 +0000 (+0200) Subject: Modularize Makefile and add two skeletons: plone3 and zope3 X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=7bf602180b339a4f4cd8ae277f9f41b6dc2fbc6b;hp=0a5b8e2a4d7084420fc431f33562307ef1d9544c;p=zope-bootstrap.git Modularize Makefile and add two skeletons: plone3 and zope3 --- diff --git a/.gitignore b/.gitignore index 20834bd..b25c15b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1 @@ -/python/ -/var/ -/bin/ -/develop-eggs/ -/downloads/ -/eggs/ -/fake-eggs/ -/parts/ - -/.*.stamp -/.installed.cfg -/localeggs.cfg -/server.cfg -/bootstrap.py -/README.txt - *~ -#*# -.#* -*.egg-info/ -*.pyc diff --git a/Makefile.master b/Makefile.master index 2088dab..0e06fd1 100644 --- a/Makefile.master +++ b/Makefile.master @@ -1,117 +1,132 @@ # -*- makefile -*- -PYTHON_VERSION ?= 2.4.6 -PYTHON_URL ?= http://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz -SETUPTOOLS_URL ?= http://peak.telecommunity.com/dist/ez_setup.py -PIL_VERSION ?= 1.1.6 -PIL_URL ?= http://effbot.org/downloads/Imaging-$(PIL_VERSION).tar.gz +# +# The master makefile sets up the follosing customizable (double-colon) targtets. +# +# debdepends:: +# This optional target may be used by the user to install the necessary +# system requirements via 'aptitude'. Must be called as root +# +# setup:: +# Called for basic setup. Executed before installing the basic eggs +# +# eggs:: +# Called to install eggs +# +# buildout:: +# Called to install the buildout (e.g. call paster create) +# +# init-hook:: +# Called after the buildout is installed but BEFORE bootstraping +# +# update-hook:: +# Called BEFORE updating the buildout (e.g. before calling bin/buildout) +# +# bootstrap:: +# Called to bootstrap the buildout. Here you can add actions to be +# performed AFTER bootstraping the project whenever a bootstrap is performed +# +# update:: +# Called to update the buildout (calls bin/buildout). Here you can add +# commands to call AFTER bin/buildout returns. +# +# .gitignore:: +# Called to populate the .gitignore file. Use '@$(gitignore) ' to +# add a pattern +# +# .env:: +# Called to add environment variables to be set when executing a shell +# Use @$(env) to add a variable settings. may be +# PATH Add to PATH +# PYTHONPATH Add to PYTHONPATH +# Set variable to +# +# clean:: +# Called to clean up all generated files +# ########################################################################### -PYTHON_DIR=python BASEDIR=$(shell pwd) -PYTHON = $(BASEDIR)/$(PYTHON_DIR)/bin/python -EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install -PASTER = $(BASEDIR)/$(PYTHON_DIR)/bin/paster - default: update-nonet +.PHONY: default -debdepends: - aptitude install build-essential zlibc libjpeg62-dev libfreetype6-dev - -.PHONY: default debdepends python-unpack python-build python-rebuild python-clean python \ - setuptools eggs pil-unpack pil-build pil-rebuild pil-clean pil buildout bootstrap \ - update update-nonet shell init otherinit - -python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README -$(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README: - mkdir $(PYTHON_DIR) - wget "$(PYTHON_URL)" -O $(PYTHON_DIR)/python.tgz - tar -C $(PYTHON_DIR) -xzf $(PYTHON_DIR)/python.tgz - rm -f $(PYTHON_DIR)/python.tgz - -python-build: $(PYTHON) -$(PYTHON): - cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && ./configure --prefix=$(BASEDIR)/$(PYTHON_DIR) - cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make - cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make install - -python-rebuild: python-clean python-build - -python-clean: - cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make clean - rm -f $(PYTHON) - -python: python-unpack python-build - -setuptools: $(EASY_INSTALL) -$(EASY_INSTALL): - mkdir $(PYTHON_DIR)/Extensions - wget $(SETUPTOOLS_URL) -O $(PYTHON_DIR)/Extensions/ez_setup.py - cd $(PYTHON_DIR)/Extensions && $(PYTHON) ez_setup.py - -eggs: - $(EASY_INSTALL) ZopeSkel - $(EASY_INSTALL) zc.buildout - -pil-unpack: $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION)/README -$(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION)/README: - wget $(PIL_URL) -O $(PYTHON_DIR)/Extensions/pil.tgz - tar -C $(PYTHON_DIR)/Extensions -xzf $(PYTHON_DIR)/Extensions/pil.tgz - rm -f $(PYTHON_DIR)/Extensions/pil.tgz +########################################################################### +# Customization targets -pil-build: $(PYTHON_DIR)/bin/pilconvert.py -$(PYTHON_DIR)/bin/pilconvert.py: - cd $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION) && $(PYTHON) setup.py build --force - cd $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION) && $(PYTHON) setup.py install --force +debdepends:: +.PHONY: debdepends -pil-rebuild: pil-clean pil-build +setup:: +.PHONY: setup -pil-clean: - rm -f $(PYTHON_DIR)/bin/pilconvert.py +eggs:: +.PHONY: eggs -pil: pil-unpack pil-build +buildout:: +.PHONY: buildout -buildout: buildout.cfg -buildout.cfg: - $(PASTER) create --no-interactive -t plone3_buildout . zope_password=admin +init-hook:: +.PHONY: init-hook -versions: - @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages" - @bin/buildout -Novvvvv |sed -ne 's/^Picked: //p' | sort | uniq +update-hook:: +.PHONY: update-hook -bootstrap: +bootstrap:: sed -i -e '1s/^#!.*\/python/#!$(subst /,\/,$(PYTHON))/' $(PYTHON_DIR)/bin/* # $(PYTHON) bootstrap.py $(PYTHON) -c 'from zc.buildout.buildout import main; main(["bootstrap"])' +update:: update-hook + bin/buildout $(BUILDOUT_OPTS) + +define gitignore + _gitignore () { \ + [ -r .gitignore ] || touch .gitignore; \ + grep -qxF "$$1" .gitignore || echo "$$1" >>.gitignore; \ + }; \ + _gitignore +endef +.gitignore:: + @echo "Updating .gitignore" + @$(gitignore) "*.pyc" + @$(gitignore) "*.egg-info/" + @$(gitignore) "/.env" + +define env + _env () { \ + [ -r .env ] || touch .env; \ + case "$$1" in \ + PATH|PYTHONPATH) line="export $$1=\"$$2:\$$$$1\"" ;; \ + *) line="export $$1=\"$$2\"" ;; \ + esac; \ + grep -qxF "$$line" .env || echo "$$line" >>.env; \ + }; \ + _env +endef +.env:: + @echo "Updating .env" + +clean:: + rm -f .gitignore .env +.PHONY: clean -.gitignore: - @echo "python/" >.gitignore - @echo "var/" >>.gitignore - @echo "bin/" >>.gitignore - @echo "develop-eggs/" >>.gitignore - @echo "downloads/" >>.gitignore - @echo "eggs/" >>.gitignore - @echo "fake-eggs/" >>.gitignore - @echo "parts/" >>.gitignore - @echo "/.installed.cfg" >>.gitignore - @echo "/bootstrap.py" >>.gitignore - @echo "*.pyc" >>.gitignore - @echo "*.egg-info/" >>.gitignore +########################################################################### +# internal targets -shell: - @PATH=$(BASEDIR)/$(PYTHON_DIR)/bin:$(BASEDIR)/bin:$$PATH $$SHELL -init: python setuptools pil eggs buildout otherinit otherupdate bootstrap update .gitignore +########################################################################### +# user targets -otherinit:: +init: setup eggs buildout init-hook update-hook bootstrap update .gitignore .env -otherupdate:: +versions: + @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages" + @bin/buildout -Novvvvv | sed -ne 's/^Picked: //p' | sort | uniq -update: otherupdate - bin/buildout +shell: + @eval "`cat .env`"; $$SHELL -update-nonet: otherupdate - bin/buildout -No +update-nonet: BUILDOUT_OPTS=-No +update-nonet: update diff --git a/Makefile.pil b/Makefile.pil new file mode 100644 index 0000000..7dbcf45 --- /dev/null +++ b/Makefile.pil @@ -0,0 +1,38 @@ +# -*- makefile -*- + +PIL_VERSION ?= 1.1.6 +PIL_URL ?= http://effbot.org/downloads/Imaging-$(PIL_VERSION).tar.gz + +########################################################################### + +pil-unpack: $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION)/README +$(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION)/README: + wget $(PIL_URL) -O $(PYTHON_DIR)/Extensions/pil.tgz + tar -C $(PYTHON_DIR)/Extensions -xzf $(PYTHON_DIR)/Extensions/pil.tgz + rm -f $(PYTHON_DIR)/Extensions/pil.tgz +.PHONY: pil-unpack + +pil-build: $(PYTHON_DIR)/bin/pilconvert.py +$(PYTHON_DIR)/bin/pilconvert.py: + cd $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION) && $(PYTHON) setup.py build --force + cd $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION) && $(PYTHON) setup.py install --force +.PHONY: pil-build + +pil-rebuild: pil-clean pil-build +.PHONY: pil-rebuild + +pil-clean: + rm -f $(PYTHON_DIR)/bin/pilconvert.py +.PHONY: pil-clean + +pil: pil-unpack pil-build +.PHONY: pil + +########################################################################### + +debdepends:: + aptitude install libjpeg62-dev libfreetype6-dev + +clean:: pil-clean + +setup:: pil diff --git a/Makefile.plone3-buildout b/Makefile.plone3-buildout new file mode 100644 index 0000000..afca669 --- /dev/null +++ b/Makefile.plone3-buildout @@ -0,0 +1,28 @@ +# -*- makefile -*- + +buildout.cfg: + $(PASTER) create --no-interactive -t plone3_buildout . zope_password=admin + +########################################################################### + +eggs:: + $(EASY_INSTALL) ZopeSkel + +buildout:: buildout.cfg + +.gitignore:: + @$(gitignore) "/var/" + @$(gitignore) "/bin/" + @$(gitignore) "/develop-eggs/" + @$(gitignore) "/downloads/" + @$(gitignore) "/eggs/" + @$(gitignore) "/fake-eggs/" + @$(gitignore) "/parts/" + @$(gitignore) "/.installed.cfg" + @$(gitignore) "/bootstrap.py" + +.env:: + @$(env) PATH $(BASEDIR)/bin + +clean:: + rm -rf var bin develop-eggs downloads eggs fake-eggs parts .installed.cfg bootstrap.py diff --git a/Makefile.pybase b/Makefile.pybase new file mode 100644 index 0000000..af6dc8a --- /dev/null +++ b/Makefile.pybase @@ -0,0 +1,69 @@ +# -*- makefile -*- + +PYTHON_VERSION ?= 2.4.6 +PYTHON_URL ?= http://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz +SETUPTOOLS_URL ?= http://peak.telecommunity.com/dist/ez_setup.py + +########################################################################### + +PYTHON_DIR=python + +PYTHON = $(BASEDIR)/$(PYTHON_DIR)/bin/python +EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install +PASTER = $(BASEDIR)/$(PYTHON_DIR)/bin/paster + +########################################################################### + +python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README +$(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README: + mkdir $(PYTHON_DIR) + wget "$(PYTHON_URL)" -O $(PYTHON_DIR)/python.tgz + tar -C $(PYTHON_DIR) -xzf $(PYTHON_DIR)/python.tgz + rm -f $(PYTHON_DIR)/python.tgz +.PHONY: python-unpack + +python-build: $(PYTHON) +$(PYTHON): + cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && ./configure --prefix=$(BASEDIR)/$(PYTHON_DIR) + cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make + cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make install +.PHONY: python-build + +python-rebuild: python-clean python-build +.PHONY: python-rebuild + +python-clean: + cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make clean + rm -f $(PYTHON) +.PHONY: python-clean + +python: python-unpack python-build +.PHONY: python + +setuptools: $(EASY_INSTALL) +$(EASY_INSTALL): + mkdir $(PYTHON_DIR)/Extensions + wget $(SETUPTOOLS_URL) -O $(PYTHON_DIR)/Extensions/ez_setup.py + cd $(PYTHON_DIR)/Extensions && $(PYTHON) ez_setup.py +.PHONY: setuptools + +pybase: python setuptools +.PHONY: pybase + +########################################################################### + +debdepends:: + aptitude install build-essential zlibc + +eggs:: + $(EASY_INSTALL) zc.buildout + +.gitignore:: + @$(gitignore) /python/ + +.env:: + @$(env) PATH $(BASEDIR)/$(PYTHON_DIR)/bin + +clean:: python-clean + +setup:: pybase diff --git a/Makefile.zope3-buildout b/Makefile.zope3-buildout new file mode 100644 index 0000000..5f6edb7 --- /dev/null +++ b/Makefile.zope3-buildout @@ -0,0 +1,55 @@ +# -*- makefile -*- + +ADMINUSER ?= admin +ADMINPWD ?= admin +EGGDIR ?= downloads + +ZOPEPROJECT = $(BASEDIR)/$(PYTHON_DIR)/bin/zopeproject + +buildout.cfg: + @[ -n "$(PROJECTNAME)" ] || (echo "PROJECTNAME not set"; exit 2) + @( \ + mkdir $(BASEDIR)/temp-project && cd $(BASEDIR)/temp-project && \ + echo "zopeproject --no-buildout \"$(PROJECTNAME)\"" && \ + (echo "$(ADMINUSER)"; echo "$(ADMINPWD)"; echo "$(EGGDIR)") | $(ZOPEPROJECT) --no-buildout "$(PROJECTNAME)" && \ + mv $(PROJECTNAME)/* $(BASEDIR)/ \ + ) || ( rm -f temp-project; false ) + @(rm -rf $(BASEDIR)/temp-project) + @echo + +########################################################################### + +eggs:: + $(EASY_INSTALL) zopeproject + +buildout:: buildout.cfg + +bootstrap:: + @[ -n "$(PROJECTNAME)" ] || (echo "PROJECTNAME not set"; exit 2) + @( \ + cd bin && \ + for script in ctl debug; do \ + ( \ + echo "#!/bin/sh"; \ + echo 'cd "`dirname "$$0"`/.."'; \ + echo "exec bin/$(PROJECTNAME)-$$script"' "$$@"' \ + ) > $$script; \ + chmod ugo+rx $$script; \ + echo "Generated script '$(BASEDIR)/bin/$$script'."; \ + done \ + ) + +.gitignore:: + @$(gitignore) "/bin/" + @$(gitignore) "/develop-eggs/" + @$(gitignore) "/downloads/" + @$(gitignore) "/log/" + @$(gitignore) "/var/" + @$(gitignore) "/.installed.cfg" + + +.env:: + @$(env) PATH $(BASEDIR)/bin + +clean:: + rm -rf log var develop-eggs parts diff --git a/skel-plone3/.gitignore b/skel-plone3/.gitignore new file mode 100644 index 0000000..9ddbfec --- /dev/null +++ b/skel-plone3/.gitignore @@ -0,0 +1,22 @@ +/python/ +/var/ +/bin/ +/develop-eggs/ +/downloads/ +/eggs/ +/fake-eggs/ +/parts/ + +/.*.stamp +/.installed.cfg +/localeggs.cfg +/server.cfg +/bootstrap.py +/README.txt +/.env + +*~ +#*# +.#* +*.egg-info/ +*.pyc diff --git a/Makefile b/skel-plone3/Makefile similarity index 74% rename from Makefile rename to skel-plone3/Makefile index fd911e1..146d801 100644 --- a/Makefile +++ b/skel-plone3/Makefile @@ -5,7 +5,12 @@ PIL_VERSION = 1.1.6 ########################################################################### -include Makefile.master +MAKELIB := $(shell for lib in plone-skeleton . ..; do [ ! -r "$$lib"/Makefile.master ] || break; done; echo "`cd $$lib; pwd`" ) + +include $(MAKELIB)/Makefile.master +include $(MAKELIB)/Makefile.pybase +include $(MAKELIB)/Makefile.pil +include $(MAKELIB)/Makefile.plone3-buildout localeggs.cfg: @( \ @@ -34,9 +39,9 @@ server.cfg: ) >$@ || (rm -f $@; false) versions.cfg: - echo "[versions]" >$@ || (rm -f $@; false_) + echo "[versions]" >$@ || (rm -f $@; false) -otherupdate:: localeggs.cfg server.cfg versions.cfg +update-hook:: localeggs.cfg server.cfg versions.cfg instance: update-nonet bin/instance foreground diff --git a/buildout.cfg b/skel-plone3/buildout.cfg similarity index 100% rename from buildout.cfg rename to skel-plone3/buildout.cfg diff --git a/products/README.txt b/skel-plone3/products/README.txt similarity index 100% rename from products/README.txt rename to skel-plone3/products/README.txt diff --git a/src/README.txt b/skel-plone3/src/README.txt similarity index 100% rename from src/README.txt rename to skel-plone3/src/README.txt diff --git a/skel-zope3/Makefile b/skel-zope3/Makefile new file mode 100644 index 0000000..70060c2 --- /dev/null +++ b/skel-zope3/Makefile @@ -0,0 +1,12 @@ +# -*- makefile -*- + +PROJECTNAME := myproject + +########################################################################### + +MAKELIB := $(shell for lib in plone-skeleton . ..; do [ ! -r "$$lib"/Makefile.master ] || break; done; echo "`cd $$lib; pwd`" ) + +include $(MAKELIB)/Makefile.master +include $(MAKELIB)/Makefile.pybase +include $(MAKELIB)/Makefile.pil +include $(MAKELIB)/Makefile.zope3-buildout