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() {
|
2020-12-16 20:19:57 +00:00
|
|
|
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)";
|
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 --";
|
2020-12-14 07:28:32 +00:00
|
|
|
modname="MinMicroG";
|
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
|
|
|
|
2020-07-29 05:21:28 +00:00
|
|
|
if [ "$1" = "all" ]; then
|
|
|
|
echo " ";
|
|
|
|
echo " - Building all packages...";
|
|
|
|
echo " ";
|
|
|
|
for var in $(find "$workdir/conf" -name "defconf-*.txt" | sed -e "s|^$workdir/conf/defconf-||g" -e "s|.txt$||g"); 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;
|
2019-10-07 06:34:01 +00:00
|
|
|
|
2020-07-29 05:21:28 +00:00
|
|
|
confvar="$1";
|
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-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-09-09 07:48:37 +00:00
|
|
|
for file in "src/META-INF" "install.md" "LICENSE" "README.md"; do
|
2020-12-16 20:19:57 +00:00
|
|
|
[ -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
|
2021-06-07 05:31:28 +00:00
|
|
|
found="";
|
2020-12-14 10:29:19 +00:00
|
|
|
for realobject in "$resdir/$object" "$resdldir/$object"; do
|
2021-06-07 05:31:28 +00:00
|
|
|
[ -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;
|
2021-06-07 05:31:28 +00:00
|
|
|
[ "$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
|
2021-06-07 05:31:28 +00:00
|
|
|
found="";
|
2020-02-01 11:23:06 +00:00
|
|
|
for realobject in "$resdir/$(dirname "$object")"/-*-/"$(basename "$object")" "$resdldir/$(dirname "$object")"/-*-/"$(basename "$object")"; do
|
2021-06-07 05:31:28 +00:00
|
|
|
[ -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;
|
2021-06-07 05:31:28 +00:00
|
|
|
[ "$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;
|
|
|
|
|
2019-09-30 08:35:55 +00:00
|
|
|
# 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
|
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";
|
2020-12-14 07:28:32 +00:00
|
|
|
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 " ";
|