forked from HowWof/KernelSU_Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·54 lines (44 loc) · 1.42 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
#!/bin/bash
# Get version from GitHub environment variable
version=${VERSION}
# Check if version is provided
if [ -z "$version" ]
then
echo "No version specified. No config or build will be executed. Exiting..."
exit 1
fi
# Convert the YAML file to JSON
json=$(python -c "import sys, yaml, json; json.dump(yaml.safe_load(sys.stdin), sys.stdout)" < sources.yaml)
# Check if json is empty
if [ -z "$json" ]
then
echo "Failed to convert YAML to JSON. Exiting..."
exit 1
fi
# Parse the JSON file
config_commands=$(echo $json | jq -r --arg version "$version" '.[$version].config[]')
build_commands=$(echo $json | jq -r --arg version "$version" '.[$version].build[]')
# Check if config_commands and build_commands are empty
if [ -z "$config_commands" ] || [ -z "$build_commands" ]
then
echo "Failed to parse JSON. Exiting..."
exit 1
fi
# Print the commands that will be executed
echo -e "\033[31mBuild.sh will execute following commands corresponding to ${version}:\033[0m"
echo "$config_commands" | while read -r command; do
echo -e "\033[32m$command\033[0m"
done
echo "$build_commands" | while read -r command; do
echo -e "\033[32m$command\033[0m"
done
# Enter the kernel directory
cd kernel || exit 1
# Execute the config commands
echo "$config_commands" | while read -r command; do
eval "$command"
done
# Execute the build commands
echo "$build_commands" | while read -r command; do
eval "$command"
done