Switch devel/upload to a static file
authorIustin Pop <iustin@google.com>
Wed, 7 Nov 2012 11:49:11 +0000 (12:49 +0100)
committerIustin Pop <iustin@google.com>
Wed, 7 Nov 2012 12:07:13 +0000 (13:07 +0100)
We had twice in the past days questions about devel/upload being
"broken", since bash re-reads shell scripts during their run and this
file can get regenerated due to Makefile changes.

Since we only need this to be dynamically built for 3 variables, let's
make the file static and read those three variables when it is run,
instead of when it is built, which allows us to re-read the "latest
version" of these vars as well.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

.gitignore
Makefile.am
devel/upload [moved from devel/upload.in with 92% similarity, mode: 0755]

index 2759bc8..06c5eba 100644 (file)
@@ -47,7 +47,6 @@
 
 # devel
 /devel/clean-cluster
 
 # devel
 /devel/clean-cluster
-/devel/upload
 
 # doc
 /doc/api/
 
 # doc
 /doc/api/
index 04fb361..4dec77f 100644 (file)
@@ -157,7 +157,6 @@ CLEANFILES = \
        $(SHELL_ENV_INIT) \
        daemons/daemon-util \
        daemons/ganeti-cleaner \
        $(SHELL_ENV_INIT) \
        daemons/daemon-util \
        daemons/ganeti-cleaner \
-       devel/upload \
        $(BUILT_EXAMPLES) \
        doc/examples/bash_completion \
        doc/examples/bash_completion-debug \
        $(BUILT_EXAMPLES) \
        doc/examples/bash_completion \
        doc/examples/bash_completion-debug \
@@ -559,7 +558,6 @@ docpng = $(patsubst %.dot,%.png,$(docdot))
 # Things to build but not to install (add it to EXTRA_DIST if it should be
 # distributed)
 noinst_DATA = \
 # Things to build but not to install (add it to EXTRA_DIST if it should be
 # distributed)
 noinst_DATA = \
-       devel/upload \
        doc/html \
        $(BUILT_EXAMPLES) \
        doc/examples/bash_completion \
        doc/html \
        $(BUILT_EXAMPLES) \
        doc/examples/bash_completion \
@@ -732,7 +730,7 @@ EXTRA_DIST = \
        daemons/daemon-util.in \
        daemons/ganeti-cleaner.in \
        $(pkglib_python_scripts) \
        daemons/daemon-util.in \
        daemons/ganeti-cleaner.in \
        $(pkglib_python_scripts) \
-       devel/upload.in \
+       devel/upload \
        tools/kvm-ifup.in \
        tools/vcluster-setup.in \
        $(docdot) \
        tools/kvm-ifup.in \
        tools/vcluster-setup.in \
        $(docdot) \
@@ -1070,10 +1068,6 @@ tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
        sed -f $(REPLACE_VARS_SED) < $< > $@
        chmod +x $@
 
        sed -f $(REPLACE_VARS_SED) < $< > $@
        chmod +x $@
 
-devel/upload: devel/upload.in $(REPLACE_VARS_SED)
-       sed -f $(REPLACE_VARS_SED) < $< > $@
-       chmod u+x $@
-
 tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
        sed -f $(REPLACE_VARS_SED) < $< > $@
        chmod +x $@
 tools/vcluster-setup: tools/vcluster-setup.in $(REPLACE_VARS_SED)
        sed -f $(REPLACE_VARS_SED) < $< > $@
        chmod +x $@
old mode 100644 (file)
new mode 100755 (executable)
similarity index 92%
rename from devel/upload.in
rename to devel/upload
index 2130a9e..5fe1c74
@@ -32,9 +32,7 @@ usage() {
   exit $1
 }
 
   exit $1
 }
 
-PREFIX='@PREFIX@'
-SYSCONFDIR='@SYSCONFDIR@'
-PKGLIBDIR='@PKGLIBDIR@'
+declare -r SED="sed -f autotools/replace_vars.sed"
 
 NO_RESTART=
 NO_CRON=
 
 NO_RESTART=
 NO_CRON=
@@ -90,6 +88,12 @@ umask 0022
 # install ganeti as a real tree
 make $make_args install DESTDIR="$TXD"
 
 # install ganeti as a real tree
 make $make_args install DESTDIR="$TXD"
 
+# at this point, make has been finished, so the configuration is
+# fixed; we can read the prefix vars/etc.
+PREFIX="$(echo @PREFIX@ | $SED)"
+SYSCONFDIR="$(echo @SYSCONFDIR@ | $SED)"
+PKGLIBDIR="$(echo @PKGLIBDIR@ | $SED)"
+
 # copy additional needed files
 [ -f doc/examples/ganeti.initd ] && \
 install -D --mode=0755 doc/examples/ganeti.initd \
 # copy additional needed files
 [ -f doc/examples/ganeti.initd ] && \
 install -D --mode=0755 doc/examples/ganeti.initd \