LeOS-GSI/LeOS/updates.sh

82 lines
2.4 KiB
Bash
Raw Permalink Normal View History

2023-12-13 10:41:07 +01:00
#!/bin/bash
set -e
repo="https://f-droid.org/repo/"
addCopy() {
addition=""
if [ "$2" == org.mozilla.fennec_fdroid ];then
unzip bin/$1 lib/*
addition="
LOCAL_PREBUILT_JNI_LIBS := \\
$(unzip -lv bin/$1 |grep -v Stored |sed -nE 's;.*(lib/arm64-v8a/.*);\t\1 \\;p')
"
fi
if [ "$2" == com.google.android.gms ] || [ "$2" == com.android.vending ] ;then
addition="LOCAL_PRIVILEGED_MODULE := true"
fi
cat >> Android.mk <<EOF
include \$(CLEAR_VARS)
LOCAL_MODULE := $2
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := bin/$1
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_OVERRIDES_PACKAGES := $3
$addition
include \$(BUILD_PREBUILT)
EOF
echo -e "\t$2 \\" >> apps.mk
}
rm -Rf apps.mk lib
cat > Android.mk <<EOF
LOCAL_PATH := \$(my-dir)
EOF
echo -e 'PRODUCT_PACKAGES += \\' > apps.mk
mkdir -p bin
#downloadFromFdroid packageName overrides
downloadFromFdroid() {
mkdir -p tmp
[ "$oldRepo" != "$repo" ] && rm -f tmp/index.xml
oldRepo="$repo"
if [ ! -f tmp/index.xml ];then
#TODO: Check security keys
wget --connect-timeout=10 $repo/index.jar -O tmp/index.jar
unzip -p tmp/index.jar index.xml > tmp/index.xml
fi
marketvercode="$(xmlstarlet sel -t -m '//application[id="'"$1"'"]' -v ./marketvercode tmp/index.xml || true)"
apk="$(xmlstarlet sel -t -m '//application[id="'"$1"'"]/package[versioncode="'"$marketvercode"'"]' -v ./apkname tmp/index.xml || xmlstarlet sel -t -m '//application[id="'"$1"'"]/package[1]' -v ./apkname tmp/index.xml)"
if [ ! -f bin/$apk ];then
while ! wget --connect-timeout=10 $repo/$apk -O bin/$apk;do sleep 1;done
fi
addCopy $apk $1 "$2"
}
#phh's Superuser
#downloadFromFdroid com.simplemobiletools.gallery.pro "Photos Gallery Gallery2"
#downloadFromFdroid com.menny.android.anysoftkeyboard "AnySoftKeyboard"
#downloadFromFdroid com.simplemobiletools.contacts.pro "Contacts"
#downloadFromFdroid com.benny.openlauncher "Launcher"
#downloadFromFdroid net.sourceforge.opencamera "Camera"
#downloadFromFdroid at.bitfire.davdroid "DAVx5"
#downloadFromFdroid eu.faircode.email "Mail"
#downloadFromFdroid org.telegram.messenger "Telegram"
#downloadFromFdroid net.kollnig.missioncontrol.fdroid "Tracker Control"
#downloadFromFdroid org.smssecure.smssecure "Silence"
#downloadFromFdroid org.fdroid.fdroid "F-Droid"
downloadFromFdroid org.fdroid.fdroid.privileged "F-Droid-Privileged"
downloadFromFdroid me.phh.superuser
#downloadFromFdroid com.gsnathan.pdfviewer "PDF Reader"
echo >> apps.mk
rm -Rf tmp