-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·55 lines (45 loc) · 1.22 KB
/
build.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
#!/bin/bash
check_root() {
local message="$1"
if su -c "echo"; then
false
elif [ "$EUID" -ne 0 ]; then
echo "$message"
exit 1
fi
}
version=$1
versionCode=$2
# Check for decimal in arguments
for arg in "$@"; do
if [[ $arg =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
true
else
echo "> Arguments must be number"
exit 1
fi
done
# Extract version information from module.prop
last_version=$(grep -o 'version=v[0-9.]*' module.prop |
cut -d'=' -f2 | sed 's/v//')
if [ -z "$version" ]; then
version=$(grep -o 'version=v[0-9.]*' module.prop |
cut -d'=' -f2 | sed 's/v//')
fi
if [ -z "$versionCode" ]; then
versionCode=$(grep versionCode module.prop | cut -d '=' -f2)
versionCode=$((versionCode + 1))
fi
# Update module.prop with the new version and versionCode
sed -i "s/\(^version=v\)[0-9.]*\(.*\)/\1$version\2/; s/\(^versionCode=\)[0-9]*/\1$versionCode/" module.prop
# Extract module name
module_name=$(sed -n 's/^id=\(.*\)/\1/p' module.prop)
# Create a zip package
package_name="packages/$module_name-v${version}_$versionCode-beta.zip"
7za a "$package_name" \
META-INF \
boot_config.sh \
customize.sh \
module.prop \
service.sh
check_root "You need ROOT to install this module" || su -c "magisk --install-module $package_name"