MinMicroG/build.sh

130 lines
3.5 KiB
Bash
Raw Normal View History

2019-10-03 19:08:29 +00:00
#!/bin/sh
# Build a package with $1 variant
2019-10-07 06:34:01 +00:00
workdir="$(pwd)";
cd "$workdir":
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";
echo " ";
echo "==================================";
echo " MinMicroG build script ";
echo "==================================";
echo " ";
echo " ";
echo " - Working from $workdir";
[ "$1" ] || { echo " "; echo "FATAL: No variant specified to build"; return 1; }
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;
[ -f "$workdir/conf/defconf-$confvar.txt" ] || { echo " "; echo "FATAL: No variant defconf found"; return 1; }
echo " ";
echo " - Building package $confvar";
rm -Rf "$tmpdir";
2019-10-03 19:08:29 +00:00
mkdir -p "$tmpdir";
# Config
2019-10-07 06:34:01 +00:00
cp -Rf "$workdir/conf/defconf-$confvar.txt" "$tmpdir/defconf";
2019-10-03 19:08:29 +00:00
eval "$(cat "$tmpdir/defconf")";
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...";
2019-10-03 19:08:29 +00:00
for file in "$workdir/src/META-INF" "$workdir/LICENSE" "$workdir/README.md"; do
[ -e "$file" ] || { echo "ERROR: $file doesn't exist"; continue; }
2019-10-07 06:34:01 +00:00
echo " -- BUILDER: Copying $file (to $tmpdir/)";
2019-10-03 19:08:29 +00:00
cp -Rf "$file" "$tmpdir/";
done;
for object in $stuff; do
for realobject in $resdir/"$object" $resdldir/"$object"; do
2019-10-07 06:34:01 +00:00
[ -e "$realobject" ] || continue;
echo " -- BUILDER: Copying $object ($realobject to $tmpdir/$(dirname "$object")/)";
2019-10-03 19:08:29 +00:00
mkdir -p "$tmpdir/$(dirname "$object")/";
cp -Rf "$realobject" "$tmpdir/$(dirname "$object")/";
done;
done;
for object in $stuff_arch; do
2019-10-07 06:34:01 +00:00
for realobject in $resdir/$(dirname "$object")/-*-/$(basename "$object") $resdldir/$(dirname "$object")/-*-/$(basename "$object"); do
[ -e "$realobject" ] || continue;
2019-10-03 19:08:29 +00:00
cond="$(basename "$(dirname "$realobject")")";
2019-10-07 06:34:01 +00:00
echo " -- BUILDER: Copying $object ($realobject to $tmpdir/$(dirname "$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;
for object in $stuff_sdk; do
2019-10-07 06:34:01 +00:00
for realobject in $resdir/$(dirname "$object")/-*-/$(basename "$object") $resdldir/$(dirname "$object")/-*-/$(basename "$object"); do
[ -e "$realobject" ] || continue;
2019-10-03 19:08:29 +00:00
cond="$(basename "$(dirname "$realobject")")";
2019-10-07 06:34:01 +00:00
echo " -- BUILDER: Copying $object ($realobject to $tmpdir/$(dirname "$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;
for object in $stuff_arch_sdk; do
2019-10-07 06:34:01 +00:00
for realobject in $resdir/$(dirname "$object")/-*--*-/$(basename "$object") $resdldir/$(dirname "$object")/-*--*-/$(basename "$object"); do
[ -e "$realobject" ] || continue;
2019-10-03 19:08:29 +00:00
cond="$(basename "$(dirname "$realobject")")";
2019-10-07 06:34:01 +00:00
echo " -- BUILDER: Copying $object ($realobject to $tmpdir/$(dirname "$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;
# Zip
2019-10-07 06:34:01 +00:00
echo " ";
echo " - Zipping files...";
2019-10-03 19:08:29 +00:00
cd "$tmpdir";
2019-10-07 06:34:01 +00:00
zip -vr9q "$tmpdir/release.zip" *;
cd "$workdir";
2019-10-03 19:08:29 +00:00
# Sign
2019-10-07 06:34:01 +00:00
echo " ";
echo " - Signing zip...";
# Done
echo " ";
echo " - Copying zip to releases...";
mkdir -p "$reldir";
mv -f "$tmpdir/release.zip" "$reldir/MinMicroG-$variant-$ver-$(date +%Y%m%d%H%M%S)-signed.zip";
# Done
echo " ";
echo " - Done!";
2019-10-03 19:08:29 +00:00
2019-10-07 06:34:01 +00:00
rm -Rf "$tmpdir";
echo " ";