forked from byf3332/sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_fox_10.sh
121 lines (98 loc) · 3.22 KB
/
update_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
#!/bin/bash
# ***************************************************************************************
# Script to update the Android 10 minimal manifest (with "repo sync")
# - Author: DarthJabba9
# - Version: 006
# - Date: 02 November 2021
# ***************************************************************************************
# the branches we will be dealing with
FOX_BRANCH="fox_10.0"
DEVICE_BRANCH="android-10"
# print message and quit
abort() {
echo "$@"
exit
}
# Our starting point (Fox base dir)
BASE_DIR="$PWD"
# the saved location of the manifest directory upon successful sync and patch
SYNC_LOG="$BASE_DIR"/"$FOX_BRANCH"_"manifest.sav"
if [ -f $SYNC_LOG ]; then
source $SYNC_LOG
fi
[ -z "$MANIFEST_DIR" ] && MANIFEST_DIR="$BASE_DIR/$FOX_BRANCH"
# help
if [ "$1" = "-h" -o "$1" = "--help" -o "$1" = "help" ]; then
echo "Script to update the $FOX_BRANCH build system"
echo "Usage = $0 [$FOX_BRANCH-manifest_directory]"
echo "The default manifest directory is \"$MANIFEST_DIR\""
exit 0
fi
# is the fox_10 manifest directory supplied from the command line?
if [ -n "$1" ]; then
MANIFEST_DIR="$1"
[ "$1" = "." ] && MANIFEST_DIR="$PWD"
fi
# test whether it is valid
if [ ! -d $MANIFEST_DIR ]; then
echo "- Invalid directory: \"$MANIFEST_DIR\""
abort "Syntax = $0 <$FOX_BRANCH-manifest_directory>"
fi
cd $MANIFEST_DIR
[ "$?" != "0" ] && abort "- Invalid directory: $MANIFEST_DIR"
# some more rudimentary checks
echo "- Checking the directory ($MANIFEST_DIR) for validity"
if [ ! -d bootable/ -o ! -d external/ -o ! -d bionic/ -o ! -d system/ -o ! -d toolchain/ ]; then
abort "- Invalid manifest directory: $MANIFEST_DIR"
fi
LOC="$PWD"
echo "- Done."
echo "- The build system to be updated is: \"$MANIFEST_DIR\""
# move the OrangeFox "bootable" directory
echo "- Backing up the OrangeFox recovery sources"
BOOTABLE_BACKUP="fox_bootable"
[ -d $BOOTABLE_BACKUP ] && rm -rf $BOOTABLE_BACKUP
mv bootable/ $BOOTABLE_BACKUP
[ "$?" != "0" ] && abort "- Error backing up the OrangeFox recovery sources"
echo "- Done."
# move the OrangeFox "device" trees
echo "- Backing up the OrangeFox device trees"
DEVICE_BACKUP="fox_devices"
[ -d $DEVICE_BACKUP ] && rm -rf $DEVICE_BACKUP
mv device/ $DEVICE_BACKUP
[ "$?" != "0" ] && {
echo "- Restoring the OrangeFox recovery sources ..."
rm -rf bootable/
mv $BOOTABLE_BACKUP bootable/
abort "- Error backing up the OrangeFox device trees"
}
echo "- Done."
# sync the twrp manifest
echo "- Updating the minimal manifest ..."
repo sync
echo "- Done."
echo "- Restoring the OrangeFox recovery sources ..."
# remove the TWRP bootable/ directory
rm -rf bootable/
# restore the OrangeFox bootable directory
mv $BOOTABLE_BACKUP bootable/
echo "- Done."
echo "- Restoring the OrangeFox device trees ..."
# remove the TWRP device/ directory
rm -rf device/
# restore the OrangeFox device directory
mv $DEVICE_BACKUP device/
echo "- Done."
# Update OrangeFox sources
echo "- Updating the OrangeFox recovery sources ..."
cd $LOC/bootable/recovery
git pull --recurse-submodules
echo "- Done."
# Update OrangeFox vendor tree
echo "- Updating the OrangeFox vendor tree ..."
cd $LOC/vendor/recovery
git pull
echo "- Done."
# Finished
echo "- Finished! You need to update your device tree(s) manually."
#