-
Notifications
You must be signed in to change notification settings - Fork 10
/
update_diff.sh
185 lines (161 loc) · 4.16 KB
/
update_diff.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
if [ $# -ne 6 ]
then
echo "useage: $0 kernel_arch target_product qcom_defconfig kernel_defconfig diff kernel_path"
exit -1
fi
echo ==========================================
echo =======start update diff config ==========
echo ==========================================
#echo $#
#echo $@
config_path="$6/arch/$1/configs"
diff_config=$config_path"/"$5
#diff_config=$config_path"/"$2"_diff"
qcom_config=$config_path"/"$3
defconfig=$config_path"/"$4
sort_diff_config=1
echo config_path=$config_path
echo diff_config=$diff_config
echo qcom_config=$qcom_config
echo defconfig=$defconfig
if [ ! -e $qcom_config ]
then
echo error: $qcom_config not exist
exit -1
fi
if [ ! -e $defconfig ]
then
echo error: $defconfig not exist
exit -1
fi
if [ -e $diff_config ]
then
echo mv diff_config to diff_config_old
#if sort the diff config,we use mv here,if not sort,we use cp
if [ $sort_diff_config -eq 0 ]
then
cp $diff_config $diff_config"_old"
else
mv $diff_config $diff_config"_old"
fi
fi
echo creat new diff_config
echo "#diff config for $2" >$diff_config
sort $qcom_config |uniq >temp1
sort $defconfig |uniq >temp2
diff temp1 temp2 >tempdiff
rm temp1
rm temp2
#cat the project defconfig increase item in tempnew
#cat the qcom defconfig reduce item in temp old
echo '' > tempnew
echo '' > tempold
cat tempdiff | while read line
do
if [[ "$line" == '>'* ]]
then
echo ${line:2} >>tempnew
fi
if [[ "$line" == '<'* ]]
then
echo ${line:2} >>tempold
fi
done
rm tempdiff
#if a valid item of tempnew also in tempold,
# I think we must save it in tempnew,and delete it in tempold
# what is valid item: it must below 2 format:
# 1. not head of "#",and have a "="
# 2. head of "# ", and end of " is not set"
cat tempold > temp0
cat tempnew | while read line
do
if [[ ("$line" != '#'*) && ("$line" == *'='*) ]]
then
# echo "*=* "$line
config_name=${line%%=*}
elif [[ ("$line" == "# CONFIG"*) && ("$line" == *" is not set") ]]
then
# echo $line
config_name=${line:0:0-11}
config_name=${config_name:2}
else
continue
fi
#we must add "=" or " is not set" here because it possible part of matched
sed_string=$config_name'='
sed '/'"$sed_string"'/'d temp0 > temp1
mv temp1 temp0
sed_string=$config_name" is not set"
sed '/'"$sed_string"'/'d temp0 > temp1
mv temp1 temp0
done
mv temp0 tempold
#in tempold, these item must reduce, we changed it to @item=default_value
#this format will special handing in creat_defconfig.sh
cat tempold |while read line
do
if [[ ("$line" != '#'*) && ("$line" == *'='*) ]]
then
# echo "*=* "$line
config_name=${line%%=*}
elif [[ ("$line" == "# CONFIG"*) && ("$line" == *" is not set") ]]
then
# echo $line
config_name=${line:0:0-11}
config_name=${config_name:2}
else
continue
fi
echo '-'$config_name >>tempnew
# echo '@'$config_name"=default_value" >>tempnew
# echo '#'$config_name"=default_value" >>tempnew
done
#cp $diff_config temp0
if [ $sort_diff_config -eq 0 ]
then
#first, we delete the same line in tempnew
cat $diff_config |while read line
do
sed '/'"$line"'/'d tempnew > temp0
mv temp0 tempnew
done
cp $diff_config temp0
cat tempnew |while read line
do
#because we must get the item,so must judge all the format
#and delete the valid item in old diff config
# if [[ ("$line" != '#'*) && ("$line" == *'='*) ]]
# if [[ ("$line" != '#'*) && ("$line" != '@'*) && ("$line" == *'='*) ]]
if [[ ("$line" != '#'*) && ("$line" != '-'*) && ("$line" == *'='*) ]]
then
config_name=${line%%=*}
elif [[ ("$line" == "# CONFIG"*) && ("$line" == *" is not set") ]]
then
config_name=${line:0:0-11}
config_name=${config_name:2}
# elif [[ ("$line" == '#'*) && ("$line" == *"=default_value") ]]
# elif [[ ("$line" == '@'*) && ("$line" == *"=default_value") ]]
elif [[ "$line" == '-'* ]]
then
config_name=${line##*-}
config_name=${config_name%%=*}
else
continue
fi
sed_string=$config_name'='
sed '/'"$sed_string"'/'d temp0 > temp1
mv temp1 temp0
sed_string=$config_name" is not set"
sed '/'"$sed_string"'/'d temp0 > temp1
mv temp1 temp0
done
#merge the changed item in to the tail
cat tempnew >> temp0
mv temp0 $diff_config
else
sort tempnew >$diff_config
rm tempnew
fi
echo "all ok now, rm $defconfig"
rm $defconfig