瀏覽代碼

Bring back space check

* Requires at least 25MB of space on top of required space
Paul Keith 6 年之前
父節點
當前提交
0e1baf6960
共有 1 個文件被更改,包括 12 次插入9 次删除
  1. 12 9
      build/meta/com/google/android/update-binary

+ 12 - 9
build/meta/com/google/android/update-binary

@@ -82,14 +82,8 @@ fi
 
 LOWMEM=1572864
 MEM=`grep MemTotal /proc/meminfo | awk '{ print $2 }'`
-#LOW_STORAGE=153600
-#REALLY_LOW_STORAGE=92160
-#STORAGE=`exec_util "df /system" | grep -v Filesystem | awk '{ print $4 }'`
-
-#if [ "$STORAGE" -lt "$REALLY_LOW_STORAGE" ]; then
-#  ui_print "Not enough space for GApps! Aborting"
-#  exit 1
-#fi
+STORAGE=`exec_util "df /system" | grep -v Filesystem | awk '{ print $4 }'`
+STORAGE_BUFFER=25600
 
 ui_print "Extracting files"
 cd /tmp
@@ -97,12 +91,21 @@ unzip -o "$ZIP"
 exec_util "rm -rf META-INF"
 cd system
 
-if [ "$MEM" -lt "$LOWMEM" ]; then #|| [ "$STORAGE" -lt "$LOW_STORAGE" ]; then
+NEEDED_STORAGE=`expr $(exec_util "du -s ." | awk '{ print $1 }') + $STORAGE_BUFFER`
+
+if [ "$MEM" -lt "$LOWMEM" ] || [ "$STORAGE" -lt "$NEEDED_STORAGE" ]; then
   ui_print "Low resource device detected, removing large extras"
   exec_util "rm -rf priv-app/AndroidMigratePrebuilt"
   exec_util "rm -rf priv-app/SetupWizard"
   exec_util "rm -rf priv-app/Velvet"
+  NEEDED_STORAGE=`expr $(exec_util "du -s ." | awk '{ print $1 }') + $STORAGE_BUFFER`
+  if [ "$STORAGE" -lt "$REALLY_LOW_STORAGE" ]; then
+    ui_print "Not enough space for GApps! Aborting"
+    cd .. && exec_utl "rm -rf system"
+    exit 1
+  fi
 fi
+
 ui_print "Generating addon.d file"
 cat addon.d/addond_head > addon.d/30-gapps.sh
 for f in `exec_util "find . -type f"`; do