]> xenbits.xen.org Git - xenclient/build.git/commitdiff
XC-665: implement percentage complete calc for verifying repo
authorChristopher Clark <cclark@zinc.(none)>
Thu, 3 Dec 2009 19:02:03 +0000 (19:02 +0000)
committerChristopher Clark <cclark@zinc.(none)>
Thu, 3 Dec 2009 19:02:03 +0000 (19:02 +0000)
target/generic/target_xenclient_installer_skeleton/install/stages/functions

index 0862d66c05b4675c083f9edaae5338a61fccf86a..ea1fd8370c2522e826adb1d9f3e41f239a751876 100644 (file)
@@ -329,6 +329,15 @@ validate_repo()
     PKG_LIST="$(package_list ${PKGDATA_FILE})"
     PERCENT=10
 
+    # Count the number of files to determine the percentage complete
+    # per file.
+    FCOUNT=0
+    for FILENAME in ${PKG_LIST} ; do
+        FCOUNT="$(( FCOUNT + 1 ))"
+    done
+    PERCENT_PER_FILE=90
+    [ "${FCOUNT}" = 0 ] || PERCENT_PER_FILE="$(( 90 / FCOUNT ))"
+
     # Validate the integrity of the downloaded packages, size and md5sum:
     for FILENAME in ${PKG_LIST} ; do
         MANIFEST_MD5SUM="$(sed -ne 's/^\(\S\+\s\+\)\{2\}\(\S\+\)\s\+\(\S\+\s\+\)\{2\}\('${FILENAME}'\)\s.*$/\2/p' <${PKGDATA_FILE})"
@@ -337,7 +346,7 @@ validate_repo()
 
         mixedgauge "Verifying: ${FILENAME}" "${PERCENT}"
         FILE_MD5SUM="$(md5sum ${FILE} | cut -f1 -d' ')"
-        PERCENT="$(( PERCENT + 50 ))" # FIXME: proper calculation
+        PERCENT="$(( PERCENT + PERCENT_PER_FILE ))"
 
         FILE_SIZE="$(ls -l ${FILE} | sed -ne 's/^\(\S\+\s\+\)\{4\}\(\S\+\)\s\+.*$/\2/p')"