[PC-BSD Commits] r5795 - pcbsd/trunk/pc-sysinstall/backend

svn at pcbsd.org svn at pcbsd.org
Wed Jan 6 11:15:24 PST 2010


Author: kris
Date: 2010-01-06 11:15:24 -0800 (Wed, 06 Jan 2010)
New Revision: 5795

Modified:
   pcbsd/trunk/pc-sysinstall/backend/functions-extractimage.sh
   pcbsd/trunk/pc-sysinstall/backend/functions-installcomponents.sh
   pcbsd/trunk/pc-sysinstall/backend/functions.sh
   pcbsd/trunk/pc-sysinstall/backend/startautoinstall.sh
Log:

Updated pc-sysinstall, now use "fetch" instead of curl for network transfers, and also
provide feedback mechanism for GUIs



Modified: pcbsd/trunk/pc-sysinstall/backend/functions-extractimage.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-extractimage.sh	2010-01-06 18:39:11 UTC (rev 5794)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-extractimage.sh	2010-01-06 19:15:24 UTC (rev 5795)
@@ -92,13 +92,13 @@
   fi
 
   # Do the fetch of the archive now
-  rc_halt_echo "curl -o ${OUTFILE} ${FTPPATH}/${INSFILE}"
+  fetch_file "${FTPPATH}/${INSFILE}" "${OUTFILE}" "1"
 
   # Check to see if there is a .count file for this install
-  rc_nohalt "curl -o ${OUTFILE}.count ${FTPPATH}/${INSFILE}.count"
+  fetch_file "${FTPPATH}/${INSFILE}.count" "${OUTFILE}.count" "0"
 
   # Check to see if there is a .md5 file for this install
-  rc_nohalt "curl -o ${OUTFILE}.md5 ${FTPPATH}/${INSFILE}.md5"
+  fetch_file "${FTPPATH}/${INSFILE}.md5" "${OUTFILE}.md5" "0"
 
   # Done fetching, now reset the INSFILE to our downloaded archived
   INSFILE="${OUTFILE}" ; export INSFILE

Modified: pcbsd/trunk/pc-sysinstall/backend/functions-installcomponents.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-installcomponents.sh	2010-01-06 18:39:11 UTC (rev 5794)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-installcomponents.sh	2010-01-06 19:15:24 UTC (rev 5795)
@@ -40,8 +40,7 @@
             fi
             FTPPATH="${VAL}" 
 
-            curl -o ${FSMNT}/${COMPTMPDIR}/${CFILE} \
-	    ${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE} 2>&1 | tee -a ${LOGOUT}
+            fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
 	    RESULT="$?"
             ;;
     esac

Modified: pcbsd/trunk/pc-sysinstall/backend/functions.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions.sh	2010-01-06 18:39:11 UTC (rev 5794)
+++ pcbsd/trunk/pc-sysinstall/backend/functions.sh	2010-01-06 19:15:24 UTC (rev 5795)
@@ -157,3 +157,58 @@
 
   echo "${STR}" | tee -a ${LOGOUT} 
 };
+
+# Function which uses "fetch" to download a file, and display a progress report
+fetch_file()
+{
+
+FETCHFILE="$1"
+OUTFILE="$2"
+EXITFAILED="$3"
+
+SIZEFILE="${TMPDIR}/.fetchSize"
+EXITFILE="${TMPDIR}/.fetchExit"
+
+rm ${SIZEFILE} 2>/dev/null >/dev/null
+rm ${OUTFILE} 2>/dev/null >/dev/null
+
+fetch -s "${FETCHFILE}" >${SIZEFILE}
+SIZE="`cat ${SIZEFILE}`"
+SIZE="`expr ${SIZE} / 1024`"
+echo "FETCH: ${FETCHFILE}"
+echo "FETCH: ${OUTFILE}" >>${LOGOUT}
+
+( fetch -o ${OUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) &
+PID="$!"
+while
+z=1
+do
+
+  if [ -e "$OUTFILE" ]
+  then
+    DSIZE=`du -k ${OUTFILE} | tr -d '\t' | cut -d '/' -f 1`
+    echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}"
+    echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" >>${LOGOUT}
+  fi
+
+  # Check if the download is finished
+  ps -p ${PID} >/dev/null 2>/dev/null
+  if [ "$?" != "0" ]
+  then
+   break;
+  fi
+
+  sleep 2
+done
+
+echo "FETCHDONE"
+
+EXIT="`cat ${EXITFILE}`"
+if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ]
+then
+  exit_err "Error: Failed to download ${FETCHFILE}"
+fi
+
+return $EXIT
+
+};

Modified: pcbsd/trunk/pc-sysinstall/backend/startautoinstall.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/startautoinstall.sh	2010-01-06 18:39:11 UTC (rev 5794)
+++ pcbsd/trunk/pc-sysinstall/backend/startautoinstall.sh	2010-01-06 19:15:24 UTC (rev 5795)
@@ -60,8 +60,8 @@
   fi
 
   # Now try to fetch the remove file
-  echo "Fetching cfg with: \"curl -o ${INSTALL_CFG} ${PCCFG}\""
-  curl -o "${INSTALL_CFG}" "${PCCFG}"
+  echo "Fetching cfg with: \"fetch -o ${INSTALL_CFG} ${PCCFG}\""
+  fetch -o "${INSTALL_CFG}" "${PCCFG}"
   if [ "$?" != "0" ]
   then
     echo "ERROR: Failed to fetch ${PCCFG}, install aborted"



More information about the Commits mailing list