-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_prepare.sh
executable file
·97 lines (86 loc) · 2.71 KB
/
build_prepare.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
#!/bin/bash
#####################################################################
echo -e "\nThis sets the OTA package path to /tmp and depending on your selection\nmake an insecure build as well.\n\n"
BOARDCNFMK="$1"
F_CHECK(){
echo -e "\nYour current settings:\n"
echo -e "OTA path (build/core/Makefile):\n$(grep 'INTERNAL_OTA_PACKAGE_TARGET :=' build/core/Makefile)"
echo -e "\ninsecure state (vendor/lineage/config/common.mk):\n$(grep "secure=" vendor/lineage/config/common.mk)"
echo -e "\nselinux state (device/lge/g4-common/BoardConfigCommon.mk):\n$(grep 'androidboot.selinux=' $BOARDCNFMK)"
echo
}
F_INSEC(){
echo -e "... prepare insecure building:"
sed -i "s/ro.adb.secure=./ro.adb.secure=0/" vendor/lineage/config/common.mk
echo -e "... set the build permissive..."
sed -i 's/androidboot.selinux=enforcing/androidboot.selinux=permissive/g' $BOARDCNFMK
F_CHECK
}
F_INSEC_OFF(){
echo -e "... prepare secure building:"
CPWD=$(pwd)
cd vendor/lineage/ && git reset --hard
cd $CPWD
echo -e "vendor/lineage/config/common.mk:\t$(grep secure= vendor/lineage/config/common.mk |tr '\n' ,)\n"
echo -e "... set the build to enforcing.."
sed -i 's/androidboot.selinux=permissive/androidboot.selinux=enforcing/g' $BOARDCNFMK
F_CHECK
}
F_TMP(){
echo -e "... set path to ramdisk:"
ROUTPATH=out/zip
[ ! -L $ROUTPATH ] && ln -s /tmp/zip $ROUTPATH
sed -i 's#INTERNAL_OTA_PACKAGE_TARGET := .*/$(name).zip#INTERNAL_OTA_PACKAGE_TARGET := ${OUT_DIR}/zip/$(name).zip#g' build/core/Makefile
echo -e "build/core/Makefile:\t\t\t$(grep 'INTERNAL_OTA_PACKAGE_TARGET :=' build/core/Makefile)\n"
F_CHECK
}
F_HELP(){
echo -e "\nUSAGE / HELP"
echo -e "----------------------\n"
echo -e "Mandatory arg:\t<PATH-TO-MK> (the full device tree path containing the mk file which defines the cmdline)"
echo -e "Action args:\tinsecure, setpath, check, resetall"
echo -e "\nmultiple options are allowed for: insecure and setpath but NOT for resetinsecure or resetall\n\n"
exit 9
}
[ ! -f "$BOARDCNFMK" ] && echo -e "ERROR: $BOARDCNFMK is not a file!\n\n" && F_HELP && exit 99
shift
case $1 in
help|-help|--help)
F_HELP
;;
insecure|setpath|resetinsecure|resetall|check)
;;
*)
echo -e "\nmissing arg!!"
F_HELP
;;
esac
while [ ! -z "$1" ];do
case $1 in
insecure)
F_INSEC
shift
;;
setpath)
F_TMP
shift
;;
resetinsecure)
F_INSEC_OFF
exit
;;
resetall)
echo -e "This will RESET ALL PROJECTS to default (repo forall -vc 'git reset --hard')!"
read -p "Are you sure? <y|N>" ANS
[ "$ANS" == "y" ] && repo forall -vc "git reset --hard"
exit
;;
check)
F_CHECK
exit
;;
*)
F_HELP
;;
esac
done