MinMicroG/build.sh

145 lines
3.3 KiB
Bash
Raw Normal View History

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
2020-07-12 09:05:54 +00:00
abort() {
echo " ";
echo "!!! FATAL ERROR: $1";
echo " ";
2020-07-12 09:05:54 +00:00
[ -d "$tmpdir" ] && rm -rf "$tmpdir";
exit 1;
}
2019-10-07 06:34:01 +00:00
workdir="$(pwd)";
2021-06-24 12:07:31 +00:00
confdir="$workdir/conf";
2019-10-03 19:08:29 +00:00
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 --";
modname="MinMicroG";
2019-10-07 06:34:01 +00:00
2021-06-24 12:02:24 +00:00
for bin in cp find grep mv rm sed zip; do
command -v "$bin" >/dev/null || 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
2020-07-29 05:21:28 +00:00
if [ "$1" = "all" ]; then
echo " ";
echo " - Building all packages...";
echo " ";
2021-06-24 12:02:24 +00:00
varlist="$(find "$confdir" -type f -name "defconf-*.txt" -exec expr {} : ".*/defconf-\(.*\)\.txt$" ';')";
for var in $varlist; do
2020-07-29 05:21:28 +00:00
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;
2019-10-07 06:34:01 +00:00
2020-07-29 05:21:28 +00:00
confvar="$1";
2021-06-24 12:07:31 +00:00
[ -f "$confdir/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
2021-06-24 12:07:31 +00:00
cp -f "$confdir/defconf-$confvar.txt" "$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";
# Copy neccesary files
2019-10-07 06:34:01 +00:00
echo " ";
echo " - Copying files...";
2021-07-21 13:50:03 +00:00
for file in "src/META-INF" "INSTALL.md" "LICENSE" "README.md"; do
[ -e "$workdir/$file" ] || { echo "ERROR: $file doesn't exist"; continue; }
2019-10-07 15:35:20 +00:00
echo " -- BUILDER: Copying $file";
2020-09-09 07:48:37 +00:00
cp -Rf "$workdir/$file" "$tmpdir/";
2019-10-03 19:08:29 +00:00
done;
2019-10-17 17:29:15 +00:00
for object in $stuff $stuff_util; do
found="";
2020-12-14 10:29:19 +00:00
for realobject in "$resdir/$object" "$resdldir/$object"; do
[ -e "$realobject" ] && found="yes" || 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;
[ "$found" ] || echo "ERROR: object not found ($object)";
2019-10-03 19:08:29 +00:00
done;
2019-10-07 07:39:36 +00:00
for object in $stuff_arch $stuff_sdk $stuff_arch_sdk; do
found="";
2020-02-01 11:23:06 +00:00
for realobject in "$resdir/$(dirname "$object")"/-*-/"$(basename "$object")" "$resdldir/$(dirname "$object")"/-*-/"$(basename "$object")"; do
[ -e "$realobject" ] && found="yes" || 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;
[ "$found" ] || echo "ERROR: object not found ($object)";
2019-10-03 19:08:29 +00:00
done;
2020-07-07 15:55:07 +00:00
# Pre build actions
pre_build_actions;
# Zip
2019-10-07 06:34:01 +00:00
echo " ";
echo " - Zipping files...";
2020-12-14 10:29:19 +00:00
(
cd "$tmpdir" && zip -r9q "$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
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/$modname-$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 " ";