-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathimport-mod.sh
320 lines (299 loc) · 7.67 KB
/
import-mod.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/usr/bin/env bash
#
# Copyright (C) 2022 Divyanshu-Modi <[email protected]>
#
# based on <[email protected]> module importer
#
# SPDX-License-Identifier: Apache-2.0
#
R='\033[1;31m'
G='\033[1;32m'
W='\033[1;37m'
echo -e "$G ___ __ _ __ "
echo -e "$G / | / /_____ ________ | |/ / "
echo -e "$G / /| |/ __/ __ \/ __ __ \| / "
echo -e "$G / ___ / /_/ /_/ / / / / / / | "
echo -e "$G /_/ |_\__/\____/_/ /_/ /_/_/|_| "
echo -e "$G __ ___ ___ ____ __ __ _ ______ "
echo -e "$G / |/ / __ \/ __ \/ / / / / / ____/ "
echo -e "$G / /|_/ / / / / / / / / / / / / __/ "
echo -e "$G / / / / /_/ / /_/ / /_/ / /___/ /___ "
echo -e "$G /_/ /_/\____/_____/\____/_____/_____/ "
echo -e "$G ______ _______ ____ ____ ________________ "
echo -e "$G / _/ |/ / __ \/ __ \/ __ \/_ __/ ____/ __ \ "
echo -e "$G / // /|_/ / /_/ / / / / /_/ / / / / __/ / /_/ / "
echo -e "$G _/ // / / / ____/ /_/ / _, _/ / / / /___/ _, _/ "
echo -e "$G /___/_/ /_/_/ \____/_/ |_| /_/ /_____/_/ |_| "
echo -e "$W"
error() {
clear
echo -e ""
echo -e "$R Error! $W" "$@"
echo -e ""
exit 1
}
success() {
echo -e ""
echo -e "$G" "$@" "$W"
echo -e ""
exit 0
}
# Commonised Importer
importer() {
MTD=$1
DIR=$2
REPO=$3
TAG=$4
if [[ -d $DIR && $MTD == SUBTREE ]]; then
error "$DIR directory is already present."
fi
if [[ $MTD == MERGE || $MTD == UPDATE ]]; then
git fetch "$REPO" "$TAG"
fi
case "$MTD" in
SUBTREE)
MSG=$5
git subtree add --prefix="$DIR" "$REPO" "$TAG" -m "$MSG"
git commit --amend --no-edit
;;
MERGE)
git merge --allow-unrelated-histories -s ours --no-commit FETCH_HEAD
git read-tree --prefix="$DIR" -u FETCH_HEAD
git commit --no-edit
;;
UPDATE)
git merge -X subtree="$DIR" FETCH_HEAD --no-edit
;;
esac
}
# Import dts
dts_import() {
if [[ $kv == 4.19 ]]; then
msg="ARM64: dts/vendor: Import DTS for SDM660 family"
importer "SUBTREE" "arch/arm64/boot/dts/vendor" https://github.com/Atom-X-Devs/android_kernel_qcom_devicetree "$msg"
elif [[ $kv == 5.4 ]]; then
msg="ARM64: dts/vendor: Import DTS for lahaina family"
importer "SUBTREE" "arch/arm64/boot/dts/vendor" https://github.com/Divyanshu-Modi/kernel-devicetree AtomX "$msg"
msg="ARM64: dts/vendor: Import camera DTS for lahaina family"
importer "SUBTREE" "arch/arm64/boot/dts/vendor/qcom/camera" https://github.com/Divyanshu-Modi/kernel-camera-devicetree main "$msg"
msg="ARM64: dts/vendor: Import display DTS for lahaina family"
importer "SUBTREE" "arch/arm64/boot/dts/vendor/qcom/display" https://github.com/Divyanshu-Modi/kernel-display-devicetree main "$msg"
else
error 'Invalid target kernel version, supported kernel versions are 4.19 and 5.4'
fi
success "Successfully imported DTS on $kv"
}
# Import exFAT
exfat_import() {
if [[ $option == u ]]; then
msg="fs/exfat: Update from arter97/exfat-linux"
importer "UPDATE" "fs/exfat" https://github.com/arter97/exfat-linux master "$msg"
success "Successfully updated exFAT"
else
msg="fs: Import exFAT driver"
importer "SUBTREE" "fs/exfat" https://github.com/arter97/exfat-linux master "$msg"
success "Successfully imported exFAT"
fi
}
# Import mainline exFAT
mainline_exfat_import() {
if [[ $option == u ]]; then
msg="fs/exfat: Update from namjaejeon/linux-exfat-oot"
importer "UPDATE" "fs/exfat" https://github.com/namjaejeon/linux-exfat-oot master "$msg"
success "Successfully updated mainline exFAT"
else
msg="fs: Import mainline exFAT driver"
importer "SUBTREE" "fs/exfat" https://github.com/namjaejeon/linux-exfat-oot master "$msg"
success "Successfully imported mainline exFAT"
fi
}
# Import tfa98xx codecs
tfa98_import() {
read -rp "Enter branch name: " branchname
if [[ $option == u ]]; then
msg="techpack/audio: codecs: Updated tfa98xx codec from CLO"
importer "UPDATE" "techpack/audio/asoc/codecs/tfa9874" http://git.codelinaro.org/external/mas/tfa98xx "$branchname" "$msg"
success "Successfully updated tfa98xx codec"
else
msg="techpack/audio: codecs: Initial tfa98xx codec import from CLO"
importer "MERGE" "techpack/audio/asoc/codecs/tfa9874" http://git.codelinaro.org/external/mas/tfa98xx "$branchname" "$msg"
success "Successfully imported tfa98xx codec"
fi
}
# Import Kprofiles
kprofiles_import() {
if [[ $option == u ]]; then
msg="kprofiles: Update from dakkshesh07/Kprofiles"
importer "UPDATE" "drivers/misc/kprofiles" https://github.com/dakkshesh07/Kprofiles main "$msg"
success "Successfully updated Kprofiles"
else
msg="drivers/misc: Introduce KernelSpace Profile Modes"
importer "SUBTREE" "drivers/misc/kprofiles" https://github.com/dakkshesh07/Kprofiles main "$msg"
success "Successfully imported Kprofiles"
fi
}
# Read git cmd
readcmd() {
case $cmd in
s)
msg1=$(echo '`DUMMY_TAG`' | sed s/DUMMY_TAG/"$br"/g)
importer "SUBTREE" "$dir" clo/"$mod" "$br" "$msg from $msg1"
;;
m)
if [[ $option == u ]]; then
importer "UPDATE" "$dir" clo/"$mod" "$br"
else
importer "MERGE" "$dir" clo/"$mod" "$br"
fi
;;
*)
error "Invalid target cmd, aborting!"
;;
esac
}
# Add remote
addremote() {
if [[ $num -lt 5 ]]; then
url=qcom-opensource/wlan/$mod
elif [[ $num == 7 ]]; then
url=qcom-opensource/$mod
elif [[ $num == 8 || $num == 9 ]]; then
url=qcom/opensource/$mod
else
url=opensource/$mod
fi
git remote add clo/"$mod" https://git.codelinaro.org/clo/la/platform/vendor/"$url".git
success "Add remote for target module ${mod} done."
}
# Update/Import modules
moduler() {
if [[ $num -lt 5 ]]; then
msg="staging: $mod: Import"
dir="drivers/staging/$mod"
else
msg="techpack: $mod: Import"
dir="techpack/$prefix"
fi
if ! grep -q "$mod" .git/config; then
addremote
fi
if [[ -d $dir && $option == u ]]; then
cmd=m
fi
readcmd
if [[ ! $(git diff HEAD~) ]]; then
git reset -q --hard HEAD~
success "HEAD resetted b'cuz empty commit for ${br}, ${mod}."
else
success "Import from target ${br} for target ${mod} done."
fi
}
# Indicate module directories
indicatemodir() {
if [[ $br == '' ]]; then
error "tag not defined"
fi
case $num in
1)
mod=qcacld-3.0
;;
2)
mod=qca-wifi-host-cmn
;;
3)
mod=fw-api
;;
4)
mod=prima
;;
5)
mod=audio-kernel
prefix=audio
;;
6)
mod=camera-kernel
prefix=camera
;;
7)
mod=data-kernel
prefix=data
;;
8)
mod=datarmnet
prefix=$mod
;;
9)
mod=datarmnet-ext
prefix=$mod
;;
10)
mod=dataipa
prefix=$mod
;;
11)
mod=display-drivers
prefix=display
;;
12)
mod=video-driver
prefix=video
;;
13)
exfat_import
;;
14)
mainline_exfat_import
;;
15)
kprofiles_import
;;
16)
dts_import
;;
17)
tfa98_import
;;
*)
clear
error "Invalid target input, aborting!"
;;
esac
if [[ $num -lt 13 ]]; then
moduler
fi
}
# Initialize
init() {
COLUMNS=45
PS3="Select a module: "
options=("qcacld-3.0" "qca-wifi-host-cmn" "fw-api" "prima" "audio-kernel"
"camera-kernel" "data-kernel" "datarmnet" "datarmnet-ext"
"dataipa" "display-drivers" "video-driver" "exFAT driver"
"mainline exFAT driver" "kprofiles" "device tree source" "tfa98xx")
select modules in "${options[@]}"; do
num=$REPLY
case $num in
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17)
if [[ $num -le 17 ]]; then
if [[ -z $br ]]; then
read -rp "Target tag / branch: " br
fi
read -rp "Import (i) / Update (u): " option
if [[ $option != u && $num -lt 13 ]]; then
read -rp "Target cmd: merge (m) subtree (s) " cmd
else
cmd=m
fi
elif [[ $num == 16 ]]; then
read -rp "Target kernel version: " kv
fi
indicatemodir
break
;;
*)
break
;;
esac
done
}
init