11#! /sbin/sh
2- VER=" 1.0 .1"
2+ VER=" 1.3 .1"
33MYFOLDER=" bart"
44SDCARD=" /sdcard"
55EXTPART=" /system/sd"
6+ CACHEPART=" /cache"
67NANDSH=" nandroid-mobile.sh"
78NANDLOG=" nandroid.log"
8- RECOVERY=" foo"
9+ CONFIGFILE=" /system/sd/bart.config"
10+
911alias _GREP_=" busybox grep"
1012alias _AWK_=" busybox awk"
1113alias _MOUNT_=" busybox mount"
@@ -29,6 +31,7 @@ myecho=":"
2931ni=0
3032reboot=0
3133shutdown=0
34+ docache=1
3235
3336do_exit ()
3437{
@@ -58,6 +61,7 @@ print_usage()
5861 echo " -n --nandroid_only, use with -r or -s"
5962 echo " -v --version"
6063 echo " --verbose, verbose output during nandroid"
64+ echo " --nocache, ignore the cache partition"
6165 echo " --norecovery, ignore recovery partition"
6266 echo " --noboot, ignore boot partition"
6367 echo " --nodata, ignore data partition"
@@ -126,12 +130,68 @@ read_rom()
126130 fi
127131}
128132
133+ # make sure /system/sd and /sdcard are mounted
134+
135+ $myecho " check for /system/sd or /sd-etc"
136+
137+ if [ -e " /sd-ext" ]
138+ then
139+ EXTPART=" /sd-ext"
140+ CONFIGFILE=" /sd-ext/bart.config"
141+ else
142+ if [ -e " /system/sd" ]
143+ then
144+ EXTPART=" /system/sd"
145+ CONFIGFILE=" /sd-ext/bart.config"
146+ fi
147+ fi
148+
149+ $myecho " checking mount points..."
150+ for i in ${SDCARD} ${EXTPART}
151+ do
152+ if [ " $i " == ${EXTPART} ] && [ $nandroid_only -eq 1 ]
153+ then
154+ $myecho " nandroid_only chosed ext partition not needed..."
155+ else
156+ $myecho " checking whether $i is mounted..."
157+ mounted=` _GREP_ $i /proc/mounts | _AWK_ ' {print $2}' `
158+ if [ " $mounted " != " $i " ]
159+ then
160+ $myecho " $i is not mounted. mounting $i now..."
161+ # not mounted, mount it
162+ _MOUNT_ $i
163+ if [ $? -ne 0 ]
164+ then
165+ echo " Unable to mount $i ..."
166+ echo " "
167+ do_exit 5
168+ fi
169+ fi
170+ $myecho " $i is mounted..."
171+ fi
172+ done
173+
174+
129175# args processing
130176if [ $# -lt 1 ]
131177then
132178 print_usage
133179 exit 1
134180fi
181+
182+
183+
184+ # check for config file
185+ if [ -f $CONFIGFILE ]
186+ then
187+ $myecho " found $CONFIGFILE "
188+
189+ . $CONFIGFILE
190+
191+ fi
192+
193+
194+ # get args from command line
135195while [ -n " $1 " ]
136196do
137197 case " $1 " in
177237 shutdown=1
178238 shift
179239 ;;
240+ --nocache)
241+ $myecho " setting cache option..."
242+ docache=0
243+ shift
244+ ;;
180245 -a|--app_s)
181246 $myecho " setting app_s option..."
182247 app_s=1
281346 esac
282347done
283348
284- # make sure /system/sd and /sdcard are mounted
285- $myecho " checking mount points..."
286- for i in ${SDCARD} ${EXTPART}
287- do
288- if [ " $i " == ${EXTPART} ] && [ $nandroid_only -eq 1 ]
289- then
290- $myecho " nandroid_only chosed ext partition not needed..."
291- else
292- $myecho " checking whether $i is mounted..."
293- mounted=` _GREP_ $i /proc/mounts | _AWK_ ' {print $2}' `
294- if [ " $mounted " != " $i " ]
295- then
296- $myecho " $i is not mounted. mounting $i now..."
297- # not mounted, mount it
298- _MOUNT_ $i
299- if [ $? -ne 0 ]
300- then
301- echo " Unable to mount $i ..."
302- echo " "
303- do_exit 5
304- fi
305- fi
306- $myecho " $i is mounted..."
307- fi
308- done
309349
310350myhome=" ${SDCARD} /${MYFOLDER} "
311351rompath=" ${myhome} /${romname} "
@@ -322,7 +362,7 @@ case "$cmd" in
322362 fi
323363 rompath=" ${myhome} /${romname} "
324364 nandfolder=" ${rompath} /nandroid"
325-
365+
326366 if [ $nandroid_only -eq 1 ]
327367 then
328368 echo " "
@@ -456,6 +496,63 @@ case "$cmd" in
456496 do_exit 30
457497 fi
458498
499+ if [ $docache -eq 1 ]
500+ then
501+ compressed=0
502+ $myecho " checking for cache partition backup..."
503+ if [ -e " ${rompath} /cache-backup.tar.gz" ]
504+ then
505+ $myecho " compressed cache-backup found..."
506+ compressed=1
507+ else
508+ if [ ! -e " ${rompath} /cache-backup.tar" ]
509+ then
510+ echo " "
511+ echo " cache-backup not fount for ROM ${romname} ."
512+ echo " "
513+ do_exit 29
514+ fi
515+ $myecho " uncompressed cache-backup found..."
516+ fi
517+ # proceed with restoring cache
518+ echo " Cleaning up /cache..."
519+ cd ${CACHEPART}
520+ _RM_ -rf ` _LS_ -d * | grep -v -e " ^recovery" -e " ^lost+found" 2>&1 ` > /dev/null 2>&1
521+
522+ if [ $compressed -eq 1 ]
523+ then
524+ echo " Restoring compressed cache-backup in ${CACHEPART} ..."
525+ cd ${CACHEPART}
526+ gzip -c -d " ${rompath} /cache-backup.tar.gz" | _TAR_ xpf -
527+ if [ $? -ne 0 ]
528+ then
529+ echo " "
530+ echo " Error occurred during restoration of cache data..."
531+ echo " tar/gzip operation failed."
532+ echo " Do you have enough space on the /sdcard?"
533+ echo " "
534+ do_exit 28
535+ fi
536+ cd /
537+ else
538+ echo " Restoring cache-backup in ${CACHEPART} ..."
539+ cd ${CACHEPART}
540+ _TAR_ xpf " ${rompath} /cache-backup.tar"
541+ if [ $? -ne 0 ]
542+ then
543+ echo " "
544+ echo " Error occurred during restoration of cache-backup ..."
545+ echo " tar operation failed."
546+ echo " Do you have enough space on the /sdcard?"
547+ echo " "
548+ do_exit 27
549+ fi
550+ cd /
551+ fi
552+
553+
554+ fi
555+
459556 if [ $nandroid_only -eq 0 ]
460557 then
461558 compressed=0
@@ -606,6 +703,23 @@ case "$cmd" in
606703
607704 if [ $compressed -eq 1 ]
608705 then
706+ if [ $docache -eq 1 ]
707+ then
708+ $myecho " storing cache..."
709+ cd ${CACHEPART}
710+ _TAR_ cpf - ` _LS_ -d * | grep -v -e " ^lost+found" -e " ^recovery" 2> /dev/null` | gzip -1 > " ${rompath} /cache-backup.tar.gz"
711+ if [ $? -ne 0 ]
712+ then
713+ echo " "
714+ echo " Error occurred during storing of cache data..."
715+ echo " tar/gzip operation failed."
716+ echo " Do you have enough space on the /sdcard?"
717+ echo " "
718+ do_exit 15
719+ fi
720+
721+ fi
722+
609723 if [ $nandroid_only -eq 0 ]
610724 then
611725 # store the apps partition data
@@ -661,6 +775,24 @@ case "$cmd" in
661775 fi
662776 fi
663777 else
778+ if [ $docache -eq 1 ]
779+ then
780+ $myecho " storing cache..."
781+ cd ${CACHEPART}
782+ _TAR_ cpf " ${rompath} /cache-backup.tar" ` _LS_ -d * | grep -v -e " ^lost+found" -e " ^recovery" 2> /dev/null`
783+ if [ $? -ne 0 ]
784+ then
785+ echo " "
786+ echo " Error occurred during storing of cache data..."
787+ echo " tar/gzip operation failed."
788+ echo " Do you have enough space on the /sdcard?"
789+ echo " "
790+ do_exit 15
791+ fi
792+
793+ fi
794+
795+
664796 if [ $nandroid_only -eq 0 ]
665797 then
666798 # store the apps partition data
0 commit comments