forked from Pixel-Props/build.prop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_magisk_module.sh
58 lines (47 loc) · 2.04 KB
/
build_magisk_module.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
#!/bin/bash
# Using util_functions.sh
[ -f "util_functions.sh" ] && . ./util_functions.sh || { echo "util_functions.sh not found" && exit 1; }
# Load data from script base path if no directory were specified
[ -n "$1" ] && dir=$1 || {
for dir in ./*; do # List directory ./*
if [ -d "$dir" ]; then # Check if it is a directory
dir=${dir%*/} # Remove last /
print_message "Processing \"${dir##*/}\"" debug
# Build system.prop
./"${BASH_SOURCE[0]}" "$dir"
fi
done
exit 1
}
vendor_path="$dir/extracted/vendor/build.prop"
system_path="$dir/extracted/system/system/build.prop"
device_name=$(grep_prop "ro.product.vendor.model" "$vendor_path")
device_build_id=$(grep_prop "ro.build.id" "$system_path")
device_code_name=$(grep_prop "ro.product.vendor.name" "$vendor_path")
device_code_name_title=${device_code_name^}
device_build_android_version=$(grep_prop "ro.vendor.build.version.release" "$vendor_path")
device_build_security_patch=$(grep_prop "ro.vendor.build.security_patch" "$vendor_path")
mkdir -p result
base_name=$device_code_name_title.A$device_build_android_version.$(echo "$device_build_security_patch" | sed 's/-//g')
subdir=$(basename "$dir")
mkdir -p "result/$subdir"
ls -la $dir
cp $dir/{module,system}.prop "result/$subdir/"
cp -r ./magisk_module_files/* "result/$subdir/"
cd "result/$subdir" || exit 1
zip -r "../../$base_name.zip" .
cd ../..
print_message "Module saved to $base_name.zip" info
# IMPORTANT: This will save the latest build's (last directory the shell loops thru) base name
# This won't be a problem for GitHub Actions as we have different instances running for each build
if [ -n "$GITHUB_OUTPUT" ]; then
{
echo "module_base_name=$base_name" ;
echo "module_hash=$(sha256sum "$base_name.zip" | awk '{print $1}')";
echo "device_name=$device_name";
echo "device_code_name_title=$device_code_name_title";
echo "device_build_id=$device_build_id";
echo "device_build_android_version=$device_build_android_version";
echo "device_build_security_patch=$device_build_security_patch";
} >> "$GITHUB_OUTPUT"
fi