Stop using stderr for important logging

gf-arm64
FriendlyNeighborhoodShane 3 years ago
parent 0017883ab2
commit 43bc47b437

@ -6,9 +6,9 @@
# Distributed under the terms of the GNU GPL v3
abort() {
echo " " >&2;
echo "!!! FATAL ERROR: $1" >&2;
echo " " >&2;
echo " ";
echo "!!! FATAL ERROR: $1";
echo " ";
[ -d "$tmpdir" ] && rm -rf "$tmpdir";
exit 1;
}
@ -82,7 +82,7 @@ echo " ";
echo " - Copying files...";
for file in "src/META-INF" "install.md" "LICENSE" "README.md"; do
[ -e "$workdir/$file" ] || { echo "ERROR: $file doesn't exist" >&2; continue; }
[ -e "$workdir/$file" ] || { echo "ERROR: $file doesn't exist"; continue; }
echo " -- BUILDER: Copying $file";
cp -Rf "$workdir/$file" "$tmpdir/";
done;

@ -141,7 +141,7 @@ verifycerts() {
for repo in $(echo "$stuff_repo" | select_word 1); do
certobject="repo/$repo.cer";
unzip -l "$tmpdir/repos/$repo.jar" "META-INF/*" | grep -q "META-INF/MANIFEST.MF" && jarsigner -verify "$tmpdir/repos/$repo.jar" > /dev/null || {
echo " !! Verification failed for repo ($repo)" >&2;
echo " !! Verification failed for repo ($repo)";
continue;
}
[ -f "$certdir/$certobject" ] || {
@ -152,7 +152,7 @@ verifycerts() {
}
unzip -p "$tmpdir/repos/$repo.jar" "META-INF/*.RSA" | openssl pkcs7 -inform der -print_certs > "$tmpdir/tmp.cer";
[ "$(diff -w "$tmpdir/tmp.cer" "$certdir/$certobject")" ] && {
echo " !! Cert mismatch for repo ($repo)" >&2;
echo " !! Cert mismatch for repo ($repo)";
cp -f "$tmpdir/tmp.cer" "$certdir/$certobject.new";
}
done;
@ -163,7 +163,7 @@ verifycerts() {
for object in $(echo "$stuff_download" | grep -E "^[ ]*[^ ]+.apk[ ]+" | select_word 1); do
certobject="$(dirname "$object")/$(basename "$object" .apk).cer";
unzip -l "$resdldir/$object" "META-INF/*" | grep -q "META-INF/MANIFEST.MF" && jarsigner -verify "$resdldir/$object" > /dev/null || {
echo " !! Verification failed for APK ($object)" >&2;
echo " !! Verification failed for APK ($object)";
continue;
}
[ -f "$certdir/$certobject" ] || {
@ -174,7 +174,7 @@ verifycerts() {
}
unzip -p "$resdldir/$object" "META-INF/*.RSA" | openssl pkcs7 -inform der -print_certs > "$tmpdir/tmp.cer";
[ "$(diff -w "$tmpdir/tmp.cer" "$certdir/$certobject")" ] && {
echo " !! Cert mismatch for APK ($object)" >&2;
echo " !! Cert mismatch for APK ($object)";
cp -f "$tmpdir/tmp.cer" "$certdir/$certobject.new";
}
done;
@ -197,7 +197,7 @@ checkwhitelist() {
echo " ";
echo " - Getting priv-app permissions...";
curl -L "$privpermurl" -o "$tmpdir/tmppage" || { echo "ERROR: Android permission docpage failed to download" >&2; return 1; }
curl -L "$privpermurl" -o "$tmpdir/tmppage" || { echo "ERROR: Android permission docpage failed to download"; return 1; }
lines="$(grep -nE "<!-- [=]* [A-Z ]* [=]* -->" "$tmpdir/tmppage" | grep -A1 "ENUM CONSTANTS DETAIL" | sed "s|:| |g" | select_word 1)";
for line in $lines; do
@ -214,7 +214,7 @@ checkwhitelist() {
echo " - Checking priv-app permissions...";
for object in $(echo "$stuff_download" | grep -E "^[ ]*/system/priv-app/[^ ]+.apk[ ]+" | select_word 1); do
[ -f "$resdldir/$object" ] || { echo "ERROR: Privapp $object not found" >&2; continue; }
[ -f "$resdldir/$object" ] || { echo "ERROR: Privapp $object not found"; continue; }
privperms="";
privapppackage="$(aapt dump badging "$resdldir/$object" | grep -oE "package: name=[^ ]*" | sed "s|'| |g" | select_word 3)"
privappperms="$(aapt dump permissions "$resdldir/$object" | grep -oE "uses-permission: name=[^ ]*" | sed "s|'| |g" | select_word 3 | sort -u)";

@ -6,9 +6,9 @@
# Distributed under the terms of the GNU GPL v3
abort() {
echo " " >&2;
echo "!!! FATAL ERROR: $1" >&2;
echo " " >&2;
echo " ";
echo "!!! FATAL ERROR: $1";
echo " ";
[ -d "$tmpdir" ] && rm -rf "$tmpdir";
exit 1;
}

@ -6,9 +6,9 @@
# Distributed under the terms of the GNU GPL v3
abort() {
echo " " >&2;
echo "!!! FATAL ERROR: $1" >&2;
echo " " >&2;
echo " ";
echo "!!! FATAL ERROR: $1";
echo " ";
[ -d "$tmpdir" ] && rm -rf "$tmpdir";
exit 1;
}
@ -97,11 +97,11 @@ echo " - Downloading repos...";
for repo in $(echo "$stuff_repo" | select_word 1); do
line="$(echo "$stuff_repo" | grep -E "^[ ]*$repo[ ]+" | head -n1)";
repourl="$(echo "$line" | select_word 2)";
[ "$repourl" ] || { echo "ERROR: Repo $repo has no URL" >&2; continue; }
[ "$repourl" ] || { echo "ERROR: Repo $repo has no URL"; continue; }
echo " -- REPO: Downloading repo $repo";
curl -L "$repourl/index-v1.jar" -o "$tmpdir/repos/$repo.jar" || { echo "ERROR: Repo $repo failed to download" >&2; continue; }
unzip -oq "$tmpdir/repos/$repo.jar" "index-v1.json" -d "$tmpdir/repos/" || { echo "ERROR: Repo $repo failed to unzip" >&2; continue; }
mv -f "$tmpdir/repos/index-v1.json" "$tmpdir/repos/$repo.json" || { echo "ERROR: Repo $repo failed to rename" >&2; continue; }
curl -L "$repourl/index-v1.jar" -o "$tmpdir/repos/$repo.jar" || { echo "ERROR: Repo $repo failed to download"; continue; }
unzip -oq "$tmpdir/repos/$repo.jar" "index-v1.json" -d "$tmpdir/repos/" || { echo "ERROR: Repo $repo failed to unzip"; continue; }
mv -f "$tmpdir/repos/index-v1.json" "$tmpdir/repos/$repo.json" || { echo "ERROR: Repo $repo failed to rename"; continue; }
done;
# Download assets
@ -114,7 +114,7 @@ for object in $(echo "$stuff_download" | select_word 1); do
source="$(echo "$line" | select_word 2)";
objectpath="$(echo "$line" | select_word 3)";
objectarg="$(echo "$line" | select_word 4)";
[ "$objectpath" ] || { echo "ERROR: $object has no source arguments" >&2; continue; }
[ "$objectpath" ] || { echo "ERROR: $object has no source arguments"; continue; }
echo " -- ASSET: Downloading object $object from source $source";
case "$source" in
local)
@ -132,10 +132,10 @@ for object in $(echo "$stuff_download" | select_word 1); do
gitlab)
echo " ---- Getting GitLab project ID for $object";
objectid="$(curl -Ls "https://gitlab.com/$objectpath" | grep "Project ID" | head -n1 | select_word 3)";
[ "$objectid" ] || { echo "ERROR: $object gitlab project ID not found" >&2; continue; }
[ "$objectid" ] || { echo "ERROR: $object gitlab project ID not found"; continue; }
echo " ---- Getting GitLab URL for $object";
objectupload="$(curl -Ls "https://gitlab.com/api/v4/projects/$objectid/repository/tags" | jq -r '.[].release.description' | grep -oE "(/uploads/[^()]*$objectarg)" | head -n1 | tr -d "()")";
[ "$objectupload" ] || { echo "ERROR: $object gitlab project upload not found" >&2; continue; }
[ "$objectupload" ] || { echo "ERROR: $object gitlab project upload not found"; continue; }
objecturl="https://gitlab.com/$objectpath$objectupload";
;;
repo)
@ -145,8 +145,8 @@ for object in $(echo "$stuff_download" | select_word 1); do
objectarch="$(echo "$objectarg" | sed "s|:| |g" | select_word 1)";
objectsdk="$(echo "$objectarg" | sed "s|:| |g" | select_word 2)";
}
[ "$objectrepo" ] && [ "$objectpackage" ] || { echo "ERROR: $object has no valid repo arguments" >&2; continue; }
[ -f "$tmpdir/repos/$objectrepo.json" ] || { echo "ERROR: $object repo $objectrepo does not exist" >&2; continue; }
[ "$objectrepo" ] && [ "$objectpackage" ] || { echo "ERROR: $object has no valid repo arguments"; continue; }
[ -f "$tmpdir/repos/$objectrepo.json" ] || { echo "ERROR: $object repo $objectrepo does not exist"; continue; }
echo " ---- Getting repo URL for $object from repo $objectrepo";
objectserver="$(jq -r '.repo.address' "$tmpdir/repos/$objectrepo.json")";
if [ "$objectarg" ]; then
@ -155,23 +155,23 @@ for object in $(echo "$stuff_download" | select_word 1); do
else
objectserverfile="$(jq -r --arg pkg "$objectpackage" '.packages[$pkg][].apkName' "$tmpdir/repos/$objectrepo.json" | head -n1)";
fi;
[ "$objectserver" ] && [ "$objectserver" != "null" ] && [ "$objectserverfile" ] && [ "$objectserverfile" != "null" ] || { echo "ERROR: $object has no URL available" >&2; continue; }
[ "$objectserver" ] && [ "$objectserver" != "null" ] && [ "$objectserverfile" ] && [ "$objectserverfile" != "null" ] || { echo "ERROR: $object has no URL available"; continue; }
objecturl="$objectserver/$objectserverfile";
;;
*)
echo "ERROR: Source $source for $object unknown" >&2;
echo "ERROR: Source $source for $object unknown";
;;
esac;
[ "$objecturl" ] || { echo "ERROR: $object has no URL available" >&2; continue; }
[ "$objecturl" ] || { echo "ERROR: $object has no URL available"; continue; }
objectname="$(basename "$objecturl")";
objectfile="$tmpdir/$objectname";
echo " ---- Downloading $objecturl";
curl -L "$objecturl" -o "$objectfile" || { echo "ERROR: $object failed to download" >&2; continue; }
curl -L "$objecturl" -o "$objectfile" || { echo "ERROR: $object failed to download"; continue; }
echo "NAME: $objectname, FILE: $object, URL: $objecturl;" >> "$updatelog";
;;
esac;
mkdir -p "$resdldir/$(dirname "$object")";
mv -f "$objectfile" "$resdldir/$object" || { echo "ERROR: $object failed to copy" >&2; continue; }
mv -f "$objectfile" "$resdldir/$object" || { echo "ERROR: $object failed to copy"; continue; }
done;
# Post update actions

Loading…
Cancel
Save