Enhance FDroid code to make selecting minSDK possible

And make the code unnecessarily complex
gf-arm64
FriendlyNeighborhoodShane 4 years ago
parent b787fad019
commit 4f9934f84f

@ -38,7 +38,7 @@ Pretty self explanatory. Leave them blank with a return 0 if there's no use for
## Variables in resdl-conf file
- stuff_repos: List of FDroid format app repositories that are to be downloaded and their contents used by update.sh. First column has their names, which are to be unique and are the key to access them in stuff_download. Second column is the URL, to which appending '/index-v1.jar' should result in an object downloadable by wget.
- stuff_download: List of actual objects that are put into resdl by update.sh. First column is the filepath inside resdl that it should be put in. Second column is the source that it comes from, which is one of local, direct, github, gitlab, or repo. Other columns depend upon the source and any extra columns are ignored. For local, third column is a path resolved against the repo directory from which the file is cp'd to the destination. For direct, the third column is a URL that must be downloadable using wget. For github and gitlab, the third column is [repo owner]/[repo name] from which the newest file is grabbed from the releases page, optionally filtering only for the regex-enabled suffix in the fourth column if provided. For repo, it's the [repo key]/[package name] of which the latest APK is grabbed, optionally filtering for the arch if provided in the third column (arch is usually one of arm64-v8a, armeabi, armeabi-v7a, mips, mips64, x86, x86_64).
- stuff_download: List of actual objects that are put into resdl by update.sh. First column is the filepath inside resdl that it should be put in. Second column is the source that it comes from, which is one of local, direct, github, gitlab, or repo. Other columns depend upon the source and any extra columns are ignored. For local, third column is a path resolved against the repo directory from which the file is cp'd to the destination. For direct, the third column is a URL that must be downloadable using wget. For github and gitlab, the third column is [repo owner]/[repo name] from which the newest file is grabbed from the releases page, optionally filtering only for the regex-enabled suffix in the fourth column if provided. For repo, it's the [repo key]/[package name] of which the latest APK is grabbed, optionally filtering for the arch and minimum SDK if provided in the third column in the format ARCH:SDK (one of these variables can be ommitted but not the colon).
## Functions in resdl-conf file

@ -30,7 +30,7 @@ Fortunately, I am wise. I foresaw this situation, and so I added a way to filter
```
Note that while here I am using a simple suffix for this filtering since there are no other APKs to be confused by, you can also use a more complicated perl-style regex like 'AuroraServices-v[.1-9]*.apk' to protect against future additional APKs in the releases.
Also note that exact same behaviour applies to the fourth column for the 'github' source type.
Additionally note that the fourth column for the 'repo' source type has a different function but similar purpose; It is the architecture to filter all the available APKs by.
Additionally note that the fourth column for the 'repo' source type has a different function but similar purpose; It is the architecture and minimum SDK level to filter all the available APKs by.
Now, when we run update.sh, as long as the internet is still up, we will get a correct AuroraServices.apk where we wanted.

@ -123,13 +123,17 @@ for object in $(echo "$stuff_download" | awk '{ print $1 }'); do
repo)
objectrepo="$(dirname "$objectpath")";
objectpackage="$(basename "$objectpath")";
[ "$objectarg" ] && {
objectarch="$(echo "$objectarg" | awk -F":" '{ print $1 }')";
objectsdk="$(echo "$objectarg" | awk -F":" '{ print $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; }
echo " ---- Getting repo URL for $object from repo $objectrepo";
objectserver="$(jq -r '.repo.address' "$tmpdir/repos/$objectrepo.json")";
if [ "$objectarg" ]; then
echo " ---- Getting object for arch $objectarg";
objectserverfile="$(jq -r --arg pkg "$objectpackage" --arg arch "$objectarg" '.packages[$pkg][] | select ( .nativecode[] == $arch ) | .apkName' "$tmpdir/repos/$objectrepo.json" | head -n1)";
echo " ---- Getting object for args $objectarg [$objectarch] [$objectsdk]";
objectserverfile="$(jq -r --arg pkg "$objectpackage" --arg arch "$objectarch" --arg sdk "$objectsdk" '.packages[$pkg][] | if ( $arch | length ) == 0 then . elif has ( "nativecode" ) then select ( .nativecode[]? == $arch ) else . end | if ( $sdk | length ) == 0 then . else select ( ( .minSdkVersion | tonumber ) <= ( $sdk | tonumber ) ) end | .apkName' "$tmpdir/repos/$objectrepo.json" | head -n1)";
else
objectserverfile="$(jq -r --arg pkg "$objectpackage" '.packages[$pkg][].apkName' "$tmpdir/repos/$objectrepo.json" | head -n1)";
fi;

Loading…
Cancel
Save