forked from byf3332/sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_fox_10.sh
257 lines (216 loc) · 8.12 KB
/
get_fox_10.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
#!/bin/bash -x
# ***************************************************************************************
# - Script to set up things for building OrangeFox with the Android-10.0 build system
# - Syncs the twrp-10.0 minimal manifest, and patches it for building OrangeFox
# - Pulls in the OrangeFox recovery sources and vendor tree
# - Author: DarthJabba9
# - Version: fox_10.0:006
# - Date: 06 November 2021
# ***************************************************************************************
# the branches we will be dealing with
FOX_BRANCH="fox_10.0";
TWRP_BRANCH="twrp-10.0";
DEVICE_BRANCH="android-10";
# the base version of the current OrangeFox
FOX_BASE_VERSION="R11.1";
# Our starting point (Fox base dir)
BASE_DIR="$PWD";
# default directory for the new manifest
MANIFEST_DIR="$BASE_DIR/$FOX_BRANCH";
# where to log the location of the manifest directory upon successful sync and patch
SYNC_LOG="$BASE_DIR"/"$FOX_BRANCH"_"manifest.sav";
# help
if [ "$1" = "-h" -o "$1" = "--help" -o "$1" = "help" ]; then
echo "Script to set up things for building OrangeFox with the $DEVICE_BRANCH build system"
echo "Usage = $0 [new_manifest_directory]"
echo "The default new manifest directory is \"$MANIFEST_DIR\""
exit 0
fi
# You can supply a path for the new manifest to override the default
[ -n "$1" ] && MANIFEST_DIR="$1";
# by default, don't use SSH for the "git clone" commands; to use SSH, export USE_SSH=1 before starting
[ -z "$USE_SSH" ] && USE_SSH="0";
# the "diff" file that will be used to patch the original manifest
PATCH_FILE="$BASE_DIR/patch-manifest-$FOX_BRANCH.diff";
# the directory in which the patch of the manifest will be executed
MANIFEST_BUILD_DIR="$MANIFEST_DIR/build";
# the device whose tree we can clone for compiling a test build
test_build_device="miatoll";
# print message and quit
abort() {
echo "$@"
exit
}
# init the script, ensure we have the patch file, and create the manifest directory
init_script() {
echo "-- Starting the script ..."
[ ! -f "$PATCH_FILE" ] && abort "-- I cannot find the patch file: $PATCH_FILE - quitting!"
echo "-- The new build system will be located in \"$MANIFEST_DIR\""
mkdir -p $MANIFEST_DIR
[ "$?" != "0" -a ! -d $MANIFEST_DIR ] && {
abort "-- Invalid directory: \"$MANIFEST_DIR\". Quitting."
}
}
# repo init and repo sync
get_twrp_minimal_manifest() {
local MIN_MANIFEST="git://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git"
cd $MANIFEST_DIR
echo "-- Initialising the $TWRP_BRANCH minimal manifest repo ..."
repo init --depth=1 -u $MIN_MANIFEST -b $TWRP_BRANCH
[ "$?" != "0" ] && {
abort "-- Failed to initialise the minimal manifest repo. Quitting."
}
echo "-- Done."
echo "-- Syncing the $TWRP_BRANCH minimal manifest repo ..."
repo sync
[ "$?" != "0" ] && {
abort "-- Failed to Sync the minimal manifest repo. Quitting."
}
echo "-- Done."
}
# patch the build system for OrangeFox
patch_minimal_manifest() {
echo "-- Patching the $TWRP_BRANCH minimal manifest for building OrangeFox for dynamic partition devices ..."
cd $MANIFEST_BUILD_DIR
patch -p1 < $PATCH_FILE
[ "$?" = "0" ] && echo "-- The $TWRP_BRANCH minimal manifest has been patched successfully" || abort "-- Failed to patch the $TWRP_BRANCH minimal manifest! Quitting."
# save location of manifest dir
echo "#" &> $SYNC_LOG
echo "MANIFEST_DIR=$MANIFEST_DIR" >> $SYNC_LOG
echo "#" >> $SYNC_LOG
}
# get the qcom/twrp common stuff
clone_common() {
local URL
cd $MANIFEST_DIR/
if [ ! -d "device/qcom/common" ]; then
echo "-- Cloning qcom common ..."
git clone https://github.com/TeamWin/android_device_qcom_common -b $DEVICE_BRANCH device/qcom/common
fi
if [ ! -d "device/qcom/twrp-common" ]; then
echo "-- Cloning twrp-common ..."
git clone https://github.com/TeamWin/android_device_qcom_twrp-common -b $DEVICE_BRANCH device/qcom/twrp-common
fi
}
# get the OrangeFox recovery sources
clone_fox_recovery() {
local URL=""
if [ "$USE_SSH" = "0" ]; then
URL="https://gitlab.com/OrangeFox/bootable/Recovery.git"
else
URL="[email protected]:OrangeFox/bootable/Recovery.git"
fi
mkdir -p $MANIFEST_DIR/bootable
[ ! -d $MANIFEST_DIR/bootable ] && {
echo "-- Invalid directory: $MANIFEST_DIR/bootable"
return
}
cd $MANIFEST_DIR/bootable/
[ -d recovery/ ] && {
echo "-- Moving the TWRP recovery sources to /tmp"
rm -rf /tmp/recovery
mv recovery /tmp
}
echo "-- Pulling the OrangeFox recovery sources ..."
git clone --recurse-submodules $URL -b $FOX_BRANCH recovery
[ "$?" = "0" ] && echo "-- The OrangeFox sources have been cloned successfully" || echo "-- Failed to clone the OrangeFox sources!"
# check that the themes are correctly downloaded
if [ ! -f recovery/gui/theme/portrait_hdpi/ui.xml ]; then
echo "-- Themes not found! Trying again to pull the themes ..."
if [ "$USE_SSH" = "0" ]; then
URL="https://gitlab.com/OrangeFox/misc/theme.git"
else
URL="[email protected]:OrangeFox/misc/theme.git"
fi
[ -d recovery/gui/theme ] && rm -rf recovery/gui/theme
git clone $URL recovery/gui/theme
[ "$?" = "0" ] && echo "-- The themes have been cloned successfully" || echo "-- Failed to clone the themes!"
fi
# cleanup /tmp/recovery/
echo "-- Cleaning up the TWRP recovery sources from /tmp"
rm -rf /tmp/recovery
# create the directory for Xiaomi device trees
mkdir -p $MANIFEST_DIR/device/xiaomi
}
# get the OrangeFox vendor
clone_fox_vendor() {
local URL
if [ "$USE_SSH" = "0" ]; then
URL="https://gitlab.com/OrangeFox/vendor/recovery.git"
else
URL="[email protected]:OrangeFox/vendor/recovery.git"
fi
echo "-- Preparing for cloning the OrangeFox vendor tree ..."
rm -rf $MANIFEST_DIR/vendor/recovery
mkdir -p $MANIFEST_DIR/vendor
[ ! -d $MANIFEST_DIR/vendor ] && {
echo "-- Invalid directory: $MANIFEST_DIR/vendor"
return
}
cd $MANIFEST_DIR/vendor
echo "-- Pulling the OrangeFox vendor tree ..."
git clone $URL -b $FOX_BRANCH recovery
[ "$?" = "0" ] && echo "-- The OrangeFox vendor tree has been cloned successfully" || echo "-- Failed to clone the OrangeFox vendor tree!"
}
# get device trees
get_device_tree() {
local DIR=$MANIFEST_DIR/device/xiaomi
mkdir -p $DIR
cd $DIR
[ "$?" != "0" ] && {
abort "-- get_device_tree() - Invalid directory: $DIR"
}
# test device
local [email protected]:OrangeFox/device/"$test_build_device".git
[ "$USE_SSH" = "0" ] && URL=https://gitlab.com/OrangeFox/device/"$test_build_device".git
echo "-- Pulling the $test_build_device device tree ..."
git clone $URL -b $FOX_BRANCH"_test" "$test_build_device"
# done
if [ -d "$test_build_device" -a -d "$test_build_device/recovery" ]; then
echo "-- Finished fetching the OrangeFox $test_build_device device tree."
else
abort "-- get_device_tree() - could not fetch the OrangeFox $test_build_device device tree."
fi
}
# test build
test_build() {
# clone the device tree
get_device_tree
# proceed with the test build
export FOX_VERSION="$FOX_BASE_VERSION"_"$FOX_BRANCH"
export FOX_BUILD_TYPE="Alpha"
export ALLOW_MISSING_DEPENDENCIES=true
export FOX_USE_TWRP_RECOVERY_IMAGE_BUILDER=1
export LC_ALL="C"
export FOX_BUILD_DEVICE="$test_build_device"
echo "-- Compiling a test build for device \"$test_build_device\". This will take a *VERY* long time ..."
echo "-- Start compiling: "
export OUT_DIR=$BASE_DIR/BUILDS/"$test_build_device"
cd $BASE_DIR/
mkdir -p $OUT_DIR
cd $MANIFEST_DIR/
. build/envsetup.sh
lunch omni_"$test_build_device"-eng
mka recoveryimage
# any results?
ls -all $(find "$OUT_DIR" -name "OrangeFox-*")
}
# do all the work!
WorkNow() {
local START=$(date);
init_script;
get_twrp_minimal_manifest;
patch_minimal_manifest;
clone_common;
clone_fox_recovery;
clone_fox_vendor;
# test_build; # comment this out - don't do a test build
local STOP=$(date);
echo "- Stop time =$STOP";
echo "- Start time=$START";
echo "- Now, clone your device trees to the correct locations!";
exit 0;
}
# --- main() ---
WorkNow;
# --- end main() ---