diff --git a/.gitignore b/.gitignore index d8eaf97..fa39411 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.apk *.zip +/apk /dist /logs /module-* \ No newline at end of file diff --git a/README.md b/README.md index 1176937..b547ddb 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ It requires Magisk to be installed obviously as it's a Magisk module. If you don 0. Use Linux, Mac or WSL on Windows 1. Install `zip`, `curl`, `jq` if not present -2. [Download APKs manually](https://microg.org/download.html) and place in `apk/` directory +2. [Download APKs manually](https://microg.org/download.html) and place in `apk/` + - Or run `scripts/download-apks.sh` 3. Run `scripts/build-noogle-microg.sh` - Check `-h` flag for help with build options - Module will be created in `dist/` diff --git a/apk/.gitkeep b/apk/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/WIP_pull-latest-microg.sh b/scripts/WIP_pull-latest-microg.sh deleted file mode 100755 index faecabb..0000000 --- a/scripts/WIP_pull-latest-microg.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh - -repo_url=https://microg.org/fdroid/repo -apk_dir=apk -wait_time=5 - -mkdir -p "$apk_dir" - -echo "[P] Pulling latest microG APKs..." -repo_index=$(curl -s $repo_url/index-v2.json) -pulled_apk="" - -latest_gms=$(echo "$repo_index" | jq -r '.packages["com.google.android.gms"].versions | to_entries | sort_by(.value.added) | last.value.file.name') -echo "[I] Latest GmsCore version: $latest_gms" - -gms_apk="$apk_dir$latest_gms" -if [ -f "$gms_apk" ] && [ $(stat -c%s "$gms_apk") -gt 1000 ]; then - echo "[I] microG Services already pulled, skipping..." -else - rm -f "$apk_dir/com.google.android.gms*" - echo "[P] Pulling latest microG Services..." - echo "[I] Waiting for $wait_time seconds to avoid rate limiting..." - sleep $wait_time # To avoid rate limiting - - curl -L --progress-bar $repo_url$latest_gms -o "$gms_apk" - if [ $(stat -c%s "$gms_apk") -lt 1000 ]; then - rm -f "$gms_apk" - echo "[E] Failed to pull latest microG Services, probbaly because requests are rate limited. Try again in a moment." - exit 1 - else - pulled_apk=1 - fi -fi - -latest_vending=$(echo "$repo_index" | jq -r '.packages["com.android.vending"].versions | to_entries | sort_by(.value.added) | last.value.file.name') -echo "[I] Latest Phonesky version: $latest_vending" - -vending_apk="$apk_dir$latest_vending" -if [ -f "$vending_apk" ] && [ $(stat -c%s "$vending_apk") -gt 1000 ]; then - echo "[I] microG Companion already pulled, skipping..." -else - rm -f "$apk_dir/com.android.vending*" - echo "[P] Pulling latest microG Companion..." - if [ $pulled_apk ]; then - echo "[I] Waiting for $wait_time seconds to avoid rate limiting..." - sleep $wait_time # To avoid rate limiting - fi - - curl -L --progress-bar $repo_url$latest_vending -o "$vending_apk" - if [ $(stat -c%s "$vending_apk") -lt 1000 ]; then - rm -f "$vending_apk" - echo "[E] Failed to pull latest microG Companion, probbaly because requests are rate limited. Try again in a moment." - exit 1 - else - pulled_apk=1 - fi -fi - -latest_gsf=$(echo "$repo_index" | jq -r '.packages["com.google.android.gsf"].versions | to_entries | sort_by(.value.added) | last.value.file.name') -echo "[I] Latest GoogleServicesFramework version: $latest_gsf" - -gsf_apk="$apk_dir$latest_gsf" -if [ -f "$gsf_apk" ] && [ $(stat -c%s "$gsf_apk") -gt 1000 ]; then - echo "[I] microG Companion already pulled, skipping..." -else - rm -f "$apk_dir/com.google.android.gsf*" - echo "[P] Pulling latest microG Services Framework Proxy..." - if [ $pulled_apk ]; then - echo "[I] Waiting for $wait_time seconds to avoid rate limiting..." - sleep $wait_time # To avoid rate limiting - fi - - curl -L --progress-bar $repo_url$latest_gsf -o "$gsf_apk" - if [ $(stat -c%s "$gsf_apk") -lt 1000 ]; then - rm -f "$gsf_apk" - echo "[E] Failed to pull latest microG Services Framework Proxy, probbaly because requests are rate limited. Try again in a moment." - exit 1 - fi -fi - -echo "[I] All microG APKs are ready!" \ No newline at end of file diff --git a/scripts/build-noogle-microg.sh b/scripts/build-noogle-microg.sh index d18ea00..44a1204 100755 --- a/scripts/build-noogle-microg.sh +++ b/scripts/build-noogle-microg.sh @@ -64,7 +64,7 @@ done apk_count=$(ls "$apk_dir/com.google.android.gms"* "$apk_dir/com.android.vending"* "$apk_dir/com.google.android.gsf"* 2>/dev/null | wc -l) if [ "$apk_count" -lt 3 ]; then - echo "[E] Missing one or more required APKs in $apk_dir/, download them from https://microg.org/download.html" + echo "[E] Missing one or more required APKs in $apk_dir/, use ./download-apks.sh to download them or do it manually" exit 1 elif [ "$apk_count" -gt 3 ]; then echo "[E] Too many APKs, the $apk_dir/ directory must contain exactly 3 APK files" diff --git a/scripts/download-apks.sh b/scripts/download-apks.sh new file mode 100755 index 0000000..ca6f888 --- /dev/null +++ b/scripts/download-apks.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +repo_url=https://microg.org/fdroid/repo +apk_dir="$(git rev-parse --show-toplevel)/apk" +wait_time=10 + +mkdir -p "$apk_dir" + +curl -fs "$repo_url"/index-v2.json | jq -r ' + .packages[] as $pkg | $pkg.versions + | to_entries | sort_by(.value.added) | last.value | [ + $pkg.metadata.name["en-US"], + .file.name, + .file.sha256, + .manifest.versionName + ] | @tsv +' | while IFS=$(printf '\t') read -r name apk sha256 ver; do + path="$apk_dir$apk" + echo "[I] Latest $name version: $ver" + [ -f "$path" ] && echo "$sha256 $path" | sha256sum -c && { + echo + continue + } + + [ "$downloaded" ] && { + echo "[I] Waiting for $wait_time seconds to avoid rate limiting..." + sleep "$wait_time" + } + + rm -f "${path%-*}"* # Remove old versions + + echo "[I] Downloading $name..." + until curl -sfL "$repo_url$apk" -o "$path"; do + echo "[I] Failed to download $name; retrying in $wait_time seconds..." + sleep "$wait_time" + done + downloaded=1 + + echo "$sha256 $path" | sha256sum -c || { + echo "[E] Download checksum verification for $path failed! please re-run the script." + exit 1 + } + echo +done + +echo "[I] All microG APKs are ready!" \ No newline at end of file