blob: b8b1934a3d9d71efcda48883a7adc381edddc1b6 [file] [log] [blame]
Dan Pasanen894b3522017-01-16 19:26:50 -06001#!/system/bin/sh
2#
3# Functions for backuptool_ab.sh
4#
5
6export S=/system
7export C=/postinstall/tmp/backupdir
maxwen5b158882022-08-21 00:02:47 +02008export V=13
Dan Pasanen894b3522017-01-16 19:26:50 -06009export backuptool_ab=true
10
11copy_file() {
Luca Stefani17a10552019-08-19 21:45:15 +020012 old=`umask`
13 umask 0322
14 mkdir -m755 -p `dirname $2`
15 umask "$old"
Dan Pasanen894b3522017-01-16 19:26:50 -060016
Luca Stefani17a10552019-08-19 21:45:15 +020017 cp -dp --preserve=a "$1" "$2"
Dan Pasanen894b3522017-01-16 19:26:50 -060018}
19
20backup_file() {
21 if [ -e "$1" -o -L "$1" ]; then
Dan Pasanen894b3522017-01-16 19:26:50 -060022 # dont backup any apps that have odex files, they are useless
Luca Stefani17a10552019-08-19 21:45:15 +020023 if ( echo "$1" | grep -q "\.apk$" ) && [ -e `echo "$1" | sed -e 's/\.apk$/\.odex/'` ]; then
Dan Pasanen894b3522017-01-16 19:26:50 -060024 echo "Skipping odexed apk $1";
25 else
Luca Stefani17a10552019-08-19 21:45:15 +020026 copy_file "$1" "$C/$1"
Dan Pasanen894b3522017-01-16 19:26:50 -060027 fi
28 fi
29}
30
31restore_file() {
Luca Stefani17a10552019-08-19 21:45:15 +020032 if [ -e "$C/$1" -o -L "$C/$1" ]; then
33 copy_file "$C/$1" "/postinstall/$1";
Dan Pasanen894b3522017-01-16 19:26:50 -060034 if [ -n "$2" ]; then
35 echo "Deleting obsolete file $2"
36 rm "$2";
37 fi
38 fi
39}