2019-10-03 19:08:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# 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
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
workdir="$(pwd)";
|
2020-02-01 11:23:06 +00:00
|
|
|
cd "$workdir" || { echo " "; echo "FATAL: Can't cd to $workdir"; return 1; };
|
2019-10-03 19:08:29 +00:00
|
|
|
confvar="$1";
|
|
|
|
resdir="$workdir/res";
|
|
|
|
resdldir="$workdir/resdl";
|
|
|
|
tmpdir="$workdir/tmp";
|
2019-10-07 06:34:01 +00:00
|
|
|
reldir="$workdir/releases";
|
2020-02-13 17:47:28 +00:00
|
|
|
zipsigner="$resdldir/util/zipsigner.jar";
|
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
|
|
|
|
2019-10-07 15:08:20 +00:00
|
|
|
for bin in cp grep java ls mv rm sed zip; do
|
2020-01-27 17:05:10 +00:00
|
|
|
[ "$(which $bin)" ] || { echo " " >&2; echo "FATAL: No $bin found" >&2; return 1; }
|
2019-10-07 15:08:20 +00:00
|
|
|
done;
|
2020-01-27 17:05:10 +00:00
|
|
|
[ -f "$zipsigner" ] || { echo " " >&2; echo "FATAL: No zipsigner jar found" >&2; return 1; }
|
2019-10-07 15:08:20 +00:00
|
|
|
|
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-01-27 17:05:10 +00:00
|
|
|
[ "$1" ] || { echo " " >&2; echo "FATAL: No variant specified to build" >&2; return 1; }
|
2019-10-07 06:34:01 +00:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
all)
|
|
|
|
echo " ";
|
|
|
|
echo " - Building all packages...";
|
|
|
|
echo " ";
|
|
|
|
for list in $(ls -1 "$workdir/conf" | grep -o "defconf-.*.txt" | sed -e "s|^defconf-||g" -e "s|.txt$||g"); do
|
|
|
|
echo " - Executing build for $list...";
|
|
|
|
"$workdir/build.sh" "$list";
|
|
|
|
done;
|
|
|
|
return;
|
|
|
|
;;
|
|
|
|
esac;
|
|
|
|
|
2020-01-27 17:05:10 +00:00
|
|
|
[ -f "$workdir/conf/defconf-$confvar.txt" ] || { echo " " >&2; echo "FATAL: No variant defconf found" >&2; return 1; }
|
2019-10-07 06:34:01 +00:00
|
|
|
|
|
|
|
echo " ";
|
|
|
|
echo " - Building package $confvar";
|
|
|
|
|
|
|
|
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";
|
|
|
|
chmod 0777 "$tmpdir/defconf";
|
|
|
|
. "$tmpdir/defconf" || { echo " " >&2; echo "FATAL: Config for $confvar cannot be executed" >&2; return 1; };
|
|
|
|
|
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...";
|
|
|
|
|
2019-10-03 19:08:29 +00:00
|
|
|
for file in "$workdir/src/META-INF" "$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;
|
|
|
|
|
2019-09-30 08:35:55 +00:00
|
|
|
# Zip
|
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
echo " ";
|
|
|
|
echo " - Zipping files...";
|
|
|
|
|
2020-02-01 11:23:06 +00:00
|
|
|
cd "$tmpdir" || { echo " "; echo "FATAL: Can't cd to $tmpdir"; return 1; };
|
2020-03-17 13:40:40 +00:00
|
|
|
zip -r9q "$tmpdir/release.zip" "." || { echo " "; echo "FATAL: Can't zip package"; return 1; };
|
2020-02-01 11:23:06 +00:00
|
|
|
cd "$workdir" || { echo " "; echo "FATAL: Can't cd to $workdir"; return 1; };
|
2019-10-03 19:08:29 +00:00
|
|
|
|
2020-01-27 17:05:10 +00:00
|
|
|
[ -f "$tmpdir/release.zip" ] || { echo " " >&2; echo "FATAL: Zip failed" >&2; return 1; }
|
2019-10-07 15:08:20 +00:00
|
|
|
|
2019-09-30 08:35:55 +00:00
|
|
|
# Sign
|
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
echo " ";
|
|
|
|
echo " - Signing zip...";
|
|
|
|
|
2019-10-07 07:05:12 +00:00
|
|
|
java -jar "$zipsigner" "$tmpdir/release.zip" "$tmpdir/release-signed.zip";
|
|
|
|
|
2020-01-27 17:05:10 +00:00
|
|
|
[ -f "$tmpdir/release-signed.zip" ] || { echo " " >&2; echo "FATAL: Zipsigner failed" >&2; return 1; }
|
2019-10-07 15:08:20 +00:00
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
# Done
|
|
|
|
|
|
|
|
echo " ";
|
|
|
|
echo " - Copying zip to releases...";
|
|
|
|
|
|
|
|
mkdir -p "$reldir";
|
2019-10-07 15:08:20 +00:00
|
|
|
mv -f "$tmpdir/release-signed.zip" "$reldir/MinMicroG-$variant-$ver-$buildtime-signed.zip";
|
|
|
|
|
2020-01-27 17:05:10 +00:00
|
|
|
[ -f "$reldir/MinMicroG-$variant-$ver-$buildtime-signed.zip" ] || { echo " " >&2; echo "FATAL: Move failed" >&2; return 1; }
|
2019-10-07 06:34:01 +00:00
|
|
|
|
|
|
|
# Done
|
|
|
|
|
|
|
|
echo " ";
|
|
|
|
echo " - Done!";
|
2019-10-03 19:08:29 +00:00
|
|
|
|
2019-10-07 06:34:01 +00:00
|
|
|
rm -Rf "$tmpdir";
|
|
|
|
echo " ";
|