kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 1 | #!/sbin/sh |
| 2 | # |
| 3 | # Backup and restore proprietary Android system files |
| 4 | # |
| 5 | |
| 6 | C=/tmp/backupdir |
| 7 | S=/system |
Diogo Ferreira | 7d3ab80 | 2010-12-22 01:44:54 +0000 | [diff] [blame] | 8 | V=CyanogenMod-7 |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 9 | |
| 10 | PROCEED=1; |
| 11 | |
| 12 | check_prereq() { |
| 13 | if ( ! grep -q "^ro.modversion=.*$V.*" /system/build.prop ); |
| 14 | then |
| 15 | echo "Not backing up files from incompatible version."; |
| 16 | PROCEED=0; |
| 17 | fi |
| 18 | } |
| 19 | |
| 20 | check_installscript() { |
ladios | e7cc354 | 2011-01-24 13:47:14 +0800 | [diff] [blame] | 21 | if [ -f "/tmp/.installscript" -a ! -f "$S/etc/force_backuptool" ]; |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 22 | then |
| 23 | echo "/tmp/.installscript found. Skipping backuptool." |
| 24 | PROCEED=0; |
| 25 | fi |
| 26 | } |
| 27 | |
| 28 | get_files() { |
| 29 | cat <<EOF |
blunden | b07bc18 | 2011-03-02 02:29:01 +0100 | [diff] [blame] | 30 | app/BooksPhone.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 31 | app/CarHomeGoogle.apk |
| 32 | app/CarHomeLauncher.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 33 | app/Facebook.apk |
Steve Kondik | 6e12dad | 2010-12-14 21:11:23 -0500 | [diff] [blame] | 34 | app/FOTAKill.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 35 | app/GenieWidget.apk |
| 36 | app/Gmail.apk |
| 37 | app/GoogleBackupTransport.apk |
| 38 | app/GoogleCalendarSyncAdapter.apk |
| 39 | app/GoogleContactsSyncAdapter.apk |
| 40 | app/GoogleFeedback.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 41 | app/GooglePartnerSetup.apk |
Steve Kondik | e0b98d0 | 2010-07-02 16:33:54 -0400 | [diff] [blame] | 42 | app/GoogleQuickSearchBox.apk app/QuickSearchBox.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 43 | app/GoogleServicesFramework.apk |
| 44 | app/googlevoice.apk |
| 45 | app/HtcCopyright.apk |
| 46 | app/HtcEmailPolicy.apk |
| 47 | app/HtcSettings.apk |
| 48 | app/kickback.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 49 | app/LatinImeTutorial.apk |
Steve Kondik | d89a39c | 2010-06-29 02:46:10 -0400 | [diff] [blame] | 50 | app/Maps.apk |
Patrick Jacques | 13ce18b | 2010-11-29 23:24:12 -0700 | [diff] [blame] | 51 | app/MapsSapphire.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 52 | app/MarketUpdater.apk |
| 53 | app/MediaUploader.apk |
| 54 | app/NetworkLocation.apk |
| 55 | app/OneTimeInitializer.apk |
| 56 | app/PassionQuickOffice.apk |
Patrick Jacques | 13ce18b | 2010-11-29 23:24:12 -0700 | [diff] [blame] | 57 | app/Quickoffice.apk |
Steve Kondik | e0b98d0 | 2010-07-02 16:33:54 -0400 | [diff] [blame] | 58 | app/SetupWizard.apk app/Provision.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 59 | app/soundback.apk |
| 60 | app/Street.apk |
| 61 | app/Talk.apk |
| 62 | app/talkback.apk |
| 63 | app/Twitter.apk |
| 64 | app/Vending.apk |
| 65 | app/VoiceSearch.apk |
| 66 | app/YouTube.apk |
| 67 | etc/permissions/com.google.android.maps.xml |
Steve Kondik | 1bfa132 | 2010-06-28 21:16:14 -0400 | [diff] [blame] | 68 | etc/permissions/features.xml |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 69 | framework/com.google.android.maps.jar |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 70 | lib/libspeech.so |
Steve Kondik | 6721ac9 | 2010-08-16 18:55:59 -0400 | [diff] [blame] | 71 | lib/libvoicesearch.so |
Steve Kondik | 94ca1ae | 2010-07-11 02:49:36 -0400 | [diff] [blame] | 72 | etc/hosts |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 73 | etc/custom_backup_list.txt |
ladios | e7cc354 | 2011-01-24 13:47:14 +0800 | [diff] [blame] | 74 | etc/force_backuptool |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 75 | EOF |
| 76 | } |
| 77 | |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 78 | get_custom_files() { |
| 79 | local L |
| 80 | if [ -f "$C/custom_backup_list.txt" ]; |
| 81 | then |
| 82 | [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \ |
| 83 | > $C/fixed_custom_backup_list.txt |
| 84 | L=`cat $C/fixed_custom_backup_list.txt` |
| 85 | cat <<EOF |
| 86 | $L |
| 87 | EOF |
| 88 | fi |
| 89 | } |
| 90 | |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 91 | backup_file() { |
| 92 | if [ -e "$1" ]; |
| 93 | then |
| 94 | if [ -n "$2" ]; |
| 95 | then |
| 96 | echo "$2 $1" | md5sum -c - |
| 97 | if [ $? -ne 0 ]; |
| 98 | then |
| 99 | echo "MD5Sum check for $1 failed!"; |
| 100 | exit $?; |
| 101 | fi |
| 102 | fi |
| 103 | |
| 104 | local F=`basename $1` |
| 105 | |
| 106 | # dont backup any apps that have odex files, they are useless |
| 107 | if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ]; |
| 108 | then |
| 109 | echo "Skipping odexed apk $1"; |
| 110 | else |
Steve Kondik | 715f2d5 | 2010-07-05 19:36:33 -0400 | [diff] [blame] | 111 | cp -p $1 $C/$F |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 112 | fi |
| 113 | fi |
| 114 | } |
| 115 | |
| 116 | restore_file() { |
| 117 | local FILE=`basename $1` |
| 118 | local DIR=`dirname $1` |
| 119 | if [ -e "$C/$FILE" ]; |
| 120 | then |
| 121 | if [ ! -d "$DIR" ]; |
| 122 | then |
| 123 | mkdir -p $DIR; |
| 124 | fi |
| 125 | cp -p $C/$FILE $1; |
| 126 | if [ -n "$2" ]; |
| 127 | then |
| 128 | rm $2; |
| 129 | fi |
| 130 | fi |
| 131 | } |
| 132 | |
| 133 | check_installscript; |
| 134 | |
| 135 | case "$1" in |
| 136 | backup) |
| 137 | mount $S |
| 138 | check_prereq; |
| 139 | if [ $PROCEED -ne 0 ]; |
| 140 | then |
| 141 | rm -rf $C |
| 142 | mkdir -p $C |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 143 | for file_list in get_files get_custom_files; do |
| 144 | $file_list | while read FILE REPLACEMENT; do |
| 145 | backup_file $S/$FILE |
| 146 | done |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 147 | done |
| 148 | fi |
| 149 | umount $S |
| 150 | ;; |
| 151 | restore) |
| 152 | check_prereq; |
| 153 | if [ $PROCEED -ne 0 ]; |
| 154 | then |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 155 | for file_list in get_files get_custom_files; do |
| 156 | $file_list | while read FILE REPLACEMENT; do |
| 157 | R="" |
| 158 | [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT" |
| 159 | restore_file $S/$FILE $R |
| 160 | done |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 161 | done |
| 162 | rm -rf $C |
| 163 | fi |
| 164 | ;; |
| 165 | *) |
| 166 | echo "Usage: $0 {backup|restore}" |
| 167 | exit 1 |
| 168 | esac |
| 169 | |
| 170 | exit 0 |