Merge "Modular backuptool.sh. Executes backup and restore methods defined in arbitrary /system/addon.d/*.sh scripts." into ics
commit
2de0bba259
@ -0,0 +1,41 @@
|
|||||||
|
#!/sbin/sh
|
||||||
|
#
|
||||||
|
# /system/addon.d/50-cm.sh
|
||||||
|
# During a CM9 upgrade, this script backs up /system/etc/hosts,
|
||||||
|
# /system is formatted and reinstalled, then the file is restored.
|
||||||
|
#
|
||||||
|
|
||||||
|
. /tmp/backuptool.functions
|
||||||
|
|
||||||
|
list_files() {
|
||||||
|
cat <<EOF
|
||||||
|
etc/hosts
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
backup)
|
||||||
|
list_files | while read FILE DUMMY; do
|
||||||
|
backup_file $S/"$FILE"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
restore)
|
||||||
|
list_files | while read FILE REPLACEMENT; do
|
||||||
|
R=""
|
||||||
|
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
|
||||||
|
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
pre-backup)
|
||||||
|
# Stub
|
||||||
|
;;
|
||||||
|
post-backup)
|
||||||
|
# Stub
|
||||||
|
;;
|
||||||
|
pre-restore)
|
||||||
|
# Stub
|
||||||
|
;;
|
||||||
|
post-restore)
|
||||||
|
# Stub
|
||||||
|
;;
|
||||||
|
esac
|
@ -0,0 +1,37 @@
|
|||||||
|
#!/sbin/sh
|
||||||
|
#
|
||||||
|
# Functions for backuptool.sh
|
||||||
|
#
|
||||||
|
|
||||||
|
export C=/tmp/backupdir
|
||||||
|
export S=/system
|
||||||
|
export V=9
|
||||||
|
|
||||||
|
backup_file() {
|
||||||
|
if [ -e "$1" ]; then
|
||||||
|
local F=`basename "$1"`
|
||||||
|
local D=`dirname "$1"`
|
||||||
|
# dont backup any apps that have odex files, they are useless
|
||||||
|
if ( echo "$F" | grep -q "\.apk$" ) && [ -e `echo "$1" | sed -e 's/\.apk$/\.odex/'` ]; then
|
||||||
|
echo "Skipping odexed apk $1";
|
||||||
|
else
|
||||||
|
mkdir -p "$C/$D"
|
||||||
|
cp -p $1 "$C/$D/$F"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_file() {
|
||||||
|
local FILE=`basename "$1"`
|
||||||
|
local DIR=`dirname "$1"`
|
||||||
|
if [ -e "$C/$DIR/$FILE" ]; then
|
||||||
|
if [ ! -d "$DIR" ]; then
|
||||||
|
mkdir -p "$DIR";
|
||||||
|
fi
|
||||||
|
cp -p "$C/$DIR/$FILE" "$1";
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
echo "Deleting obsolete file $2"
|
||||||
|
rm "$2";
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
@ -1,215 +1,80 @@
|
|||||||
#!/sbin/sh
|
#!/sbin/sh
|
||||||
#
|
#
|
||||||
# Backup and restore proprietary Android system files
|
# Backup and restore addon /system files
|
||||||
#
|
#
|
||||||
|
|
||||||
C=/tmp/backupdir
|
export C=/tmp/backupdir
|
||||||
S=/system
|
export S=/system
|
||||||
V=9
|
export V=9
|
||||||
|
|
||||||
PROCEED=1;
|
# Mount /system if it is not already mounted
|
||||||
|
mount_system() {
|
||||||
check_prereq() {
|
if [ ! -f "$S/build.prop" ]; then
|
||||||
if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop );
|
mount $S
|
||||||
then
|
fi
|
||||||
echo "Not backing up files from incompatible version.";
|
|
||||||
PROCEED=0;
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_installscript() {
|
# Unmount /system unless it is already unmounted
|
||||||
if [ -f "/tmp/.installscript" ] && [ $PROCEED -ne 0 ];
|
umount_system() {
|
||||||
then
|
if [ -f "$S/build.prop" ]; then
|
||||||
# We have an install script, and ROM versions match!
|
umount $S
|
||||||
# We now need to check and see if we have force_backup
|
fi
|
||||||
# in either /etc or /tmp/backupdir
|
|
||||||
if [ -f "$S/etc/force_backuptool" ] || [ -f "$C/force_backuptool" ];
|
|
||||||
then
|
|
||||||
echo "force_backuptool file found, Forcing backuptool."
|
|
||||||
else
|
|
||||||
echo "/tmp/.installscript found. Skipping backuptool."
|
|
||||||
PROCEED=0;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_files() {
|
# Preserve /system/addon.d in /tmp/addon.d
|
||||||
cat <<EOF
|
preserve_addon_d() {
|
||||||
vendor/pittpatt/models/recognition/face.face.y0-y0-22-b-N/full_model.bin
|
mkdir -p /tmp/addon.d/
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin
|
cp -a /system/addon.d/* /tmp/addon.d/
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin
|
chmod 755 /tmp/addon.d/*.sh
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-rn30-ri30.5/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-rp30-ri30.5/full_model.bin
|
|
||||||
vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-r0-ri30.4a/full_model.bin
|
|
||||||
framework/com.android.nfc_extras.jar
|
|
||||||
framework/com.google.widevine.software.drm.jar
|
|
||||||
framework/com.google.android.maps.jar
|
|
||||||
framework/com.google.android.media.effects.jar
|
|
||||||
lib/libfacelock_jni.so
|
|
||||||
lib/libfilterpack_facedetect.so
|
|
||||||
lib/libflint_engine_jni_api.so
|
|
||||||
lib/libfrsdk.so
|
|
||||||
lib/libgcomm_jni.so
|
|
||||||
lib/libpicowrapper.so
|
|
||||||
lib/libspeexresampler.so
|
|
||||||
lib/libspeexwrapper.so
|
|
||||||
lib/libvideochat_jni.so
|
|
||||||
lib/libvideochat_stabilize.so
|
|
||||||
lib/libvoicesearch.so
|
|
||||||
etc/permissions/com.google.android.nfc_extras.xml
|
|
||||||
etc/permissions/com.google.android.media.effects.xml
|
|
||||||
etc/permissions/com.google.android.maps.xml
|
|
||||||
etc/permissions/com.google.widevine.software.drm.xml
|
|
||||||
etc/permissions/features.xml
|
|
||||||
app/MediaUploader.apk
|
|
||||||
app/GoogleFeedback.apk
|
|
||||||
app/GoogleTTS.apk
|
|
||||||
app/MarketUpdater.apk
|
|
||||||
app/GoogleServicesFramework.apk
|
|
||||||
app/YouTube.apk
|
|
||||||
app/GenieWidget.apk
|
|
||||||
app/GooglePackageVerifierUpdater.apk
|
|
||||||
app/SetupWizard.apk app/Provision.apk
|
|
||||||
app/GoogleEarth.apk
|
|
||||||
app/ChromeBookmarksSyncAdapter.apk
|
|
||||||
app/GoogleQuickSearchBox.apk app/QuickSearchBox.apk
|
|
||||||
app/GoogleLoginService.apk
|
|
||||||
app/Talk.apk
|
|
||||||
app/Maps.apk
|
|
||||||
app/GooglePackageVerifier.apk
|
|
||||||
app/GoogleBackupTransport.apk
|
|
||||||
app/GalleryGoogle.apk app/Gallery2.apk
|
|
||||||
app/FaceLock.apk
|
|
||||||
app/Vending.apk
|
|
||||||
app/GoogleContactsSyncAdapter.apk
|
|
||||||
app/GoogleCalendarSyncAdapter.apk
|
|
||||||
app/Gmail.apk
|
|
||||||
app/OneTimeInitializer.apk
|
|
||||||
app/NetworkLocation.apk
|
|
||||||
app/GooglePartnerSetup.apk
|
|
||||||
app/Phonesky.apk
|
|
||||||
app/VoiceSearch.apk
|
|
||||||
etc/hosts
|
|
||||||
etc/custom_backup_list.txt
|
|
||||||
etc/force_backuptool
|
|
||||||
EOF
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_custom_files() {
|
# Restore /system/addon.d in /tmp/addon.d
|
||||||
local L
|
restore_addon_d() {
|
||||||
if [ -f "$C/custom_backup_list.txt" ];
|
cp -a /tmp/addon.d/* /system/addon.d/
|
||||||
then
|
rm -rf /tmp/addon.d/
|
||||||
[ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
|
|
||||||
> $C/fixed_custom_backup_list.txt
|
|
||||||
L=`cat $C/fixed_custom_backup_list.txt`
|
|
||||||
cat <<EOF
|
|
||||||
$L
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_file() {
|
# Proceed only if /system is the expected major version
|
||||||
if [ -e "$1" ];
|
check_prereq() {
|
||||||
then
|
if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop ); then
|
||||||
if [ -n "$2" ];
|
echo "Not backing up files from incompatible version."
|
||||||
then
|
umount_system
|
||||||
echo "$2 $1" | md5sum -c -
|
exit 127
|
||||||
if [ $? -ne 0 ];
|
fi
|
||||||
then
|
|
||||||
echo "MD5Sum check for $1 failed!";
|
|
||||||
exit $?;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
local F=`basename $1`
|
|
||||||
local D=`dirname $1`
|
|
||||||
|
|
||||||
# dont backup any apps that have odex files, they are useless
|
|
||||||
if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
|
|
||||||
then
|
|
||||||
echo "Skipping odexed apk $1";
|
|
||||||
else
|
|
||||||
mkdir -p $C/bak/$D
|
|
||||||
cp -p $1 $C/bak/$D/$F
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_file() {
|
# Execute /system/addon.d/*.sh scripts with $1 parameter
|
||||||
local FILE=`basename $1`
|
run_stage() {
|
||||||
local DIR=`dirname $1`
|
for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
|
||||||
if [ -e "$C/bak/$DIR/$FILE" ];
|
$script $1
|
||||||
then
|
done
|
||||||
if [ ! -d "$DIR" ];
|
|
||||||
then
|
|
||||||
mkdir -p $DIR;
|
|
||||||
fi
|
|
||||||
cp -p $C/bak/$DIR/$FILE $1;
|
|
||||||
if [ -n "$2" ];
|
|
||||||
then
|
|
||||||
rm $2;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# don't (u)mount system if already done
|
|
||||||
UMOUNT=0
|
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
backup)
|
backup)
|
||||||
if [ ! -f "$S/build.prop" ]; then
|
mkdir -p $C
|
||||||
mount $S
|
mount_system
|
||||||
UMOUNT=1
|
check_prereq
|
||||||
fi
|
preserve_addon_d
|
||||||
check_prereq;
|
run_stage pre-backup
|
||||||
check_installscript;
|
run_stage backup
|
||||||
if [ $PROCEED -ne 0 ];
|
run_stage post-backup
|
||||||
then
|
umount_system
|
||||||
rm -rf $C
|
;;
|
||||||
mkdir -p $C
|
restore)
|
||||||
for file_list in get_files get_custom_files; do
|
mount_system
|
||||||
$file_list | while read FILE REPLACEMENT; do
|
check_prereq
|
||||||
backup_file $S/$FILE
|
run_stage pre-restore
|
||||||
done
|
run_stage restore
|
||||||
done
|
run_stage post-restore
|
||||||
fi
|
restore_addon_d
|
||||||
if [ $UMOUNT -ne 0 ]; then
|
umount_system
|
||||||
umount $S
|
rm -rf $C
|
||||||
fi
|
sync
|
||||||
;;
|
;;
|
||||||
restore)
|
*)
|
||||||
if [ ! -f "$S/build.prop" ]; then
|
echo "Usage: $0 {backup|restore}"
|
||||||
mount $S
|
exit 1
|
||||||
UMOUNT=1
|
|
||||||
fi
|
|
||||||
check_prereq;
|
|
||||||
check_installscript;
|
|
||||||
if [ $PROCEED -ne 0 ];
|
|
||||||
then
|
|
||||||
for file_list in get_files get_custom_files; do
|
|
||||||
$file_list | while read FILE REPLACEMENT; do
|
|
||||||
R=""
|
|
||||||
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
|
|
||||||
restore_file $S/$FILE $R
|
|
||||||
done
|
|
||||||
done
|
|
||||||
rm -rf $C
|
|
||||||
fi
|
|
||||||
if [ $UMOUNT -ne 0 ]; then
|
|
||||||
umount $S
|
|
||||||
fi
|
|
||||||
sync
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {backup|restore}"
|
|
||||||
exit 1
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in new issue