-
Notifications
You must be signed in to change notification settings - Fork 1
/
compile.sh
executable file
·57 lines (47 loc) · 1.35 KB
/
compile.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
#!/bin/bash
set -e
set -u
set -o pipefail
shopt -s inherit_errexit
IFS=$'\n'
renice -n 19 $$ &>/dev/null
cd "$(dirname "$(readlink -f "$0")")"
for cmd in git zip base64; do
[ -z "$(command -v "$cmd")" ] && echo "missing $cmd" && exit 1
done
git clean -fdxq magiskmodule/
rm -f MagicalProtection-*.zip
./update.sh checkOutHosts
function getCommitCount() {
local folder="${1-.}"
(
cd "$folder"
git rev-list --count HEAD
)
}
git diff --exit-code --quiet && LOCALCHANGES=false || LOCALCHANGES=true
$LOCALCHANGES && CHANGES="+" || CHANGES="-"
MODULE_COMMITS=$(getCommitCount)
HOSTS_COMMITS=$(getCommitCount hosts)
VERSIONCODE=$MODULE_COMMITS$(printf '%05d' "$HOSTS_COMMITS")
COMMITHASH=$(git log -1 --pretty=%h)
COMMITHASHFULL=$(git log -1 --pretty=%H)
VERSIONTAG=mv$MODULE_COMMITS-hv$HOSTS_COMMITS
VERSION=$VERSIONTAG$CHANGES$COMMITHASH
FILENAME=MagicalProtection-$VERSIONTAG
LOCALDIFF=$(git diff --no-color --irreversible-delete | base64 -w 0)
declare -x VERSION VERSIONCODE VERSIONTAG MODULE_COMMITS HOSTS_COMMITS COMMITHASHFULL LOCALCHANGES LOCALDIFF
envsubst < module.prop > magiskmodule/module.prop
cp -f README.md magiskmodule/README.md
mkdir -p magiskmodule/system/etc
cat hosts/* \
| grep -v '^\s*#' \
| sed -e '/^$/d' \
| sort \
| uniq \
> magiskmodule/system/etc/hosts
./update.sh removeHosts
(
cd magiskmodule
zip -r -9 -q ../"$FILENAME" .
)