summaryrefslogtreecommitdiffstats
path: root/prebuilt/common/bin/backuptool.functions
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-05-02 19:56:19 +0200
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-05-02 19:56:19 +0200
commit801e730e7e4d3e5a58d7af797d417c75870d4782 (patch)
tree4ad8d3ad37b4ece3c29d714d87924a40f269208b /prebuilt/common/bin/backuptool.functions
parent2b5008db43131e21d7c100f55621457322bbc82d (diff)
parent109fef9e1e04b2faa44c5f9dc7c5b8d3ba559858 (diff)
downloadvendor_replicant-801e730e7e4d3e5a58d7af797d417c75870d4782.zip
vendor_replicant-801e730e7e4d3e5a58d7af797d417c75870d4782.tar.gz
vendor_replicant-801e730e7e4d3e5a58d7af797d417c75870d4782.tar.bz2
Merge branch 'cm-13.0' of https://github.com/LineageOS/android_vendor_cm into replicant-6.0
Diffstat (limited to 'prebuilt/common/bin/backuptool.functions')
-rw-r--r--prebuilt/common/bin/backuptool.functions18
1 files changed, 14 insertions, 4 deletions
diff --git a/prebuilt/common/bin/backuptool.functions b/prebuilt/common/bin/backuptool.functions
index 9598f23..8a372a3 100644
--- a/prebuilt/common/bin/backuptool.functions
+++ b/prebuilt/common/bin/backuptool.functions
@@ -7,8 +7,18 @@ export C=/tmp/backupdir
export S=/system
export V=13.0
+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() {
- if [ -e "$1" ]; then
+ if [ -e "$1" -o -L "$1" ]; then
local F=`basename "$1"`
local D=`dirname "$1"`
# dont backup any apps that have odex files, they are useless
@@ -16,7 +26,7 @@ backup_file() {
echo "Skipping odexed apk $1";
else
mkdir -p "$C/$D"
- cp -p $1 "$C/$D/$F"
+ copy_file "$1" "$C/$D/$F"
fi
fi
}
@@ -24,11 +34,11 @@ backup_file() {
restore_file() {
local FILE=`basename "$1"`
local DIR=`dirname "$1"`
- if [ -e "$C/$DIR/$FILE" ]; then
+ if [ -e "$C/$DIR/$FILE" -o -L "$C/$DIR/$FILE" ]; then
if [ ! -d "$DIR" ]; then
mkdir -p "$DIR";
fi
- cp -p "$C/$DIR/$FILE" "$1";
+ copy_file "$C/$DIR/$FILE" "$1";
if [ -n "$2" ]; then
echo "Deleting obsolete file $2"
rm "$2";