You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.9 KiB
83 lines
1.9 KiB
#!/sbin/sh
|
|
#
|
|
# MinMicroG addon.d
|
|
#
|
|
# ADDOND_VERSION=2
|
|
|
|
save_files() {
|
|
cat <<EOL
|
|
@INSTALLLIST@
|
|
|
|
EOL
|
|
}
|
|
|
|
delete_files() {
|
|
cat <<EOL
|
|
@DEBLOATLIST@
|
|
|
|
EOL
|
|
}
|
|
|
|
log() { echo "$1"; }
|
|
|
|
abort() {
|
|
log " ";
|
|
log "!!! ERROR: $1";
|
|
exit 1;
|
|
}
|
|
|
|
log " ";
|
|
log "=== MinMicroG addon.d script ===";
|
|
|
|
if [ -f "/tmp/backuptool.functions" ]; then
|
|
. "/tmp/backuptool.functions" || abort "could not source addon.d helper";
|
|
elif [ -f "/postinstall/tmp/backuptool.functions" ]; then
|
|
. "/postinstall/tmp/backuptool.functions" || abort "could not source addon.d helper";
|
|
else
|
|
abort "could not find addon.d helper"
|
|
fi;
|
|
|
|
[ -f "$S/build.prop" ] || abort "could not find a ROM in $S";
|
|
sdk="$(grep ro.build.version.sdk "$S/build.prop" | head -n1 | cut -d= -f2)";
|
|
[ "$sdk" ] && [ "$sdk" -gt "0" ] || abort "could not find SDK";
|
|
|
|
translate_path() {
|
|
while read -r entry; do
|
|
if [ "$sdk" -lt 21 ]; then
|
|
[ "$(basename "$(dirname "$entry")").apk" = "$(basename "$entry")" ] && entry="$(dirname "$(dirname "$entry")")/$(basename "$entry")";
|
|
fi;
|
|
[ "$(basename "$(dirname "$entry")").apk" = "$(basename "$entry")" ] && entry="$(dirname "$entry")";
|
|
echo "${entry#/system/}";
|
|
done;
|
|
}
|
|
|
|
case "$1" in
|
|
backup)
|
|
log " ";
|
|
log "Backing up...";
|
|
save_files | translate_path | while read -r object; do
|
|
[ "$object" ] && [ -e "$S/$object" ] || continue;
|
|
backup_file "$S/$object";
|
|
log "BACKUPER: Object backed up ($object)";
|
|
done;
|
|
;;
|
|
restore)
|
|
log " ";
|
|
log "Restoring...";
|
|
save_files | translate_path | while read -r object; do
|
|
[ "$object" ] && [ -e "$C/$S/$object" ] || continue;
|
|
restore_file "$S/$object";
|
|
log "RESTORER: Object restored ($object)";
|
|
done;
|
|
;;
|
|
post-restore)
|
|
log " ";
|
|
log "Debloating...";
|
|
delete_files | translate_path | while read -r object; do
|
|
[ "$object" ] && [ -e "$S/$object" ] || continue;
|
|
rm -rf "$S/$object";
|
|
log "DEBLOATER: Object debloated ($object)";
|
|
done;
|
|
;;
|
|
esac;
|