forked from FriendlyNeighborhoodShane/MinMicroG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·148 lines (114 loc) · 3.45 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/sh
# Build a package with $1 variant
#
# Copyright 2018-2020 FriendlyNeighborhoodShane
# Distributed under the terms of the GNU GPL v3
abort() {
echo " ";
echo "!!! FATAL ERROR: $1";
echo " ";
[ -d "$tmpdir" ] && rm -rf "$tmpdir";
exit 1;
}
workdir="$(pwd)";
confdir="$workdir/conf";
resdir="$workdir/res";
resdldir="$workdir/resdl";
reldir="$workdir/releases";
buildtime="$(date -u +%Y%m%d%H%M%S)";
echo " ";
echo "-- Minimal MicroG Build Script --";
echo "-- The Essentials only MicroG pack --";
MODNAME="MinMicroG";
for bin in cp find grep mv rm sed zip; do
command -v "$bin" >/dev/null || abort "No $bin found";
done;
echo " ";
echo " - Working from $workdir";
echo " ";
echo " - Build started at $buildtime";
[ "$1" ] || abort "No variant specified to build";
if [ "$1" = "all" ]; then
echo " ";
echo " - Building all packages...";
echo " ";
varlist="$(find "$confdir" -type f -name "defconf-*.txt" -exec expr {} : ".*/defconf-\(.*\)\.txt$" ';')";
for var in $varlist; do
echo " - Executing build for $var...";
"$workdir/build.sh" "$var";
done;
exit;
elif [ "$#" -gt "1" ]; then
echo " ";
echo " - Building packages: $*...";
echo " ";
for var in "$@"; do
echo " - Executing build for $var...";
"$workdir/build.sh" "$var";
done;
exit;
fi;
confvar="$1";
[ -f "$confdir/defconf-$confvar.txt" ] || abort "No $confvar variant defconf found";
echo " ";
echo " - Building package $confvar";
tmpdir="$(mktemp -d)";
rm -rf "$tmpdir";
mkdir -p "$tmpdir";
# Config
cp -f "$confdir/defconf-$confvar.txt" "$tmpdir/defconf";
. "$tmpdir/defconf" || abort "Config for $confvar cannot be executed";
echo " ";
echo " - Config says variant $variant";
# Copy neccesary files
echo " ";
echo " - Copying files...";
for file in "src/META-INF" "INSTALL.md" "LICENSE" "README.md"; do
[ -e "$workdir/$file" ] || { echo "ERROR: $file doesn't exist"; continue; }
echo " -- BUILDER: Copying $file";
cp -Rf "$workdir/$file" "$tmpdir/";
done;
for object in $stuff $stuff_util; do
found="";
for realobject in "$resdldir/$object" "$resdir/$object"; do
[ -e "$realobject" ] && found="yes" || continue;
echo " -- BUILDER: Copying $object";
mkdir -p "$tmpdir/$(dirname "$object")/";
cp -Rf "$realobject" "$tmpdir/$(dirname "$object")/";
done;
[ "$found" ] || echo "ERROR: object not found ($object)";
done;
for object in $stuff_arch $stuff_sdk $stuff_arch_sdk; do
found="";
for realobject in "$resdldir/$(dirname "$object")"/-*-/"$(basename "$object")" "$resdir/$(dirname "$object")"/-*-/"$(basename "$object")"; do
[ -e "$realobject" ] && found="yes" || continue;
cond="$(basename "$(dirname "$realobject")")";
echo " -- BUILDER: Copying $object ($cond)";
mkdir -p "$tmpdir/$(dirname "$object")/$cond/";
cp -Rf "$realobject" "$tmpdir/$(dirname "$object")/$cond/";
done;
[ "$found" ] || echo "ERROR: object not found ($object)";
done;
cp -f "$workdir/src/customize.sh" "$tmpdir"
. "$tmpdir/defconf"
echo "$modprop" > "$tmpdir/module.prop"
# Pre build actions
pre_build_actions;
# Zip
echo " ";
echo " - Zipping files...";
(
cd "$tmpdir" && zip -r9q "$tmpdir/release.zip" ".";
) || abort "Zip failed";
# Post build actions
post_build_actions;
# Copy zip
echo " ";
echo " - Copying zip to releases...";
mkdir -p "$reldir";
mv -f "$tmpdir/release.zip" "$reldir/$MODNAME-$variant-$ver-$buildtime.zip" || abort "Move failed";
# Done
echo " ";
echo " - Done!";
rm -rf "$tmpdir";
echo " ";