Fix -nonet targets (zope3-buildout)
Stefan Bund [Fri, 23 Jul 2010 22:48:35 +0000 (00:48 +0200)]
Makefile.master
Makefile.pil
Makefile.plone3-buildout
Makefile.pybase
Makefile.zope3-buildout

index 4931d11..22ff4b6 100644 (file)
@@ -37,9 +37,9 @@
 # .env::
 #     Called to add environment variables to be set when executing a shell
 #     Use @$(env) <var> <value> to add a variable settings. <var> may be
-#         PATH         Add <value> to PATH
-#         PYTHONPATH   Add <value> to PYTHONPATH
-#         <other>      Set variable to <value>
+#        PATH         Add <value> to PATH
+#        PYTHONPATH   Add <value> to PYTHONPATH
+#        <other>      Set variable to <value>
 # 
 # clean::
 #     Called to clean up all generated files
@@ -51,7 +51,7 @@ BASEDIR=$(shell pwd)
 
 DLCACHE ?= dlcache
 
-default: update-nonet
+default: shorthelp
 .PHONY: default
 
 # Usage:
@@ -63,14 +63,14 @@ default: update-nonet
 # If the file exists in $(DLCACHE), it is retrieved from there instead.
 define httpget
     _httpget() {                                                       \
-        name="$${1##*/}";                                              \
+       name="$${1##*/}";                                               \
        target="$$2";                                                   \
        [ -n "$$target" ] || target="$$name";                           \
-        cache="$(DLCACHE)/$$name";                                     \
+       cache="$(DLCACHE)/$$name";                                      \
        if [ -r "$$cache" ]; then                                       \
            echo "Fetching '$$name' from cache.";                       \
        else                                                            \
-           [ -z "$(NONET)" ] || ( echo "Missing '$$1'."; exit 2 );     \
+           [ -z "$(HTTPGET_NONET)" ] || ( echo "Missing '$$1'."; exit 2 );     \
            echo "Downloading '$$1'.";                                  \
            wget -O "$$cache" "$$1";                                    \
        fi;                                                             \
@@ -79,53 +79,67 @@ define httpget
     _httpget
 endef
 
-# Usage:
-#     @$(dlegg) <package>
-#
-# Downloads egg to '$(DLCACHE)/<package>-*.egg' unless a file with that name
-# already exists.
-#
-# THIS DOES NOT WORK WITH ALL PACKAGES !!! USE WITH CARE
-define _dlegg
-    _dlegg() {                                                         \
-       if [ -r $(DLCACHE)/$$1-*.egg ]; then                            \
-           name="`cd $(DLCACHE); echo $$1-*.egg`";                     \
-           echo "Fetching '$$name' from cache.";                       \
-       else                                                            \
-           [ -z "$(NONET)" ] || ( echo "Missing '$$1'."; exit 2 );     \
-           $(EASY_INSTALL) -zmaxd $(DLCACHE) $$1;                      \
-           name="`cd $(DLCACHE); echo $$1-*.egg`";                     \
-           if [ -d $(DLCACHE)/$$name ]; then                           \
-               cd $(DLCACHE)/$$name;                                   \
-               zip -r ../$$name.zip .;                                 \
-               cd ..;                                                  \
-               rm -r $$name;                                           \
-               mv $$name.zip $$name;                                   \
-           fi;                                                         \
-       fi;                                                             \
-    }
-endef
-define dlegg
-    $(_dlegg); _dlegg
-endef
-
-# Usage:
-#     @$(install) <package>
-#
-# Downloads egg to '$(DLCACHE)/<package>-*.egg' and installs it unless a file
-# with that name already exists.
-define install
-    _install() { \
-       echo $(PIP_CACHE_FILES); \
-       echo "$(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) $$1";        \
-       $(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) "$$1";             \
-    };                                                                                 \
-    _install
-endef
-
 ###########################################################################
 # Customization targets
 
+shorthelp::
+       @echo
+       @echo "SUMMARY"
+       @echo
+       @echo "    Makefile for bootstraping and maintaining a buildout. Most important"
+       @echo "    targets are:"
+       @echo
+       @echo "        init"
+       @echo "        update-nonet"
+       @echo
+       @echo
+       @echo "MAIN TARGETS"
+       @echo
+       @echo "    shorthelp"
+       @echo "        Summary of important targets"
+       @echo
+       @echo "    help"
+       @echo "        Complete list of user-targets"
+       @echo
+       @echo "    debdepends"
+       @echo "        Install debian packages via 'aptitude' needed to satisy build"
+       @echo "        dependencies. MUST BE CALLED AS ROOT (e.g. with sudo)."
+       @echo
+       @echo "    init"
+       @echo "        Initialize buildout. Call this to either bootstrap a new project"
+       @echo "        or to initialize a new working copy. Missing packages will be"
+       @echo "        downloaded from the internet."
+       @echo
+       @echo "    init-nonet"
+       @echo "        Initialize buildout from cache. Like 'init' but does not download"
+       @echo "        any packages from the internet. Needs an up-to-date download cache."
+       @echo
+       @echo "    update"
+       @echo "        Update the buildout (calls './bin/buildout'). This target may need"
+       @echo "        network access."
+       @echo
+       @echo "    update-nonet"
+       @echo "        Update the buildout (calls './bin/buildout -No') with no network"
+       @echo "        access."
+       @echo
+       @echo "    shell"
+       @echo "        Spawn an interactive subshell with the environment set up correctly"
+       @echo "        for the local buildout."
+       @echo
+       @echo "    versions"
+       @echo "        Generate lines to be added to 'buildout.cfg' to pin all package"
+       @echo "        versions."
+       @echo
+       @echo "    clean"
+       @echo "        Remove all generated files."
+       @echo
+.PHONY: shorthelp
+
+help:: shorthelp
+       @echo
+       @echo "SECONDARY TARGETS"
+       @echo
+
 debdepends::
 .PHONY: debdepends
 
@@ -148,14 +162,16 @@ update-hook::
 bootstrap::
        sed -i -e '1s/^#!.*\/python/#!$(subst /,\/,$(PYTHON))/' $(PYTHON_DIR)/bin/*
        $(PYTHON) -c 'from zc.buildout.buildout import main; main(["bootstrap"])'
+.PHONY: bootstrap
 
 update:: update-hook
        bin/buildout $(BUILDOUT_OPTS)
+.PHONY: update
 
 define gitignore
-    _gitignore () {                                            \
+    _gitignore () {                                            \
        [ -r .gitignore ] || touch .gitignore;                  \
-        grep -qxF "$$1" .gitignore || echo "$$1" >>.gitignore; \
+       grep -qxF "$$1" .gitignore || echo "$$1" >>.gitignore;  \
     };                                                         \
     _gitignore
 endef
@@ -164,7 +180,7 @@ endef
        @$(gitignore) "*.pyc"
        @$(gitignore) "*.egg-info/"
        @$(gitignore) "/.env"
-       @$(gitignore) "/$(DLCACHE)/"
+       @$(gitignore) "/.nonet.cfg"
 
 define env
     _env () {                                                  \
@@ -173,7 +189,7 @@ define env
        PATH|PYTHONPATH) line="export $$1=\"$$2:\$$$$1\"" ;;    \
        *) line="export $$1=\"$$2\"" ;;                         \
        esac;                                                   \
-        grep -qxF "$$line" .env || echo "$$line" >>.env;       \
+       grep -qxF "$$line" .env || echo "$$line" >>.env;        \
     };                                                         \
     _env
 endef
@@ -185,40 +201,23 @@ clean::
 .PHONY: clean
 
 ###########################################################################
-# internal targets
-
-prepare-pipcache:
-       @(                                                              \
-           cd $(DLCACHE)/pip;                                          \
-           for file in *.tar.gz; do                                    \
-               name="$${file##*%2F}";                                  \
-               if [ "$$name" != "$$file" -a ! -r "$$name" ]; then      \
-                   ln -s $$file $$name || exit 1;                      \
-               fi;                                                     \
-           done                                                        \
-       )
-
-PIP_CACHE_FILES := $(shell cd $(DLCACHE)/pip; ls *.tar.gz | grep -vF '%2F')
-
-do-init-nonet: PIP_OPTS  = --no-index $(patsubst %,--find-link=file://$(BASEDIR)/$(DLCACHE)/pip/%,$(PIP_CACHE_FILES))
-do-init-nonet: BUILDOUT_OPTS = -N
-do-init-nonet: NONET=1
-do-init-nonet: init
-
-###########################################################################
 # user targets
 
 init: setup eggs buildout init-hook update-hook bootstrap update .gitignore .env
+.PHONY: init
 
-init-nonet: prepare-pipcache
-       @$(MAKE) do-init-nonet
+init-nonet: HTTPGET_NONET=1
+init-nonet: init
+.PHONY: init-nonet
 
 versions:
        @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
        @bin/buildout -vvvvv | sed -ne 's/^Picked: //p' | sort | uniq 
+.PHONY: versions
 
 shell:
        @eval "`cat .env`"; $$SHELL
+.PHONY: shell
 
-update-nonet: BUILDOUT_OPTS=-No
 update-nonet: update
+.PHONY: update-nonet
index a525436..c137d35 100644 (file)
@@ -36,3 +36,9 @@ debdepends::
 clean:: pil-clean
 
 setup:: pil
+
+help::
+       @echo "    pil-rebuild"
+       @echo "        recompile PIL plugin from source. This may be needed after"
+       @echo "        upgrading the host distribution."
+       @echo
\ No newline at end of file
index 520aa48..e39ac20 100644 (file)
@@ -2,6 +2,11 @@
 
 buildout.cfg:
        $(PASTER) create --no-interactive -t plone3_buildout . zope_password=admin
+       @sed -i -e '/\[buildout\]/ba' -eb -e:a                  \
+           -ea\\ -e 'download-cache = $(DLCACHE)/downloads'    \
+           -ea\\ -e 'extends-cache = $(DLCACHE)/extends'       \
+                buildout.cfg || ( rm -f buildout.cfg; false )
+       @mkdir -p $(DLCACHE)/downloads $(DLCACHE)/extends || ( rm -f buildout.cfg; false )
 
 ###########################################################################
 
index b9db381..75333a7 100644 (file)
@@ -13,6 +13,55 @@ EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
 PIP          = $(BASEDIR)/$(PYTHON_DIR)/bin/pip
 PASTER       = $(BASEDIR)/$(PYTHON_DIR)/bin/paster
 
+# Usage:
+#     @$(dlegg) <package>
+#
+# Downloads egg to '$(DLCACHE)/<package>-*.egg' unless a file with that name
+# already exists.
+#
+# THIS DOES NOT WORK WITH ALL PACKAGES !!! USE WITH CARE
+define dlegg
+    _dlegg() {                                                         \
+       if [ -r $(DLCACHE)/$$1-*.egg ]; then                            \
+           name="`cd $(DLCACHE); echo $$1-*.egg`";                     \
+           echo "Fetching '$$name' from cache.";                       \
+       else                                                            \
+           [ -z "$(NONET)" ] || ( echo "Missing '$$1'."; exit 2 );     \
+           $(EASY_INSTALL) -zmaxd $(DLCACHE) $$1;                      \
+           name="`cd $(DLCACHE); echo $$1-*.egg`";                     \
+           if [ -d $(DLCACHE)/$$name ]; then                           \
+               cd $(DLCACHE)/$$name;                                   \
+               zip -r ../$$name.zip .;                                 \
+               cd ..;                                                  \
+               rm -r $$name;                                           \
+               mv $$name.zip $$name;                                   \
+           fi;                                                         \
+       fi;                                                             \
+    };                                                                 \
+    _dlegg
+endef
+
+# Usage:
+#     @$(install) <package>
+#
+# Downloads egg to '$(DLCACHE)/<package>-*.egg' and installs it unless a file
+# with that name already exists.
+define install
+    _install() {                                                                       \
+       echo $(PIP_CACHE_FILES);                                                        \
+       echo "$(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) $$1";        \
+       $(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) "$$1";             \
+       cd $(DLCACHE)/pip;                                                              \
+       for file in *.tar.gz; do                                                        \
+           name="$${file##*%2F}";                                                      \
+           if [ "$$name" != "$$file" -a ! -r "$$name" ]; then                          \
+               ln -s $$file $$name || exit 1;                                          \
+           fi;                                                                         \
+       done                                                                            \
+    };                                                                                 \
+    _install
+endef
+
 ###########################################################################
 
 python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README
@@ -63,6 +112,7 @@ pip: $(PIP)
 $(PIP):
        @$(dlegg) pip
        $(EASY_INSTALL) $(DLCACHE)/pip-*.egg
+.PHONY: pip
 
 pybase: python setuptools pip
 .PHONY: pybase
@@ -84,3 +134,13 @@ eggs::
 clean:: python-clean
 
 setup:: pybase
+
+PIP_CACHE_FILES := $(shell cd $(DLCACHE)/pip; ls *.tar.gz | grep -vF '%2F')
+
+init-nonet: PIP_OPTS  = --no-index $(patsubst %,--find-link=file://$(BASEDIR)/$(DLCACHE)/pip/%,$(PIP_CACHE_FILES))
+
+help::
+       @echo "    python-rebuild"
+       @echo "        recompile python from source. This may be needed after"
+       @echo "        upgrading the host distribution."
+       @echo
\ No newline at end of file
index f79d198..6bb86c8 100644 (file)
@@ -23,12 +23,21 @@ buildout.cfg:
                 buildout.cfg || ( rm -f buildout.cfg; false )
        @mkdir -p $(DLCACHE)/downloads $(DLCACHE)/extends || ( rm -f buildout.cfg; false )
 
+buildout-net.cfg:
+       @(                                      \
+           echo "[buildout]";                  \
+           echo "extends = buildout.cfg";      \
+           echo "install-from-cache = false";  \
+           echo "newest = true";               \
+       ) >  buildout-net.cfg
+
+
 ###########################################################################
 
 eggs::
        @$(install) zopeproject
 
-buildout:: buildout.cfg
+buildout:: buildout.cfg buildout-net.cfg
 
 bootstrap::
        @[ -n "$(PROJECTNAME)" ] || (echo "PROJECTNAME not set"; exit 2)
@@ -53,9 +62,13 @@ bootstrap::
        @$(gitignore) "/var/"
        @$(gitignore) "/.installed.cfg"
 
-
 .env::
        @$(env) PATH $(BASEDIR)/bin
 
 clean::
        rm -rf log var develop-eggs parts
+
+BUILDOUT_OPTS = -c buildout-net.cfg
+
+init-nonet: BUILDOUT_OPTS =
+update-nonet: BUILDOUT_OPTS =