···1-#!/bin/sh
2show_error() {
3 if command -v zenity > /dev/null; then
4 zenity --no-wrap --no-markup --error --title "OpenRA - @title@" --text "$1" 2>/dev/null
···1213# Check for missing assets
14assetsError='@assetsError@'
15-if [ -n "$assetsError" -a ! -d "$HOME/.openra/Content/@name@" ]; then
16 show_error "$assetsError"
17fi
18···20mono --debug OpenRA.Game.exe Game.Mod=@name@ Engine.LaunchPath="@out@/bin/openra-@name@" Engine.ModSearchPaths="@out@/lib/openra-@name@/mods" "$@"
2122# Show a crash dialog if something went wrong
23-if [ $? -ne 0 -a $? -ne 1 ]; then
24 show_error $'OpenRA - @title@ has encountered a fatal error.\nPlease refer to the crash logs for more information.\n\nLog files are located in ~/.openra/Logs'
25fi
···1+#!/usr/bin/env bash
2show_error() {
3 if command -v zenity > /dev/null; then
4 zenity --no-wrap --no-markup --error --title "OpenRA - @title@" --text "$1" 2>/dev/null
···1213# Check for missing assets
14assetsError='@assetsError@'
15+if [[ -n "$assetsError" && ! -d "$HOME/.openra/Content/@name@" ]]; then
16 show_error "$assetsError"
17fi
18···20mono --debug OpenRA.Game.exe Game.Mod=@name@ Engine.LaunchPath="@out@/bin/openra-@name@" Engine.ModSearchPaths="@out@/lib/openra-@name@/mods" "$@"
2122# Show a crash dialog if something went wrong
23+if (( $? != 0 && $? != 1 )); then
24 show_error $'OpenRA - @title@ has encountered a fatal error.\nPlease refer to the crash logs for more information.\n\nLog files are located in ~/.openra/Logs'
25fi
+18-9
pkgs/games/openra/mod-update.sh
···1#!/usr/bin/env bash
023# for mod in $(nix eval --raw '(
4# with import <nixpkgs> { };
···9# ./mod-update.sh "$mod"
10# done
1112-# Uses:
13-# https://github.com/msteen/nix-prefetch
14-# https://github.com/msteen/nix-update-fetch
1516mod=$1
17commit_count=$2
···19nixpkgs='<nixpkgs>'
2021die() {
22- ret=$?
23 echo "$*" >&2
24 exit $ret
25}
···34 curl -H "Authorization: token $token" -H 'Accept: application/vnd.github.VERSION.sha' "https://api.github.com/repos/$owner/$repo/commits/$ref"
35}
360037[[ -n $token ]] || die "Please edit this script to include a GitHub API access token, which is required for API v4:
38https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/"
3940# Get current mod_owner and mod_repo.
41-vars=$(nix-prefetch --file "$nixpkgs" "openraPackages.mods.$mod" --index 0 --quiet --output json --skip-hash > >(
42 jq --raw-output 'with_entries(select(.value | contains("\n") | not)) | to_entries | .[] | .key + "=" + .value')) || exit
43044while IFS='=' read -r key val; do
45 declare "mod_${key}=${val}"
46done <<< "$vars"
···65}'
66fi
6768-query='query {
69- repository(owner: \"'"$mod_owner"'\", name: \"'"$mod_repo"'\") {
070 defaultBranchRef {
71 target {
72- ... on Commit '"$query_on_commit"'
73 }
74 }
75 licenseInfo {
···8081# Newlines are not allowed in a query.
82# https://developer.github.com/v4/guides/forming-calls/#communicating-with-graphql
083query=$(echo $query)
08485# https://developer.github.com/v4/guides/using-the-explorer/#configuring-graphiql
86json=$(curl -H "Authorization: bearer $token" -X POST -d '{ "query": "'"$query"'" }' https://api.github.com/graphql) || exit
···99 rev: .oid,
100}) | to_entries | .[] | .key + "=" + (.value | tostring)' <<< "$json") || exit
1010102while IFS='=' read -r key val; do
103 declare "mod_${key}=${val}"
104done <<< "$vars"
105106mod_config=$(curl "https://raw.githubusercontent.com/$mod_owner/$mod_repo/$mod_rev/mod.config") || exit
1070108while IFS='=' read -r key val; do
109 declare "${key,,}=$(jq --raw-output . <<< "$val")"
110done < <(grep '^\(MOD_ID\|ENGINE_VERSION\|AUTOMATIC_ENGINE_MANAGEMENT\|AUTOMATIC_ENGINE_SOURCE\)=' <<< "$mod_config")
···116117[[ $mod_id == "$mod" ]] ||
118 die "The mod '$mod' reports being mod '$mod_id' instead."
0119[[ $mod_license_key == gpl-3.0 ]] ||
120[[ $(echo $(head -2 <(curl "https://raw.githubusercontent.com/$mod_owner/$mod_repo/$mod_rev/COPYING"))) == 'GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007' ]] ||
121 die "The mod '$mod' is licensed under '$mod_license_key' while expecting 'gpl-3.0'."
···126127engine_owner=${BASH_REMATCH[1]}
128engine_repo=${BASH_REMATCH[2]}
0129[[ ${BASH_REMATCH[3]} == '${ENGINE_VERSION}' ]] || engine_version=${BASH_REMATCH[3]}
130engine_rev=$(get_sha1 "$engine_owner" "$engine_repo" "$engine_version")
131···146 done
147 var="${type}_version"
148 version=${!var}
149- nix-update-fetch --yes --version "$version" "$(nix-prefetch --quiet --file "$nixpkgs" "openraPackages.mods.$mod" --index $i --output json --with-position --diff -- "${fetcher_args[@]}")"
150 (( i++ ))
151done
···1#!/usr/bin/env bash
2+# shellcheck disable=SC2034
34# for mod in $(nix eval --raw '(
5# with import <nixpkgs> { };
···10# ./mod-update.sh "$mod"
11# done
1213+# Uses: https://github.com/msteen/nix-upfetch
001415mod=$1
16commit_count=$2
···18nixpkgs='<nixpkgs>'
1920die() {
21+ local ret=$?
22 echo "$*" >&2
23 exit $ret
24}
···33 curl -H "Authorization: token $token" -H 'Accept: application/vnd.github.VERSION.sha' "https://api.github.com/repos/$owner/$repo/commits/$ref"
34}
3536+[[ -n $mod ]] || die "The first argument of this script has to be a mod identifier."
37+38[[ -n $token ]] || die "Please edit this script to include a GitHub API access token, which is required for API v4:
39https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/"
4041# Get current mod_owner and mod_repo.
42+vars=$(nix-prefetch --file "$nixpkgs" "openraPackages.mods.$mod" --index 0 --quiet --output json --no-compute-hash > >(
43 jq --raw-output 'with_entries(select(.value | contains("\n") | not)) | to_entries | .[] | .key + "=" + .value')) || exit
4445+mod_owner=; mod_repo=; mod_rev=
46while IFS='=' read -r key val; do
47 declare "mod_${key}=${val}"
48done <<< "$vars"
···67}'
68fi
6970+# shellcheck disable=SC2089
71+query='{
72+ repository(owner: "'$mod_owner'", name: "'$mod_repo'") {
73 defaultBranchRef {
74 target {
75+ ... on Commit '$query_on_commit'
76 }
77 }
78 licenseInfo {
···8384# Newlines are not allowed in a query.
85# https://developer.github.com/v4/guides/forming-calls/#communicating-with-graphql
86+# shellcheck disable=SC2086 disable=SC2090 disable=SC2116
87query=$(echo $query)
88+query=${query//\"/\\\"}
8990# https://developer.github.com/v4/guides/using-the-explorer/#configuring-graphiql
91json=$(curl -H "Authorization: bearer $token" -X POST -d '{ "query": "'"$query"'" }' https://api.github.com/graphql) || exit
···104 rev: .oid,
105}) | to_entries | .[] | .key + "=" + (.value | tostring)' <<< "$json") || exit
106107+mod_license_key=; mod_version=; mod_rev=
108while IFS='=' read -r key val; do
109 declare "mod_${key}=${val}"
110done <<< "$vars"
111112mod_config=$(curl "https://raw.githubusercontent.com/$mod_owner/$mod_repo/$mod_rev/mod.config") || exit
113114+mod_id=; engine_version=; automatic_engine_management=; automatic_engine_source=
115while IFS='=' read -r key val; do
116 declare "${key,,}=$(jq --raw-output . <<< "$val")"
117done < <(grep '^\(MOD_ID\|ENGINE_VERSION\|AUTOMATIC_ENGINE_MANAGEMENT\|AUTOMATIC_ENGINE_SOURCE\)=' <<< "$mod_config")
···123124[[ $mod_id == "$mod" ]] ||
125 die "The mod '$mod' reports being mod '$mod_id' instead."
126+# shellcheck disable=SC2005 disable=SC2046
127[[ $mod_license_key == gpl-3.0 ]] ||
128[[ $(echo $(head -2 <(curl "https://raw.githubusercontent.com/$mod_owner/$mod_repo/$mod_rev/COPYING"))) == 'GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007' ]] ||
129 die "The mod '$mod' is licensed under '$mod_license_key' while expecting 'gpl-3.0'."
···134135engine_owner=${BASH_REMATCH[1]}
136engine_repo=${BASH_REMATCH[2]}
137+# shellcheck disable=SC2016
138[[ ${BASH_REMATCH[3]} == '${ENGINE_VERSION}' ]] || engine_version=${BASH_REMATCH[3]}
139engine_rev=$(get_sha1 "$engine_owner" "$engine_repo" "$engine_version")
140···155 done
156 var="${type}_version"
157 version=${!var}
158+ nix-upfetch --yes --version "$version" "$(nix-preupfetch --file "$nixpkgs" "openraPackages.mods.$mod" --index $i -- "${fetcher_args[@]}")"
159 (( i++ ))
160done