From 56e05f08d7a8a8943aca187fb449a839ba0a1aec Mon Sep 17 00:00:00 2001 From: Velsoth Date: Wed, 13 Nov 2019 23:03:06 +0000 Subject: [PATCH] Refactor get-prebuilts for easier addition of apps Signed-off-by: Velsoth --- get-prebuilts | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/get-prebuilts b/get-prebuilts index 0e4398d7..6f9d8be1 100755 --- a/get-prebuilts +++ b/get-prebuilts @@ -2,10 +2,38 @@ set -e BASEDIR=$( dirname $0 ) +PREBUILT_PATH="$BASEDIR/prebuilt/common/apps" +REPO_URL_FDROID="https://f-droid.org/repo" +REPO_URL_GUARDIAN="https://guardianproject.info/fdroid/repo" -mkdir -p $BASEDIR/prebuilt/common/apps/ +mkdir -p $PREBUILT_PATH -# F-Droid -curl -L -o $BASEDIR/prebuilt/common/apps/FDroid.apk -O -L https://f-droid.org/FDroid.apk -curl -L -o $BASEDIR/prebuilt/common/apps/FDroid.apk.asc -O -L https://f-droid.org/FDroid.apk.asc -gpg --armor --verify $BASEDIR/prebuilt/common/apps/FDroid.apk.asc $BASEDIR/prebuilt/common/apps/FDroid.apk +function getPrebuild() { + repo="$1" + name="$2" + full_name="$3" + version="$4" + version_string="" + if [[ ! -z $version ]]; then version_string="_$version"; fi + case "$repo" in + "guardian") repo_url=$REPO_URL_GUARDIAN ;; + * ) repo_url=$REPO_URL_FDROID ;; + esac + local_app_path="$PREBUILT_PATH/$name.apk" + remote_app_path="$repo_url/${full_name}${version_string}.apk" + echo -e "Downloading app $name" + curl -s \ + -L -o "$local_app_path" \ + -O -L "$remote_app_path" + curl -s \ + -L -o "$local_app_path.asc" \ + -O -L "$remote_app_path.asc" + echo -e "Verifying app $name" + gpg -q \ + --armor \ + --verify \ + "$local_app_path.asc" \ + "$local_app_path" +} + +getPrebuild fdroid FDroid org.fdroid.fdroid 1007051