From c5159571d0319b47232fc385ca56d6a037e46f54 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 4 Aug 2009 13:38:42 +0200
Subject: [PATCH] Simplify the devel/upload script

Instead of multiple uploads to each node, this script copies everything
as needed to the temporary directory, exactly as to be installed in the
destination machine, then runs only one rsync per host.

This is more dangerous (we can break /etc now), but for development
machines is fine.

The patch then also uploads the bash completions and the current name
for the cron job (I think that ganeti-master-cron is a deprecated name,
not that someone actually intends to upload a file named like that). A
flag --no-cron is added to skip uploading the cron file if desired.

The patch also changes rsync to propagate the file permissions.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 Makefile.am     |  1 +
 devel/upload.in | 53 +++++++++++++++++++++++++++----------------------
 2 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index da7c68942..b94bb28c6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -329,6 +329,7 @@ $(REPLACE_VARS_SED): Makefile stamp-directories
 	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
 	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
 	  echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
+	  echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
 	} > $@
 
 # We need to create symlinks because "make distcheck" will not install Python
diff --git a/devel/upload.in b/devel/upload.in
index 94759e60f..38588914e 100644
--- a/devel/upload.in
+++ b/devel/upload.in
@@ -27,14 +27,22 @@
 
 set -e
 
+PREFIX='@PREFIX@'
+SYSCONFDIR='@SYSCONFDIR@'
+PKGLIBDIR='@PKGLIBDIR@'
+
 NO_RESTART=
+NO_CRON=
 hosts=
 while [ "$#" -gt 0 ]; do
   opt="$1"
   case "$opt" in
     --no-restart)
       NO_RESTART=1
-    ;;
+      ;;
+    --no-cron)
+      NO_CRON=1
+      ;;
     -h|--help)
       echo "Usage: $0 [--no-restart] hosts..."
       exit 0
@@ -42,10 +50,10 @@ while [ "$#" -gt 0 ]; do
     -*)
       echo "Unknown option: $opt" >&2
       exit 1
-    ;;
+      ;;
     *)
       hosts="$hosts $opt"
-    ;;
+      ;;
   esac
   shift
 done
@@ -58,39 +66,36 @@ trap 'rm -rf $TXD' EXIT
 # install ganeti as a real tree
 make install DESTDIR="$TXD"
 
+# copy additional needed files
+install -D --mode=0755 doc/examples/ganeti.initd \
+  "$TXD/$SYSCONFDIR/init.d/ganeti"
+
+install -D --mode=0644 doc/examples/bash_completion \
+  "$TXD/$SYSCONFDIR/bash_completion.d/ganeti"
+
+if [ -z "$NO_CRON" ]; then
+  install -D --mode=0644 doc/examples/ganeti.cron \
+    "$TXD/$SYSCONFDIR/cron.d/ganeti"
+fi
+
+install -D --mode=0755 doc/examples/dumb-allocator \
+  "$TXD/$PKGLIBDIR/iallocators/dumb"
+
 echo ---
 
 ( cd "$TXD" && find; )
 
 echo ---
 
-PREFIX='@PREFIX@'
-
 # and now put it under $prefix on the target node(s)
 for host; do
   echo Uploading code to ${host}...
-  rsync -v -rlDc --exclude="*.py[oc]" --exclude="*.pdf" --exclude="*.html" \
-    "$TXD/$PREFIX/" \
-    root@${host}:$PREFIX/ &
-done
-wait
-
-INIT_SCRIPT="$TXD/ganeti.initd"
-install --mode=0755 doc/examples/ganeti.initd $INIT_SCRIPT
-for host; do
-  echo Uploading init script to ${host}...
-  scp $INIT_SCRIPT root@${host}:/etc/init.d/ganeti &
+  rsync -v -rplDc --exclude="*.py[oc]" --exclude="*.pdf" --exclude="*.html" \
+    "$TXD/" \
+    root@${host}:/ &
 done
 wait
 
-if [ -f ganeti-master-cron ]; then
-  for host; do
-    echo Uploading cron files to ${host}...
-    scp ganeti-master-cron root@${host}:/etc/ganeti/master-cron &
-  done
-fi
-wait
-
 if test -z "${NO_RESTART}"; then
   for host; do
     echo Restarting ganeti-noded on ${host}...
-- 
GitLab