forked from Flamefire/lineageos_lilac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildMicroG.sh
executable file
·85 lines (69 loc) · 2.65 KB
/
buildMicroG.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
#! /usr/bin/env bash
set -eu
function printStatus () {
echo ">> [$(date)] $@" >&2
}
export WITH_GMS="true"
export RELEASE_TYPE="MICROG"
#export SKIP_EXTRACT="1"
if [ ! -e "vendor/partner_gms/products/gms.mk" ]; then
printStatus "Missing GMS files!"
exit 1
fi
branch=$(grep -F '<default revision=' .repo/manifests/default.xml | sed -E 's|.*"refs/heads/(.*)"|\1|')
vendor=lineage
case "$branch" in
lineage-17.1)
frameworks_base_patch="android_frameworks_base-Q.patch"
;;
lineage-18.1)
frameworks_base_patch="" # "android_frameworks_base-R.patch"
;;
lineage-19.1)
frameworks_base_patch="" #"android_frameworks_base-S.patch"
;;
*)
printStatus "Building branch $branch is not (yet) suppported"
exit 1
;;
esac
printStatus "Branch: $branch"
PATCH_DIR="/tmp/docker-lineage-cicd-master/src"
if [ ! -d "$PATCH_DIR" ]; then
printStatus "Downloading lineageos4microg"
wget https://github.com/lineageos4microg/docker-lineage-cicd/archive/refs/heads/master.tar.gz -O /tmp/master.tar.gz
(cd /tmp && tar xf master.tar.gz)
printStatus "Downloaded lineageos4microg"
fi
function reset_patches {
# Remove previous changes (if they exist)
for path in "vendor/lineage" "frameworks/base"; do
if [ -d "$path" ]; then
printStatus "Removing changes to $path"
(cd "$path"; git reset -q --hard; git clean -q -fd)
fi
done
}
reset_patches
printStatus "Set up MicroG overlay"
_microgOverlayPath="vendor/lineage/overlay/microg"
mkdir -p "$_microgOverlayPath"
sed -i "1s;^;PRODUCT_PACKAGE_OVERLAYS := $_microgOverlayPath\n;" "vendor/lineage/config/common.mk"
# Override device-specific settings for the location providers
_microgOverlayPath+="/frameworks/base/core/res/res/values"
mkdir -p "$_microgOverlayPath"
cp $PATCH_DIR/signature_spoofing_patches/frameworks_base_config.xml "$_microgOverlayPath/config.xml"
makefile_containing_version="vendor/lineage/config/common.mk"
if [ -f "vendor/lineage/config/version.mk" ]; then
makefile_containing_version="vendor/lineage/config/version.mk"
fi
printStatus "Patching build type check in $makefile_containing_version"
sed -i "/\$(filter .*\$(LINEAGE_BUILDTYPE)/,/endif/d" "$makefile_containing_version"
if [[ -n $frameworks_base_patch ]]; then
printStatus "Applying the restricted signature spoofing patch (based on $frameworks_base_patch) to frameworks/base"
patchPath="$PATCH_DIR/signature_spoofing_patches/$frameworks_base_patch"
sed 's/android:protectionLevel="dangerous"/android:protectionLevel="signature|privileged"/' "$patchPath" | patch -d frameworks/base --quiet --force -p1 --no-backup-if-mismatch
fi
"$(dirname "${BASH_SOURCE[0]}")/build.sh" "$@"
printStatus "Build done"
reset_patches