forked from KernelSU-Next/KPatch-Next-Module
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
47 lines (37 loc) · 1.24 KB
/
build.sh
File metadata and controls
47 lines (37 loc) · 1.24 KB
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
#!/bin/bash
if [[ $1 == "clean" ]]; then
rm -rf out module/bin module/webroot
exit 0
fi
mkdir -p out module/bin module/webroot
# Build WebUI
cd webui
npm run build || npm install && npm run build
cd ..
download_bin() {
local suffix="$1"
local target="$2"
local url=$(echo "$RELEASE_JSON" | jq -r ".assets[] | select(.name | endswith(\"$suffix\")) | .browser_download_url")
echo "Downloading $target from $url"
curl -L "$url" -o "module/bin/$target"
}
# Fetch KPatch-Next binaries
if [[ ! -f "module/bin/kpatch" || ! -f "module/bin/kpimg" || ! -f "module/bin/kptools" ]]; then
URL="https://api.github.com/repos/KernelSU-Next/KPatch-Next/releases"
RELEASE_JSON=$(curl -s "$URL" | jq '.[0]')
download_bin "kpatch-android" "kpatch"
download_bin "kpimg-linux" "kpimg"
download_bin "kptools-android" "kptools"
fi
# Fetch magiskboot
if [[ ! -f "module/bin/magiskboot" ]]; then
URL="https://api.github.com/repos/topjohnwu/Magisk/releases"
RELEASE_JSON=$(curl -s "$URL" | jq '.[0]')
download_bin "Magisk*.apk" "magiskboot"
fi
# zip module
commit_number=$(git rev-list --count HEAD)
commit_hash=$(git rev-parse --short HEAD)
cd module
zip -r ../out/KPatch-Next-${commit_number}-${commit_hash}.zip .
cd ..