[PC-BSD Commits] r17829 - pcbsd/current/src-sh/pc-updatemanager

svn at pcbsd.org svn at pcbsd.org
Fri Jul 20 06:42:28 PDT 2012


Author: kris
Date: 2012-07-20 13:42:27 +0000 (Fri, 20 Jul 2012)
New Revision: 17829

Modified:
   pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager
Log:

Improve the pc-updatemanager, do some better checking when setting up
system updates, make sure files really do get copied where they need to go



Modified: pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager
===================================================================
--- pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager	2012-07-20 09:39:55 UTC (rev 17828)
+++ pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager	2012-07-20 13:42:27 UTC (rev 17829)
@@ -67,12 +67,39 @@
 	exit 1
 }
 
+# Run-command, don't halt if command exits with non-0
+rc_nohalt()
+{
+  CMD="$1"
+ 
+  if [ -z "${CMD}" ] ; then
+    exit_err "Error: missing argument in rc_nohalt()"
+  fi
+
+  ${CMD}
+}
+
+# Run-command, halt if command exits with non-0
+rc_halt()
+{
+  CMD="$1"
+
+  if [ -z "${CMD}" ] ; then
+    exit_err "Error: missing argument in rc_halt()"
+  fi
+
+  ${CMD}
+  STATUS=$?
+  if [ ${STATUS} -ne 0 ] ; then
+    exit_err "Error ${STATUS}: ${CMD}"
+  fi
+}
+
 do_check() {
 
 	# Now fetch the update file
 	fetch -o "${PATCHTMPFILE}" "${PATCHURL}" >/dev/null 2>/dev/null 
-	if [ "$?" = "0" ]
-	then
+	if [ "$?" = "0" ] ; then
 	  # If we have new update-data file, extract it
  	  cd ${AVAILDIR}/${SYSVER}
 
@@ -87,7 +114,11 @@
           rm -rf ${PATCHTMPDIR} 
 	else
 		# If not root, cleanup tmp AVAILDIR
-		if [ `id -u` != "0" ] ; then rm -rf "${AVAILDIR}" ; fi
+		if [ `id -u` != "0" ] ; then 
+			if [ -n "$AVAILDIR" -a "$AVAILDIR" != "/" ] ; then
+				rc_halt "rm -rf ${AVAILDIR}"
+			fi
+		fi
 
 		is_net_up
 		if [ $? -eq 0 ] ; then 
@@ -441,25 +472,25 @@
 
         # Rename the stagedir
 	if [ -e "$MUSTAGEDIR" ] ; then rm -rf "$MUSTAGEDIR" ; fi
-	mv ${STAGEDIR} ${MUSTAGEDIR}
+	rc_halt "mv ${STAGEDIR} ${MUSTAGEDIR}"
 	STAGEDIR="$MUSTAGEDIR"
 	
 	# Copy over the rc scripts
 	if [ ! -e "/etc/rc.backup" ] ; then
-	  cp /etc/rc /etc/rc.backup
+	  rc_halt "cp /etc/rc /etc/rc.backup"
 	fi
-	cp ${PROGDIR}/scripts/mu-rc /etc/rc
+	rc_halt "cp ${PROGDIR}/scripts/mu-rc /etc/rc"
 
 	# Copy over the update scripts
-	cp ${PROGDIR}/scripts/mu-stage1 ${STAGEDIR}/doupdate.sh
-	cp ${PROGDIR}/scripts/mu-rc ${STAGEDIR}/
-	cp ${PROGDIR}/scripts/mu-stage1 ${STAGEDIR}/
-	cp ${PROGDIR}/scripts/mu-stage2 ${STAGEDIR}/
+	rc_halt "cp ${PROGDIR}/scripts/mu-stage1 ${STAGEDIR}/doupdate.sh"
+	rc_halt "cp ${PROGDIR}/scripts/mu-rc ${STAGEDIR}/"
+	rc_halt "cp ${PROGDIR}/scripts/mu-stage1 ${STAGEDIR}/"
+	rc_halt "cp ${PROGDIR}/scripts/mu-stage2 ${STAGEDIR}/"
 }
 
 download_major_update() {
 
-	# Set the mirror locaion for this major update
+	# Set the mirror location for this major update
 	MIRRORDIR="${MIRRORURL}/${up}/`uname -m`/netinstall"
         MIRRORDIR="`echo ${MIRRORDIR} | sed -e 's|://|:::|g' | sed -e 's|//|/|g' | sed -e 's|:::|://|g'`"       
 	echo "STARTINGUPDATE: $up"



More information about the Commits mailing list