You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MinMicroG-abuse-CI/run

145 lines
3.6 KiB
Bash

#!/bin/sh
# Build and upload MinMicroG packages
error() {
echo " ";
echo "!!! FATAL: $1";
exit 1;
}
# Use sudo if available
exec_su() {
if false; then
return 1;
elif command -v "sudo" >/dev/null; then
sudo "$@";
else
"$@";
fi;
}
# Translate command names to package names
getpkg() {
case "$1" in
*)
echo "$1"
;;
esac;
}
# Find package manager
if false; then
:;
elif command -v "apt-get" >/dev/null; then
echo 'debconf debconf/frontend select Noninteractive' | exec_su debconf-set-selections;
exec_su apt-get update -yy >/dev/null;
exec_su apt-get upgrade -yy >/dev/null;
pmcmd() {
pkg="$(getpkg "$1")";
exec_su apt-get install -yy "$pkg" >/dev/null;
}
else
echo " ";
echo "!!! ERROR: Could not figure out package manager";
pmcmd() {
return 1;
}
fi;
# Dependency check
for bin in curl git jq unzip zip; do
command -v "$bin" >/dev/null || pmcmd "$bin";
command -v "$bin" >/dev/null || error "could not install dependency: $bin";
done;
for bin in aapt java; do
command -v "$bin" >/dev/null || pmcmd "$bin";
command -v "$bin" >/dev/null || {
echo " ";
echo "!!! ERROR: Could not install optional dependency: $bin !!!";
}
done;
# Workaround for stupid outdated debian packages
command -v "java" >/dev/null && {
d="$(mktemp -d)";
curl -fL "https://dl.google.com/android/repository/build-tools_r33.0.1-linux.zip" -o "$d/build-tools.zip";
unzip -p "$d/build-tools.zip" "android-13/lib/apksigner.jar" > "$d/apksigner.jar";
printf '#!/bin/sh\njava -jar "%s" "$@";\n' "$d/apksigner.jar" > "$d/apksigner";
chmod +x "$d/apksigner";
export PATH="$d:$PATH";
}
# Variables
tag="$(date -u +"%Y.%m.%d")";
name="$(date -u +"%d %b %Y")";
date="$(date -u +"%Y%m%d%H%M%S")";
# Clone time
echo " ";
echo "Cloning MinMicroG...";
git clone "https://github.com/FriendlyNeighborhoodShane/MinMicroG";
git clone "https://github.com/FriendlyNeighborhoodShane/MinMicroG-abuse-CI" "MinMicroG-resdl";
(
cd "./MinMicroG-resdl" || error "could not cd";
git fetch origin "refs/volatile/current:current";
git checkout "current";
git reset;
)
# Intro
mkdir "./MinMicroG/releases";
echo " ";
{
echo " --- MinMicroG autobuild logs --- ";
echo " ";
echo "Date: $name $date";
echo "System: $(uname -a)";
} | tee "./MinMicroG/releases/build-$date.log";
# Setup stuff
echo " ";
echo "Setting up build...";
ln -frs "./MinMicroG-resdl/system" "./MinMicroG-resdl/util" "./MinMicroG/resdl/";
cert="$(curl -fs "https://api.github.com/repos/FriendlyNeighborhoodShane/MinMicroG_releases/releases" | jq -r ".[].assets[].browser_download_url" | grep "certs.tar.gz$" | head -n1)";
[ "$cert" ] && {
{
echo " ";
echo "Cert archive found at $cert"
} | tee -a "./MinMicroG/releases/build-$date.log";
(
cd "./MinMicroG-resdl/util/certs" || error "could not cd";
rm -rf ./*;
curl -fL "$cert" | tar xz;
)
}
# Build time
echo " ";
echo "Updating and building MinMicroG...";
(
echo " ";
cd "./MinMicroG" || error "could not cd";
./bump.sh "UPDATELY" "999999" "$name";
./update.sh;
./build.sh all;
) 2>&1 | tee -a "./MinMicroG/releases/build-$date.log";
# Create diff
echo " ";
echo "Generating update diff...";
echo " ";
(
cd "./MinMicroG-resdl" || error "could not cd";
git add -A;
echo "Update diff from last CI build:";
echo " ";
git diff -C -C --stat --patch --staged;
echo " ";
echo "Update diff from last official build:";
echo " ";
git diff -C -C --stat --patch --staged "HEAD^";
) | tee "./MinMicroG/releases/diff-$date.txt";
# Run release script
[ -f ./release ] && ./release "$tag" "$name" "$date";