Author: brane
Date: Mon Feb 16 01:28:02 2015
New Revision: 1660012

URL: http://svn.apache.org/r1660012
Log:
Make RAMdisk creation and cleanup safer on the the svn-x64-macosx buildbot 
slave.

* tools/buildbot/slaves/svn-x64-macosx/setenv.sh
  (ramconf): New variable, points to RAMdisk configuration file.

* tools/buildbot/slaves/svn-x64-macosx/mkramdisk.sh,
  tools/buildbot/slaves/svn-x64-macosx/rmramdisk.sh:
   Use ${ramconf} to save and find the RAMdisk device.
   Add extra checks to make sure that we don't attmpt to mount/unmount
   the wrong volume.

* tools/buildbot/slaves/svn-x64-macosx/svnbuild.sh,
  tools/buildbot/slaves/svn-x64-macosx/svnclean.sh:
   Pass ${ramconf} to mkramdisk.sh and rmramdisk.sh.

Modified:
    subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/mkramdisk.sh
    subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/rmramdisk.sh
    subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/setenv.sh
    subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnbuild.sh
    subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnclean.sh

Modified: subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/mkramdisk.sh
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/mkramdisk.sh?rev=1660012&r1=1660011&r2=1660012&view=diff
==============================================================================
--- subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/mkramdisk.sh 
(original)
+++ subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/mkramdisk.sh Mon Feb 
16 01:28:02 2015
@@ -24,15 +24,44 @@ if [ -z "$1" ]; then
     exit 1
 fi
 
+if [ -z "$2" ]; then
+    echo "Missing parameter: device name file"
+    exit 1
+fi
+
 volume="/Volumes/$1"
+ramconf="$2"
+
+ramconfpath=$(dirname "${ramconf}")
+if [ ! -d "${ramconfpath}" ]; then
+    echo "Missing device name parent: ${ramconfpath}"
+    exit 1
+fi
+if [ -f "${ramconf}" ]; then
+    echo "Device name file exists: ${ramconf}"
+    exit 1
+fi
 
-mount | fgrep "on ${volume} " >/dev/null || {
-    set -e
-    # Make sure we strip trailing spaces from the result of older
-    # versions of hduitil.
-    device=$(echo $(hdiutil attach -nomount ram://900000))
-    newfs_hfs -M 0700 -v "$1" "${device}"
-    hdiutil mountvol "${device}"
+if [ -d "${volume}" ]; then
+    echo "Mount point exists: ${volume}"
+    exit 1
+fi
+
+mount | grep "^/dev/disk[0-9]* on ${volume} (hfs" >/dev/null && {
+    mountpoint=$(mount | grep "^/dev/disk[0-9]* on ${volume} (hfs")
+    echo "Already mounted: ${mountpoint}"
+    exit 1
 }
 
+set -e
+echo -n "" > "${ramconf}"
+
+# Make sure we strip trailing spaces from the result of older
+# versions of hduitil.
+device=$(echo $(hdiutil attach -nomount ram://900000))
+newfs_hfs -M 0700 -v "$1" "${device}"
+hdiutil mountvol "${device}"
+
+echo -n "${device}" > "${ramconf}"
+
 exit 0

Modified: subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/rmramdisk.sh
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/rmramdisk.sh?rev=1660012&r1=1660011&r2=1660012&view=diff
==============================================================================
--- subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/rmramdisk.sh 
(original)
+++ subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/rmramdisk.sh Mon Feb 
16 01:28:02 2015
@@ -24,11 +24,38 @@ if [ -z "$1" ]; then
     exit 1
 fi
 
+if [ -z "$2" ]; then
+    echo "Missing parameter: device name file"
+    exit 1
+fi
+
 volume="/Volumes/$1"
+ramconf="$2"
+
+if [ ! -f "${ramconf}" ]; then
+    echo "Device name missing: ${ramconf}"
+    exit 1
+fi
+
+if [ ! -d "${volume}" ]; then
+    echo "Mount point missing: ${volume}"
+    exit 1
+fi
 
-mount | fgrep "on ${volume} " >/dev/null && {
-    set -e
-    hdiutil detach "${volume}" -force
+device=$(cat "${ramconf}")
+devfmt=$(echo "${device}" | grep "^/dev/disk[0-9][0-9]*$")
+if [ "${device}" != "${devfmt}" ]; then
+    echo "Invalid device name: ${device}"
+    exit 1
+fi
+
+mount | grep "^${device} on ${volume} (hfs" >/dev/null || {
+    echo "Not mounted: ${device} on ${volume}"
+    exit 1
 }
 
+set -e
+rm "${ramconf}"
+hdiutil detach "${device}" -force
+
 exit 0

Modified: subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/setenv.sh
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/setenv.sh?rev=1660012&r1=1660011&r2=1660012&view=diff
==============================================================================
--- subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/setenv.sh (original)
+++ subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/setenv.sh Mon Feb 16 
01:28:02 2015
@@ -56,6 +56,9 @@ export LIBTOOL_CONFIG
 # Set the absolute source path
 abssrc=$(pwd)
 
+# Set the path to the RAMdisk device name file
+ramconf=$(dirname "${abssrc}")/ramdisk.conf
+
 # The RAMdisk volume name is the same as the name of the builder
 volume_name=$(basename $(dirname "${abssrc}"))
 if [ -z "${volume_name}" ]; then

Modified: subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnbuild.sh
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnbuild.sh?rev=1660012&r1=1660011&r2=1660012&view=diff
==============================================================================
--- subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnbuild.sh (original)
+++ subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnbuild.sh Mon Feb 
16 01:28:02 2015
@@ -24,7 +24,7 @@ scripts=$(cd $(dirname "$0") && pwd)
 
 . ${scripts}/setenv.sh
 
-${scripts}/mkramdisk.sh ${volume_name}
+${scripts}/mkramdisk.sh ${volume_name} ${ramconf}
 
 # These are the default APR and Serf config options
 serfconfig="--with-serf=${SVNBB_SERF} --with-apxs=/usr/sbin/apxs"

Modified: subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnclean.sh
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnclean.sh?rev=1660012&r1=1660011&r2=1660012&view=diff
==============================================================================
--- subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnclean.sh (original)
+++ subversion/trunk/tools/buildbot/slaves/svn-x64-macosx/svnclean.sh Mon Feb 
16 01:28:02 2015
@@ -24,4 +24,4 @@ scripts=$(cd $(dirname "$0") && pwd)
 
 . ${scripts}/setenv.sh
 
-${scripts}/rmramdisk.sh ${volume_name}
+${scripts}/rmramdisk.sh ${volume_name} ${ramconf}


Reply via email to