wilde: server install-kolab.sh,1.32,1.33

cvs at kolab.org cvs at kolab.org
Fri Jul 4 16:38:55 CEST 2008


Author: wilde

Update of /kolabrepository/server
In directory doto:/tmp/cvs-serv13046

Modified Files:
	install-kolab.sh 
Log Message:
Fix issue2727: tar -O is no longer needed, further improvements:
- All work is now done in an temporary working directory, so openpkg
  rpm and sh files are no longer overwritten in place.
- The buggy and somewhat obscure -i option was removed.
- Some very minor code beautification.


Index: install-kolab.sh
===================================================================
RCS file: /kolabrepository/server/install-kolab.sh,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- install-kolab.sh	5 Jun 2008 14:07:42 -0000	1.32
+++ install-kolab.sh	4 Jul 2008 14:38:53 -0000	1.33
@@ -34,15 +34,10 @@
     echo "Usage:"
     echo "  $0         (will try to determine mode of action itself)"
     echo
-    echo "  $0 -i directory/openpkg-*-*.src.sh"
-    echo "  $0 -i directory/openpkg-*-*.ix86-debian4.0.sh"
-    echo "  $0 -i directory"
-    echo
     echo "Options:"
     echo
     echo "  -H         (install the Horde groupware web client)"
     echo "  -F         (install the free/busy view frontend)"
-    echo
     echo "  -h         (display this help)"
     echo
     echo "Advanced options:"
@@ -66,15 +61,37 @@
     echo "  -O         (additional build options, used for openpkg bootstraping from source)"
 }
 
+mktmpdir() {
+  newtmp="${TMPDIR-/tmp}/install-kolab.$RANDOM.$RANDOM.$RANDOM.$$"
+  (umask 022 && mkdir "$newtmp") || {
+    echo "Could not create temporary directory! Exiting." 1>&2
+    exit 1
+  }
+  echo "$newtmp"
+}
+
+shtool_get_plattag() {
+  [ -f shtool ] || sh "$INSTALLER" -t | tar xf - shtool
+  echo `sh shtool -s platform --type=binary`-$TAG
+}
+
+populate_workdir() {
+  if [ -z "$SRCDIR" -o -z "$WORKDIR" ] ; then
+    echo "Source- or working-directory missing." 1>&2 
+    exit 1 
+  fi
+  cp "$SRCDIR"/openpkg-2*.rpm "$WORKDIR"
+  cp "$SRCDIR"/openpkg-*.sh "$WORKDIR"
+  ln -sf "$SRCDIR/00INDEX.rdf" "$WORKDIR"
+  find "$SRCDIR" -mindepth 1 -maxdepth 1 -name "*.rpm" \! -name "openpkg-2*.rpm" -exec ln -sf '{}' "$WORKDIR" \;
+}
+
 while getopts hcBXEFHi:V:p:I:u:t:O: ARGS; do
     case $ARGS in
         h) # Display help
             usage
             exit 0
             ;;
-        i) # What should be installed?
-            INSTALL="$OPTARG"
-            ;;
         V) # User specified a specific Kolab version
             KOLAB_VERSION="$OPTARG"
             ;;
@@ -123,12 +140,12 @@
     USER=$TAG
 fi
 
-if [ -n "$FLAG_HORDE" ]; then
+if [ "$FLAG_HORDE" ]; then
     DEFINE="$DEFINE -D kolabd::with_horde"
     PACKAGES="$PACKAGES horde-kolab-client"
 fi
 
-if [ -n "$FLAG_FBVIEW" ]; then
+if [ "$FLAG_FBVIEW" ]; then
     PACKAGES="$PACKAGES fbview-kronolith"
 fi
 
@@ -139,9 +156,9 @@
 R_KID=`expr $KID + 1`
 N_KID=`expr $R_KID + 1`
 
-if [ -n "$FLAG_CLEAN" -o -n "$FLAG_INDEX" ]; then
+if [ "$FLAG_CLEAN" -o "$FLAG_INDEX" ]; then
     if [ -x "$PREFIX/bin/openpkg" ]; then
-        if [ -n "$FLAG_CLEAN" ]; then
+        if [ "$FLAG_CLEAN" ]; then
             echo
             echo "This will completely wipe your installation in $PREFIX!"
             echo "Are you certain you want to do that (YES/NO)?"
@@ -154,7 +171,7 @@
                 echo "Not cleaning."
                 exit 0
             fi
-        elif [ -n "$FLAG_INDEX" ]; then
+        elif [ "$FLAG_INDEX" ]; then
             BINARY=`find . -mindepth 1 -maxdepth 1 -name "openpkg-2*.rpm" \! -name "openpkg-*.src.rpm" -print`
             if [ -z "$BINARY" ]; then
                 echo "Generating 00INDEX.rdf for source distribution ..."
@@ -171,6 +188,12 @@
     fi
 fi
 
+SRCDIR=`pwd`
+WORKDIR=`mktmpdir`
+echo "Changing to temporary working directory $WORKDIR ..."
+cd "$WORKDIR"
+populate_workdir
+
 echo
 echo "Kolab installation tag (TAG):       $TAG"
 echo "Kolab installation prefix (PREFIX): $PREFIX"
@@ -204,7 +227,7 @@
             fi
         else
             # We have a source package. Check for a matching binary
-            PLATTAG=`sh "$INSTALLER" -t | tar xf - -O shtool | sh -s platform --type=binary`-$TAG
+            PLATTAG=`shtool_get_plattag`
             BIN=`basename "$INSTALLER" .src.sh`.$PLATTAG.sh
             if [ "$BINARY" = "$BIN" ]; then
                 # There is a binary with the correct tag. Install it
@@ -222,7 +245,7 @@
 if echo "$INSTALL" | grep '\.src\.sh$' >/dev/null; then
     # install from source
     SRC="$INSTALL"
-    PLATTAG=`sh "$INSTALL" -t | tar xf - -O shtool | sh -s platform --type=binary`-$TAG
+    PLATTAG=`shtool_get_plattag`
     BIN=`basename "$INSTALL" .src.sh`.$PLATTAG.sh
     DIR=`dirname "$SRC"`
 elif echo "$INSTALL" | grep 'openpkg-.*\.sh$' >/dev/null; then
@@ -250,7 +273,7 @@
         --muid="$KID" --ruid="$R_KID" --nuid="$N_KID" \
         --mgid="$KID" --rgid="$R_KID" --ngid="$N_KID" \
         || exit $?
-    if [ -n "$FLAG_BASE" ]; then
+    if [ "$FLAG_BASE" ]; then
         echo "Created basic openpkg binary for you platform!"
         exit 0
     fi
@@ -258,7 +281,7 @@
 
 if [ -n "$BIN" ]; then
     sh "$BIN" || exit $?
-    if [ -n "$FLAG_ENV" ]; then
+    if [ "$FLAG_ENV" ]; then
         echo "Created basic openpkg environment!"
         exit 0
     fi





More information about the commits mailing list