Python always compiles imported modules. By running these targets
in a temporary directory we don't pollute the source tree.
---
Makefile.am | 29 ++++++++---------------------
autotools/run-in-tempdir | 11 +++++++++++
2 files changed, 19 insertions(+), 21 deletions(-)
create mode 100755 autotools/run-in-tempdir
diff --git a/Makefile.am b/Makefile.am
index 7be1d5b..86f9465 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,7 @@ abs_top_srcdir = @abs_top_srcdir@
ACLOCAL_AMFLAGS = -I autotools
DOCBOOK_WRAPPER = $(top_srcdir)/autotools/docbook-wrapper
BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
+RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
REPLACE_VARS_SED = autotools/replace_vars.sed
hypervisordir = $(pkgpythondir)/hypervisor
@@ -183,6 +184,7 @@ EXTRA_DIST = \
DEVNOTES \
pylintrc \
autotools/docbook-wrapper \
+ autotools/run-in-tempdir \
devel/upload.in \
$(docdot) \
$(docrst) \
@@ -274,17 +276,9 @@ doc/examples/%: doc/examples/%.in stamp-directories \
$(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
-doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) \
+doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
lib/cli.py $(gnt_scripts) tools/burnin
- TMPDIR=`mktemp -d ./buildtmpXXXXXX` && \
- cp -r scripts lib tools $$TMPDIR && \
- ( \
- CDIR=`pwd` && \
- cd $$TMPDIR && \
- mv lib ganeti && \
- PYTHONPATH=. $$CDIR/$(BUILD_BASH_COMPLETION) > $$CDIR/$@; \
- ); \
- rm -rf $$TMPDIR
+ PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
doc/%.png: doc/%.dot
@test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
@@ -388,18 +382,11 @@ stamp-directories: Makefile
touch $@
.PHONY: apidoc
-apidoc:
+apidoc: epydoc.conf $(RUN_IN_TEMPDIR)
test -e doc/api || mkdir doc/api
- TMPDIR=`mktemp -d ` && { \
- cp -r scripts daemons lib $$TMPDIR && \
- ( \
- CDIR=`pwd` && \
- cd $$TMPDIR && \
- mv lib ganeti && \
- epydoc -v --conf $$CDIR/epydoc.conf -o $$CDIR/doc/api \
- ) ; \
- rm -rf $$TMPDIR ; \
- }
+ $(RUN_IN_TEMPDIR) epydoc -v \
+ --conf $(CURDIR)/epydoc.conf \
+ --output $(CURDIR)/doc/api
.PHONY: TAGS
TAGS:
diff --git a/autotools/run-in-tempdir b/autotools/run-in-tempdir
new file mode 100755
index 0000000..4c87dfc
--- /dev/null
+++ b/autotools/run-in-tempdir
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX)
+trap "rm -rf $tmpdir" EXIT
+
+cp -r scripts lib tools test $tmpdir
+mv $tmpdir/lib $tmpdir/ganeti
+
+cd $tmpdir && "$@"
--
1.6.3.4