2020-07-05 11:39:37 +00:00
|
|
|
#!/bin/sh
|
2020-05-26 18:00:32 +00:00
|
|
|
|
2019-10-03 19:08:29 +00:00
|
|
|
# Build a package with $1 variant
|
2020-03-16 07:24:31 +00:00
|
|
|
#
|
|
|
|
# Copyright 2018-2020 FriendlyNeighborhoodShane
|
|
|
|
# Distributed under the terms of the GNU GPL v3
|
2019-09-30 08:35:55 +00:00
|
|
|
|
2020-07-12 09:05:54 +00:00
|
|
|
abort() {
|
|
|
|
echo " " >&2;
|
|
|
|
echo "!!! FATAL ERROR: $1" >&2;
|
|
|
|
echo " " >&2;
|
|
|
|
[ -d "$tmpdir" ] && rm -rf "$tmpdir";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
workdir="$(pwd)";
|
2020-07-12 09:05:54 +00:00
|
|
|
cd "$workdir" || abort "Can't cd to $workdir";
|
2019-10-03 19:08:29 +00:00
|
|
|
confvar="$1";
|
|
|
|
resdir="$workdir/res";
|
|
|
|
resdldir="$workdir/resdl";
|
2019-10-07 06:34:01 +00:00
|
|
|
reldir="$workdir/releases";
|
2019-10-13 14:31:52 +00:00
|
|
|
buildtime="$(date -u +%Y%m%d%H%M%S)";
|
2019-10-07 06:34:01 +00:00
|
|
|
|
|
|
|
echo " ";
|
2019-10-07 13:10:51 +00:00
|
|
|
echo "-- Minimal MicroG Build Script --";
|
|
|
|
echo "-- The Essentials only MicroG pack --";
|
|
|
|
echo "-- From the MicroG Telegram group --";
|
|
|
|
echo "-- No, not the Official one --";
|
2019-10-07 06:34:01 +00:00
|
|
|
|
2020-05-02 14:23:26 +00:00
|
|
|
for bin in cp grep ls mv rm sed zip; do
|
2020-07-12 09:05:54 +00:00
|
|
|
[ "$(which $bin)" ] || abort "No $bin found";
|
2019-10-07 15:08:20 +00:00
|
|
|
done;
|
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
echo " ";
|
|
|
|
echo " - Working from $workdir";
|
2019-10-07 15:35:20 +00:00
|
|
|
|
|
|
|
echo " ";
|
2019-10-07 15:08:20 +00:00
|
|
|
echo " - Build started at $buildtime";
|
2019-10-07 06:34:01 +00:00
|
|
|
|
2020-07-12 09:05:54 +00:00
|
|
|
[ "$1" ] || abort "No variant specified to build";
|
2019-10-07 06:34:01 +00:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
all)
|
|
|
|
echo " ";
|
|
|
|
echo " - Building all packages...";
|
|
|
|
echo " ";
|
2020-07-05 05:46:42 +00:00
|
|
|
for list in $(find "$workdir/conf" -name "defconf-*.txt" | sed -e "s|^$workdir/conf/defconf-||g" -e "s|.txt$||g"); do
|
2019-10-07 06:34:01 +00:00
|
|
|
echo " - Executing build for $list...";
|
|
|
|
"$workdir/build.sh" "$list";
|
|
|
|
done;
|
2020-07-12 09:05:54 +00:00
|
|
|
exit;
|
2019-10-07 06:34:01 +00:00
|
|
|
;;
|
|
|
|
esac;
|
|
|
|
|
2020-07-12 09:05:54 +00:00
|
|
|
[ -f "$workdir/conf/defconf-$confvar.txt" ] || abort "No $confvar variant defconf found";
|
2019-10-07 06:34:01 +00:00
|
|
|
|
|
|
|
echo " ";
|
|
|
|
echo " - Building package $confvar";
|
|
|
|
|
2020-07-12 09:05:54 +00:00
|
|
|
tmpdir="$(mktemp -d)";
|
|
|
|
rm -rf "$tmpdir";
|
2019-10-03 19:08:29 +00:00
|
|
|
mkdir -p "$tmpdir";
|
|
|
|
|
|
|
|
# Config
|
|
|
|
|
2020-03-16 06:36:00 +00:00
|
|
|
cp -f "$workdir/conf/defconf-$confvar.txt" "$tmpdir/defconf";
|
2020-07-05 05:46:42 +00:00
|
|
|
chmod +x "$tmpdir/defconf";
|
2020-07-12 09:05:54 +00:00
|
|
|
. "$tmpdir/defconf" || abort "Config for $confvar cannot be executed";
|
2020-03-16 06:36:00 +00:00
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
echo " ";
|
|
|
|
echo " - Config says variant $variant";
|
2019-09-30 08:35:55 +00:00
|
|
|
|
|
|
|
# Copy neccesary files
|
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
echo " ";
|
|
|
|
echo " - Copying files...";
|
|
|
|
|
2020-03-23 06:01:30 +00:00
|
|
|
for file in "$workdir/src/META-INF" "$workdir/install.md" "$workdir/LICENSE" "$workdir/README.md"; do
|
2020-01-27 17:05:10 +00:00
|
|
|
[ -e "$file" ] || { echo "ERROR: $file doesn't exist" >&2; continue; }
|
2019-10-07 15:35:20 +00:00
|
|
|
echo " -- BUILDER: Copying $file";
|
2019-10-03 19:08:29 +00:00
|
|
|
cp -Rf "$file" "$tmpdir/";
|
|
|
|
done;
|
|
|
|
|
2019-10-17 17:29:15 +00:00
|
|
|
for object in $stuff $stuff_util; do
|
2019-10-03 19:08:29 +00:00
|
|
|
for realobject in $resdir/"$object" $resdldir/"$object"; do
|
2019-10-07 06:34:01 +00:00
|
|
|
[ -e "$realobject" ] || continue;
|
2019-10-07 15:35:20 +00:00
|
|
|
echo " -- BUILDER: Copying $object";
|
2019-10-03 19:08:29 +00:00
|
|
|
mkdir -p "$tmpdir/$(dirname "$object")/";
|
|
|
|
cp -Rf "$realobject" "$tmpdir/$(dirname "$object")/";
|
|
|
|
done;
|
|
|
|
done;
|
|
|
|
|
2019-10-07 07:39:36 +00:00
|
|
|
for object in $stuff_arch $stuff_sdk $stuff_arch_sdk; do
|
2020-02-01 11:23:06 +00:00
|
|
|
for realobject in "$resdir/$(dirname "$object")"/-*-/"$(basename "$object")" "$resdldir/$(dirname "$object")"/-*-/"$(basename "$object")"; do
|
2019-10-07 06:34:01 +00:00
|
|
|
[ -e "$realobject" ] || continue;
|
2019-10-03 19:08:29 +00:00
|
|
|
cond="$(basename "$(dirname "$realobject")")";
|
2019-10-07 15:35:20 +00:00
|
|
|
echo " -- BUILDER: Copying $object ($cond)";
|
2019-10-03 19:08:29 +00:00
|
|
|
mkdir -p "$tmpdir/$(dirname "$object")/$cond/";
|
|
|
|
cp -Rf "$realobject" "$tmpdir/$(dirname "$object")/$cond/";
|
|
|
|
done;
|
|
|
|
done;
|
|
|
|
|
2020-07-07 15:55:07 +00:00
|
|
|
# Pre build actions
|
|
|
|
|
|
|
|
pre_build_actions;
|
|
|
|
|
2019-09-30 08:35:55 +00:00
|
|
|
# Zip
|
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
echo " ";
|
|
|
|
echo " - Zipping files...";
|
|
|
|
|
2020-07-12 09:05:54 +00:00
|
|
|
cd "$tmpdir" || abort "Can't cd to $tmpdir";
|
|
|
|
zip -r9q "$tmpdir/release.zip" "." || abort "Can't zip package";
|
|
|
|
cd "$workdir" || abort "Can't cd to $workdir";
|
|
|
|
[ -f "$tmpdir/release.zip" ] || abort "Zip failed";
|
2019-10-07 15:08:20 +00:00
|
|
|
|
2020-07-12 09:31:50 +00:00
|
|
|
# Post build actions
|
|
|
|
|
|
|
|
post_build_actions;
|
|
|
|
|
2020-07-07 15:43:28 +00:00
|
|
|
# Copy zip
|
2019-09-30 08:35:55 +00:00
|
|
|
|
2020-07-07 15:43:28 +00:00
|
|
|
echo " ";
|
|
|
|
echo " - Copying zip to releases...";
|
2019-10-07 15:08:20 +00:00
|
|
|
|
2020-07-07 15:43:28 +00:00
|
|
|
mkdir -p "$reldir";
|
|
|
|
mv -f "$tmpdir/release.zip" "$reldir/MinMicroG-$variant-$ver-$buildtime.zip";
|
2020-07-12 09:05:54 +00:00
|
|
|
[ -f "$reldir/MinMicroG-$variant-$ver-$buildtime.zip" ] || abort "Move failed";
|
2019-10-07 06:34:01 +00:00
|
|
|
|
|
|
|
# Done
|
|
|
|
|
|
|
|
echo " ";
|
|
|
|
echo " - Done!";
|
2019-10-03 19:08:29 +00:00
|
|
|
|
2020-07-12 09:05:54 +00:00
|
|
|
rm -rf "$tmpdir";
|
2019-10-07 06:34:01 +00:00
|
|
|
echo " ";
|