Compare commits

..

4 Commits

Author SHA1 Message Date
the-sane
1c3bb8d61e update coreutils dependencies 2023-03-26 23:33:46 -04:00
the-sane
077395fa63 Add Ph42oN GPL+Async DXVK source 2023-03-26 19:34:24 -04:00
the-sane
11bd29b444 Paginate API requests to improve speed 2023-03-26 19:31:39 -04:00
the-sane
f090c6cde9 Add gitlab as a download source 2023-03-26 19:23:53 -04:00

View File

@ -71,11 +71,11 @@ fi
# notify-send "lug-helper" "The package 'zstd' was not found on this system. It is required for extracting some runner packages.\n" --icon=dialog-warning
# exit 1
#fi
if [ ! -x "$(command -v mktemp)" ] || [ ! -x "$(command -v sort)" ] || [ ! -x "$(command -v basename)" ] || [ ! -x "$(command -v realpath)" ] || [ ! -x "$(command -v dirname)" ] || [ ! -x "$(command -v numfmt)" ]; then
if [ ! -x "$(command -v mktemp)" ] || [ ! -x "$(command -v sort)" ] || [ ! -x "$(command -v basename)" ] || [ ! -x "$(command -v realpath)" ] || [ ! -x "$(command -v dirname)" ] || [ ! -x "$(command -v cut)" ] || [ ! -x "$(command -v numfmt)" ]; then
# coreutils
# Print to stderr and also try warning the user through notify-send
printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n" 1>&2
notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n- numfmt\n" --icon=dialog-warning
printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n- cut\n- numfmt\n" 1>&2
notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n- cut\n- numfmt\n" --icon=dialog-warning
exit 1
fi
if [ ! -x "$(command -v xargs)" ]; then
@ -171,7 +171,7 @@ runners_dir_flatpak="$lutris_flatpak_dir/data/lutris/runners/wine"
# URLs for downloading Lutris runners
# Elements in this array must be added in quoted pairs of: "description" "url"
# The first string in the pair is expected to contain the runner description
# The second is expected to contain the github api releases url
# The second is expected to contain the api releases url
# ie. "RawFox" "https://api.github.com/repos/rawfoxDE/raw-wine/releases"
runner_sources=(
"GloriousEggroll" "https://api.github.com/repos/GloriousEggroll/wine-ge-custom/releases"
@ -189,11 +189,13 @@ dxvk_dir_flatpak="$lutris_flatpak_dir/data/lutris/runtime/dxvk"
# URLs for downloading dxvk versions
# Elements in this array must be added in quoted pairs of: "description" "url"
# The first string in the pair is expected to contain the runner description
# The second is expected to contain the github api releases url
# The second is expected to contain the api releases url
# ie. "Sporif Async" "https://api.github.com/repos/Sporif/dxvk-async/releases"
# ie. "Ph42oN GPL+Async" "https://gitlab.com/api/v4/projects/Ph42oN%2Fdxvk-gplasync/releases"
dxvk_sources=(
"doitsujin (standard dxvk)" "https://api.github.com/repos/doitsujin/dxvk/releases"
"Sporif Async" "https://api.github.com/repos/Sporif/dxvk-async/releases"
"Ph42oN GPL+Async" "https://gitlab.com/api/v4/projects/Ph42oN%2Fdxvk-gplasync/releases"
"gnusenpai" "https://api.github.com/repos/gnusenpai/dxvk/releases"
"/dev/null" "https://api.github.com/repos/gort818/dxvk/releases"
)
@ -1373,15 +1375,22 @@ download_install() {
;;
esac
# Get the selected download url
# Set the search key we'll use to parse the api for the download url
# To add new sources, handle them here and in the
# download_select_install function below
if [ "$download_url_type" = "github" ]; then
download_url="$(curl -s "$contributor_url" | grep "browser_download_url.*$download_file" | cut -d \" -f4)"
search_key="browser_download_url"
query_string="?per_page=$max_download_items"
elif [ "$download_url_type" = "gitlab" ]; then
search_key="direct_asset_url"
query_string="?per_page=$max_download_items"
else
debug_print exit "Script error: Unknown api/url format in ${download_type}_sources array. Aborting."
fi
# Get the selected download url
download_url="$(curl -s "$contributor_url$query_string" | grep -o "$search_key.*$download_file" | cut -d \" -f3)"
# Sanity check
if [ -z "$download_url" ]; then
message warning "Could not find the requested ${download_type}. The source API may be down or rate limited."
@ -1538,18 +1547,6 @@ download_select_install() {
contributor_name="${download_sources[$1]}"
contributor_url="${download_sources[$1+1]}"
# Check the provided contributor url to make sure we know how to handle it
# To add new sources, add them here and handle in the if statement
# just below and the download_install function above
case "$contributor_url" in
https://api.github.com*)
download_url_type="github"
;;
*)
debug_print exit "Script error: Unknown api/url format in ${download_type}_sources array. Aborting."
;;
esac
# For runners, check GlibC version against runner requirements
if [ "$download_type" = "runner" ] && { [ "$contributor_name" = "/dev/null" ] || [ "$contributor_name" = "TKG" ]; }; then
unset glibc_fail
@ -1615,18 +1612,41 @@ download_select_install() {
fi
fi
# Fetch a list of versions from the selected contributor
# Check the provided contributor url to make sure we know how to handle it
# To add new sources, add them here and handle in the if statement
# just below and the download_install function above
case "$contributor_url" in
https://api.github.com/*)
download_url_type="github"
;;
https://gitlab.com/api/v4/projects/*)
download_url_type="gitlab"
;;
*)
debug_print exit "Script error: Unknown api/url format in ${download_type}_sources array. Aborting."
;;
esac
# Set the search key we'll use to parse the api for the download url
# To add new sources, handle them here, in the if statement
# just above, and the download_install function above
unset download_versions
if [ "$download_url_type" = "github" ]; then
while IFS='' read -r line; do
download_versions+=("$line")
done < <(curl -s "$contributor_url" | awk '/browser_download_url/ {print $2}' | xargs basename -a)
search_key="browser_download_url"
query_string="?per_page=$max_download_items"
elif [ "$download_url_type" = "gitlab" ]; then
search_key="direct_asset_url"
query_string="?per_page=$max_download_items"
else
debug_print exit "Script error: Unknown api/url format in ${download_type}_sources array. Aborting."
fi
# Fetch a list of versions from the selected contributor
unset download_versions
while IFS='' read -r line; do
download_versions+=("$line")
done < <(curl -s "$contributor_url$query_string" | grep -Po "$search_key.*?[^\\\](\",|\$)" | cut -d \" -f3 | xargs basename -a)
# Note: match from search_key until ", or EOL (Handles embedded commas and escaped quotes)
# Sanity check
if [ "${#download_versions[@]}" -eq 0 ]; then
message warning "No $download_type versions were found. The source API may be down or rate limited."