This repository has been archived by the owner on Aug 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
fromdiff.sh
executable file
·142 lines (121 loc) · 2.59 KB
/
fromdiff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# Copyright (C) 2011 SuperTeam.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#Inicializamos las variables
#!/bin/bash
SCRIPTDIR=`dirname $0`
. $SCRIPTDIR/mensajes.sh
if [ $# -lt 3 ]
then
msgErr >&2 "Usage: $0 <file> <dir|device> <release|patch>"
exit 1
fi
DIFFFILE=$1
ORIG=$2
DEST=$3
DEVICE=$4
if [ -z $DEVICE ]
then
DEVICE=false
fi
if $DEVICE
then
preDir=system
fi
mLANG=`echo $LANG | cut -f 2 -d "=" | cut -f 1 -d "."`
if [ $mLANG = "es_ES" ]; then
mONLY="Sólo "
mFILES="Archivos "
else
mONLY="Only "
mFILES="Files "
fi
if [ ! -f $DIFFFILE ]
then
msgErr >&2 "El fichero $DIFFFILE no existe"
exit 1
fi
if ! $DEVICE && [ ! -d $DEST ]
then
msgErr >&2 "El directorio $DEST no existe"
exit 1
fi
#borramos los ficheros que no están y copiamos los cambiados.
if $DEVICE
then
adb remount
fi
while read line; do
if [[ "$line" =~ "$mFILES" ]]
then
accion=copiar
prefile=${line#*$ORIG*}
else
if [[ "$line" =~ "$DEST" ]]
then
accion=borrar
prefile=${line#*$DEST*}
prefile=${prefile/: //}
else
accion=copiar
prefile=${line#*$ORIG*}
prefile=${prefile/: //}
fi
fi
file=`echo $prefile | cut -d " " -f 1`
if [[ $accion == "copiar" ]]
then
if [ -d $ORIG$file ] && [ ! -d $DEST$file ]
then
mkdir -p $DEST$file
fi
if [ -d $ORIG$file ]
then
comodin="/*"
else
comodin=""
fi
if $DEVICE
then
if [[ "$file" =~ "/bin/" ]] || [[ "$file" =~ "/xbin/" ]]
then
chmod 755 $ORIG$file
fi
msgInfo $ORIG$file$comodin
adb push $ORIG$file$comodin $preDir$file
if [[ "$file" == "/build.prop" ]]
then
adb shell chmod 644 $preDir$file
fi
else
cp -rv $ORIG$file$comodin $DEST$file
fi
fi
if [[ $accion == "borrar" ]]
then
if $DEVICE
then
msgWarn "borrando $preDir$file"
adb shell rm -r $preDir$file
else
msgWarn "borrando $DEST$file"
rm -r $DEST$file
fi
fi
done < $DIFFFILE
if $DEVICE
then
adb remount
fi
exit 0