backuptool: Add checks if it makes sense to execute commands
Change-Id: Ic83fc1168ac459b1bba5cef97d184ce2a9db4c68
This commit is contained in:
parent
c6d40c01f7
commit
9cfe968a73
|
@ -12,19 +12,27 @@ cp -f /tmp/install/bin/backuptool.functions /tmp
|
||||||
|
|
||||||
# Preserve /system/addon.d in /tmp/addon.d
|
# Preserve /system/addon.d in /tmp/addon.d
|
||||||
preserve_addon_d() {
|
preserve_addon_d() {
|
||||||
mkdir -p /tmp/addon.d/
|
if [ -d /system/addon.d/ ]; then
|
||||||
cp -a /system/addon.d/* /tmp/addon.d/
|
mkdir -p /tmp/addon.d/
|
||||||
chmod 755 /tmp/addon.d/*.sh
|
cp -a /system/addon.d/* /tmp/addon.d/
|
||||||
|
chmod 755 /tmp/addon.d/*.sh
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restore /system/addon.d in /tmp/addon.d
|
# Restore /system/addon.d from /tmp/addon.d
|
||||||
restore_addon_d() {
|
restore_addon_d() {
|
||||||
cp -a /tmp/addon.d/* /system/addon.d/
|
if [ -d /tmp/addon.d/ ]; then
|
||||||
rm -rf /tmp/addon.d/
|
cp -a /tmp/addon.d/* /system/addon.d/
|
||||||
|
rm -rf /tmp/addon.d/
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Proceed only if /system is the expected major and minor version
|
# Proceed only if /system is the expected major and minor version
|
||||||
check_prereq() {
|
check_prereq() {
|
||||||
|
# If there is no build.prop file the partition is probably empty.
|
||||||
|
if [ ! -r /system/build.prop ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop ); then
|
if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop ); then
|
||||||
echo "Not backing up files from incompatible version: $V"
|
echo "Not backing up files from incompatible version: $V"
|
||||||
return 0
|
return 0
|
||||||
|
@ -63,9 +71,11 @@ check_whitelist() {
|
||||||
|
|
||||||
# Execute /system/addon.d/*.sh scripts with $1 parameter
|
# Execute /system/addon.d/*.sh scripts with $1 parameter
|
||||||
run_stage() {
|
run_stage() {
|
||||||
for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
|
if [ -d /tmp/addon.d/ ]; then
|
||||||
$script $1
|
for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
|
||||||
done
|
$script $1
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
Loading…
Reference in New Issue