Commit 0008ba29 authored by Buxdehuda's avatar Buxdehuda

Cache version tags

parent c6b76602
Pipeline #45652769 passed with stage
in 11 minutes and 20 seconds
......@@ -27,3 +27,4 @@ pages:
cache:
paths:
- fdroid
- cache
......@@ -11,6 +11,7 @@ Add new download information in [apks.json](apks.json):
```json
{
"name": "App",
"baseUrl": "https://example.org/download/App-{ver}-{arch}.apk",
"architectures": ["arm", "x86"],
"version": {
......@@ -21,7 +22,7 @@ Add new download information in [apks.json](apks.json):
}
```
Everything except `baseUrl` is optional.
Everything except `name` and `baseUrl` is optional.
`{ver}` and `{arch}` will get automatically replaced with the corresponding version and all architectures.
Note that you can use a single `regex` string instead of `json` to query the version.
......
[
{
"name": "Firefox",
"baseUrl": "https://download.mozilla.org/?product=fennec-latest&os=android{arch}&lang=multi",
"architectures": ["", "-x86"]
},
{
"name": "Firefox Beta",
"baseUrl": "https://download.mozilla.org/?product=fennec-beta-latest&os=android{arch}&lang=multi",
"architectures": ["", "-x86"],
"ignoreErrors": true
},
{
"name": "Firefox Focus",
"baseUrl": "https://download-installer.cdn.mozilla.net/pub/android/focus/latest/Focus-{arch}.apk",
"architectures": ["arm", "x86"]
},
{
"name": "Firefox Klar",
"baseUrl": "https://download-installer.cdn.mozilla.net/pub/android/focus/latest/Klar-{arch}.apk",
"architectures": ["arm", "x86"]
},
{
"name": "Brave",
"baseUrl": "https://github.com/brave/browser-android-tabs/releases/download/{ver}/Brave{arch}.apk",
"architectures": ["arm", "x86"],
"version": {
......
{}
\ No newline at end of file
import json
import os
import re
import requests
import subprocess
......@@ -7,7 +6,8 @@ import subprocess
def main():
with open("apks.json") as file:
apks = json.load(file)
os.chdir("fdroid/repo")
with open("cache/versions.json") as file:
versions = json.load(file)
for apk in apks:
ver = ""
ignore = False
......@@ -17,6 +17,9 @@ def main():
ver = get_version_json(verObj["url"], verObj["json"])
elif "regex" in verObj:
ver = get_version_regex(verObj["url"], verObj["regex"])
if apk["name"] in versions and ver == versions[apk["name"]]:
break
versions[apk["name"]] = ver
if "ignoreErrors" in apk:
ignore = apk["ignoreErrors"]
if "architectures" in apk:
......@@ -24,12 +27,14 @@ def main():
download(apk["baseUrl"].format(arch=arch, ver=ver), ignore)
else:
download(apk["baseUrl"].format(ver=ver), ignore)
with open('cache/versions.json', 'w') as file:
json.dump(versions, file, ensure_ascii=False)
def download(download_url, ignore):
if download_url.endswith(".apk"):
retcode = subprocess.call(["wget", "-N", download_url])
retcode = subprocess.call(["wget", "-N", "-P", "fdroid/repo", download_url])
else:
retcode = subprocess.call(["wget", "-nc", "--content-disposition", download_url])
retcode = subprocess.call(["wget", "-nc", "--content-disposition", "-P", "fdroid/repo", download_url])
if not ignore and retcode != 0:
raise Exception("Failed downloading " + download_url)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment