Skip to content

Commit 7f65c0d

Browse files
committed
add local build script
1 parent 6074837 commit 7f65c0d

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/webui/node_modules
22
/module/webroot
33
/module/bin
4+
/out
45
*.zip

build.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
if [[ $1 == "clean" ]]; then
4+
rm -rf out module/bin module/webroot
5+
exit 0
6+
fi
7+
8+
mkdir -p out module/bin module/webroot
9+
10+
# Build WebUI
11+
cd webui
12+
npm run build || npm install && npm run build
13+
cd ..
14+
15+
download_bin() {
16+
local suffix="$1"
17+
local target="$2"
18+
local url=$(echo "$RELEASE_JSON" | jq -r ".assets[] | select(.name | endswith(\"$suffix\")) | .browser_download_url")
19+
20+
echo "Downloading $target from $url"
21+
curl -L "$url" -o "module/bin/$target"
22+
}
23+
24+
# Fetch KPatch-Next binaries
25+
if [[ ! -f "module/bin/kpatch" || ! -f "module/bin/kpimg" || ! -f "module/bin/kptools" ]]; then
26+
URL="https://api.github.com/repos/KernelSU-Next/KPatch-Next/releases"
27+
RELEASE_JSON=$(curl -s "$URL" | jq '.[0]')
28+
29+
download_bin "kpatch-android" "kpatch"
30+
download_bin "kpimg-linux" "kpimg"
31+
download_bin "kptools-android" "kptools"
32+
fi
33+
34+
# Fetch magiskboot
35+
if [[ ! -f "module/bin/magiskboot" ]]; then
36+
URL="https://api.github.com/repos/topjohnwu/Magisk/releases"
37+
RELEASE_JSON=$(curl -s "$URL" | jq '.[0]')
38+
download_bin "Magisk*.apk" "magiskboot"
39+
fi
40+
41+
# zip module
42+
commit_number=$(git rev-list --count HEAD)
43+
commit_hash=$(git rev-parse --short HEAD)
44+
45+
cd module
46+
zip -r ../out/KPatch-Next-${commit_number}-${commit_hash}.zip .
47+
cd ..

0 commit comments

Comments
 (0)