openra: 20181215 -> 20190314 + updated other engine releases and mods
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
# for mod in $(nix eval --raw '(
|
||||
# with import <nixpkgs> { };
|
||||
@@ -9,9 +10,7 @@
|
||||
# ./mod-update.sh "$mod"
|
||||
# done
|
||||
|
||||
# Uses:
|
||||
# https://github.com/msteen/nix-prefetch
|
||||
# https://github.com/msteen/nix-update-fetch
|
||||
# Uses: https://github.com/msteen/nix-upfetch
|
||||
|
||||
mod=$1
|
||||
commit_count=$2
|
||||
@@ -19,7 +18,7 @@ token=
|
||||
nixpkgs='<nixpkgs>'
|
||||
|
||||
die() {
|
||||
ret=$?
|
||||
local ret=$?
|
||||
echo "$*" >&2
|
||||
exit $ret
|
||||
}
|
||||
@@ -34,13 +33,16 @@ get_sha1() {
|
||||
curl -H "Authorization: token $token" -H 'Accept: application/vnd.github.VERSION.sha' "https://api.github.com/repos/$owner/$repo/commits/$ref"
|
||||
}
|
||||
|
||||
[[ -n $mod ]] || die "The first argument of this script has to be a mod identifier."
|
||||
|
||||
[[ -n $token ]] || die "Please edit this script to include a GitHub API access token, which is required for API v4:
|
||||
https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/"
|
||||
|
||||
# Get current mod_owner and mod_repo.
|
||||
vars=$(nix-prefetch --file "$nixpkgs" "openraPackages.mods.$mod" --index 0 --quiet --output json --skip-hash > >(
|
||||
vars=$(nix-prefetch --file "$nixpkgs" "openraPackages.mods.$mod" --index 0 --quiet --output json --no-compute-hash > >(
|
||||
jq --raw-output 'with_entries(select(.value | contains("\n") | not)) | to_entries | .[] | .key + "=" + .value')) || exit
|
||||
|
||||
mod_owner=; mod_repo=; mod_rev=
|
||||
while IFS='=' read -r key val; do
|
||||
declare "mod_${key}=${val}"
|
||||
done <<< "$vars"
|
||||
@@ -65,11 +67,12 @@ else
|
||||
}'
|
||||
fi
|
||||
|
||||
query='query {
|
||||
repository(owner: \"'"$mod_owner"'\", name: \"'"$mod_repo"'\") {
|
||||
# shellcheck disable=SC2089
|
||||
query='{
|
||||
repository(owner: "'$mod_owner'", name: "'$mod_repo'") {
|
||||
defaultBranchRef {
|
||||
target {
|
||||
... on Commit '"$query_on_commit"'
|
||||
... on Commit '$query_on_commit'
|
||||
}
|
||||
}
|
||||
licenseInfo {
|
||||
@@ -80,7 +83,9 @@ query='query {
|
||||
|
||||
# Newlines are not allowed in a query.
|
||||
# https://developer.github.com/v4/guides/forming-calls/#communicating-with-graphql
|
||||
# shellcheck disable=SC2086 disable=SC2090 disable=SC2116
|
||||
query=$(echo $query)
|
||||
query=${query//\"/\\\"}
|
||||
|
||||
# https://developer.github.com/v4/guides/using-the-explorer/#configuring-graphiql
|
||||
json=$(curl -H "Authorization: bearer $token" -X POST -d '{ "query": "'"$query"'" }' https://api.github.com/graphql) || exit
|
||||
@@ -99,12 +104,14 @@ vars=$(jq --raw-output '.data.repository | {
|
||||
rev: .oid,
|
||||
}) | to_entries | .[] | .key + "=" + (.value | tostring)' <<< "$json") || exit
|
||||
|
||||
mod_license_key=; mod_version=; mod_rev=
|
||||
while IFS='=' read -r key val; do
|
||||
declare "mod_${key}=${val}"
|
||||
done <<< "$vars"
|
||||
|
||||
mod_config=$(curl "https://raw.githubusercontent.com/$mod_owner/$mod_repo/$mod_rev/mod.config") || exit
|
||||
|
||||
mod_id=; engine_version=; automatic_engine_management=; automatic_engine_source=
|
||||
while IFS='=' read -r key val; do
|
||||
declare "${key,,}=$(jq --raw-output . <<< "$val")"
|
||||
done < <(grep '^\(MOD_ID\|ENGINE_VERSION\|AUTOMATIC_ENGINE_MANAGEMENT\|AUTOMATIC_ENGINE_SOURCE\)=' <<< "$mod_config")
|
||||
@@ -116,6 +123,7 @@ echo >&2
|
||||
|
||||
[[ $mod_id == "$mod" ]] ||
|
||||
die "The mod '$mod' reports being mod '$mod_id' instead."
|
||||
# shellcheck disable=SC2005 disable=SC2046
|
||||
[[ $mod_license_key == gpl-3.0 ]] ||
|
||||
[[ $(echo $(head -2 <(curl "https://raw.githubusercontent.com/$mod_owner/$mod_repo/$mod_rev/COPYING"))) == 'GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007' ]] ||
|
||||
die "The mod '$mod' is licensed under '$mod_license_key' while expecting 'gpl-3.0'."
|
||||
@@ -126,6 +134,7 @@ echo >&2
|
||||
|
||||
engine_owner=${BASH_REMATCH[1]}
|
||||
engine_repo=${BASH_REMATCH[2]}
|
||||
# shellcheck disable=SC2016
|
||||
[[ ${BASH_REMATCH[3]} == '${ENGINE_VERSION}' ]] || engine_version=${BASH_REMATCH[3]}
|
||||
engine_rev=$(get_sha1 "$engine_owner" "$engine_repo" "$engine_version")
|
||||
|
||||
@@ -146,6 +155,6 @@ for type in mod engine; do
|
||||
done
|
||||
var="${type}_version"
|
||||
version=${!var}
|
||||
nix-update-fetch --yes --version "$version" "$(nix-prefetch --quiet --file "$nixpkgs" "openraPackages.mods.$mod" --index $i --output json --with-position --diff -- "${fetcher_args[@]}")"
|
||||
nix-upfetch --yes --version "$version" "$(nix-preupfetch --file "$nixpkgs" "openraPackages.mods.$mod" --index $i -- "${fetcher_args[@]}")"
|
||||
(( i++ ))
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user