feat(fdroid): download tagged releases
This commit is contained in:
parent
718662b9d8
commit
9f03ababcf
@ -1,6 +1,16 @@
|
|||||||
# 1 URL by line
|
# 1 URL by line
|
||||||
|
# lines starting with a # will be ignored
|
||||||
|
#
|
||||||
# Supported URLS patterns:
|
# Supported URLS patterns:
|
||||||
# - .*github.com/OWNER/REPO.*
|
# - .*github.com/OWNER/REPO.*
|
||||||
# - .*gitlab.com/OWNER/REPO.*
|
# - .*gitlab.com/OWNER/REPO.*
|
||||||
# Exemple:
|
#
|
||||||
|
# line syntax:
|
||||||
|
# URL [tag]
|
||||||
|
#
|
||||||
|
# if no tag, the latest release will be chosen
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
# https://gitlab.com/fdroid/fdroidclient
|
# https://gitlab.com/fdroid/fdroidclient
|
||||||
|
# https://github.com/android-password-store/Android-Password-Store latest
|
||||||
|
|
||||||
|
@ -1,25 +1,32 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
SCRIPT_PATH="$(dirname "$0")"
|
SCRIPT_PATH="$(dirname "$0")"
|
||||||
|
APK_FILE=/apks.txt
|
||||||
|
|
||||||
function get_links() {
|
function get_links() {
|
||||||
FILE="$1"
|
local file="$1"
|
||||||
|
local url
|
||||||
|
local tag
|
||||||
|
local line
|
||||||
|
|
||||||
awk 'NF && $1!~/^#/' "$FILE" | while read -r URL; do
|
while read -r line; do
|
||||||
case "$URL" in
|
IFS=' ' read -r url tag <<< "$line"
|
||||||
*github.com*)
|
|
||||||
"$SCRIPT_PATH/get_github_dl_links.sh" "$URL"
|
case "$url" in
|
||||||
|
*github.com/*)
|
||||||
|
"$SCRIPT_PATH/get_github_dl_links.sh" "$url" "$tag"
|
||||||
;;
|
;;
|
||||||
*gitlab.com*)
|
*gitlab.com/*)
|
||||||
"$SCRIPT_PATH/get_gitlab_dl_links.sh" "$URL"
|
"$SCRIPT_PATH/get_gitlab_dl_links.sh" "$url" "$tag"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done < <(awk 'NF && $1!~/^#/' "$file")
|
||||||
}
|
}
|
||||||
|
|
||||||
LINKS="$(get_links /apks.txt)"
|
function main() {
|
||||||
|
local links; links="$(get_links "$APK_FILE")"
|
||||||
|
|
||||||
(cd /repo/repo/ && xargs -n1 -P8 curl -LOC- <<< "$LINKS")
|
(cd /repo/repo/ && xargs -n1 -P8 curl -LOC- <<< "$LINKS")
|
||||||
(cd /repo/ && fdroid update -c)
|
(cd /repo/ && fdroid update -c)
|
||||||
@ -27,3 +34,6 @@ LINKS="$(get_links /apks.txt)"
|
|||||||
if [ -n "$PUID" ]; then
|
if [ -n "$PUID" ]; then
|
||||||
chown -R "$PUID:$PGID" /repo/
|
chown -R "$PUID:$PGID" /repo/
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
@ -1,19 +1,35 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
API='https://api.github.com'
|
API='https://api.github.com'
|
||||||
CONTENT_TYPE='"application/vnd.android.package-archive"'
|
|
||||||
|
function get_tag_urls() {
|
||||||
|
local repo="$1"
|
||||||
|
local tag="$2"
|
||||||
|
|
||||||
|
curl -sSL "$API/repos/$repo/releases/tags/$tag" | \
|
||||||
|
jq -r '.assets[] | select(.name | test(".apk$")) | .browser_download_url'
|
||||||
|
}
|
||||||
|
|
||||||
function get_urls() {
|
function get_urls() {
|
||||||
local repo="$1"
|
local repo="$1"
|
||||||
|
|
||||||
curl -sSL "$API/repos/$repo/releases/latest" | \
|
curl -sSL "$API/repos/$repo/releases/latest" | \
|
||||||
jq -r ".assets | select(.[].content_type == $CONTENT_TYPE) | .[].browser_download_url"
|
jq -r '.assets[] | select(.name | test(".apk$")) | .browser_download_url'
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_repo_name_from_url() {
|
function get_repo_name_from_url() {
|
||||||
grep -Po '(?<=github.com/)[[:alnum:]]+/[[:alnum:]]+' <<< "$1"
|
grep -Po '(?<=github.com/)[\w\d-]+/[\w\d-]+' <<< "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
for repo in "$@"; do
|
function main() {
|
||||||
get_urls "$(get_repo_name_from_url "$repo")"
|
local repo; repo="$(get_repo_name_from_url "$1")"
|
||||||
done
|
local tag="$2"
|
||||||
|
|
||||||
|
if [ -z "$tag" ]; then
|
||||||
|
get_urls "$repo"
|
||||||
|
else
|
||||||
|
get_tag_urls "$repo" "$tag"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
@ -2,19 +2,36 @@
|
|||||||
|
|
||||||
API='https://gitlab.com/api/v4'
|
API='https://gitlab.com/api/v4'
|
||||||
|
|
||||||
|
function get_tag_urls() {
|
||||||
|
local repo="$1"
|
||||||
|
local tag="$2"
|
||||||
|
|
||||||
|
curl -L "$API/projects/$repo/releases/$tag" | \
|
||||||
|
jq -r '.assets.links[] | select(.name | test(".apk$")) | .url'
|
||||||
|
}
|
||||||
|
|
||||||
function get_urls() {
|
function get_urls() {
|
||||||
local repo="$1"
|
local repo="$1"
|
||||||
|
|
||||||
curl -L "$API/projects/$repo/releases" | \
|
curl -L "$API/projects/$repo/releases" | \
|
||||||
jq -r '.[0].assets.links | select(.[].name | test(".apk$")) | .[].url'
|
jq -r '.[0].assets.links[] | select(.name | test(".apk$")) | .url'
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_repo_name_from_url() {
|
function get_repo_name_from_url() {
|
||||||
printf '%s' \
|
printf '%s' \
|
||||||
"$(grep -Po '(?<=gitlab.com/)[[:alnum:]]+/[[:alnum:]]+' <<< "$1")" | \
|
"$(grep -Po '(?<=gitlab.com/)[\w\d-]+/[\w\d-]+' <<< "$1")" | \
|
||||||
jq -sRr '@uri'
|
jq -sRr '@uri'
|
||||||
}
|
}
|
||||||
|
|
||||||
for repo in "$@"; do
|
function main() {
|
||||||
get_urls "$(get_repo_name_from_url "$repo")"
|
local repo; repo="$(get_repo_name_from_url "$1")"
|
||||||
done
|
local tag="$2"
|
||||||
|
|
||||||
|
if [ -z "$tag" ]; then
|
||||||
|
get_urls "$repo"
|
||||||
|
else
|
||||||
|
get_tag_urls "$repo" "$tag"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user