@ -7,6 +7,16 @@ export C=/tmp/backupdir
export S=/system
export S=/system
export V=14.1
export V=14.1
copy_file() {
cp -dp "$1" "$2"
# symlinks don't have a context
if [ ! -L "$1" ]; then
# it is assumed that every label starts with 'u:object_r' and has no white-spaces
local context=`ls -Z "$1" | grep -o 'u:object_r:[^ ]*' | head -1`
chcon "$context" "$2"
fi
}
backup_file() {
backup_file() {
if [ -e "$1" -o -L "$1" ]; then
if [ -e "$1" -o -L "$1" ]; then
local F=`basename "$1"`
local F=`basename "$1"`
@ -16,7 +26,7 @@ backup_file() {
echo "Skipping odexed apk $1";
echo "Skipping odexed apk $1";
else
else
mkdir -p "$C/$D"
mkdir -p "$C/$D"
cp -dp $1 "$C/$D/$F"
copy_file "$1" "$C/$D/$F"
fi
fi
fi
fi
}
}
@ -28,7 +38,7 @@ restore_file() {
if [ ! -d "$DIR" ]; then
if [ ! -d "$DIR" ]; then
mkdir -p "$DIR";
mkdir -p "$DIR";
fi
fi
cp -dp "$C/$DIR/$FILE" "$1";
copy_file "$C/$DIR/$FILE" "$1";
if [ -n "$2" ]; then
if [ -n "$2" ]; then
echo "Deleting obsolete file $2"
echo "Deleting obsolete file $2"
rm "$2";
rm "$2";