Ubuntu Pastebin

Paste from promet at Sat, 30 Apr 2016 20:20:49 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# Global
GOG_BASH_LIBRARY_VERSION="1.1"
HELP_TEXTS=""
_OPTION_FOUND="false"

library_sanity_test() {
  echo "Library responding!"
}

get_gameinfo() {
  cat gameinfo | head -n "${1}" | tail -n 1
}

_option_found() {
 _OPTION_FOUND="true"
}

# define option (short_name,long_name,help_text,arguments,action, arguments)
define_option() {
  local short_name=$1
  local long_name=$2
  local help_text=$3
  local function=$4
  local arguments=$5
  local help_text="${short_name}, \t${long_name} \t\t- ${help_text}"
  HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
  if [ "${arguments}" == "${short_name}" ] || [ "${arguments}" == "${long_name}" ] ; then
    _option_found
    "${function}" $arguments
  fi
}

# version_option (version_gog,version_original)
version_option() {
  local help_text="-v, \t--version \t\t- show version of this package"
  HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
  
  local version_gog=$1
  local version_original=$2
  local arguments=$3
  if [ "${arguments}" == "-v" ] || [ "${arguments}" == "--version" ] ; then
    _option_found
    echo "${version_gog} (GOG.com)"
    echo "${version_original} (Developer)"
  fi
}

system_report_option() {
  local arguments=$1
  local help_text="-p, \t--sysrep \t\t- generate a system report"
  HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
  if [ "${arguments}" == "-p" ] || [ "${arguments}" == "--sysrep" ] ; then
    _option_found
    cd support
    ./gog-system-report.sh
  fi
}

# help_option (arguments)
help_option(){
  local arguments=$1
  local help_text="-h, \t--help \t\t\t- display this help"
  HELP_TEXTS="${HELP_TEXTS}${help_text}\n"
  if [ "${arguments}" == "-h" ] || [ "${arguments}" == "--help" ] ; then
    _option_found
    echo -e "${GAME_NAME} [ ${VERSION} ] (GOG.com)\n"
    echo -e "usage: [command] [argument]\n"
    echo -e "Arguments: "
    echo -e $HELP_TEXTS | column -t -s $'\t'
    echo -e ""
    cat support/support_notice.txt
  fi
}

default_option() {
  if [ "${_OPTION_FOUND}" != "true" ] ; then
    default
  fi
}

standard_options() {
  version_option "${VERSION}" "${VERSION_DEV}" "$@"
  system_report_option "$@"
  
  help_option "$@" # this has to be latest option before default_option
  default_option
}

###
# Native
###

execute_game() {
  local bin_32="${1}" 
  local bin_64="${2}"
  local bin_path32="${3}"
  local bin_path64="${4}"
  local lib_path32="${5}"
  local lib_path64="${6}"
  local arch=$(uname -m)
  if [ "$arch" == "x86_64" ]
  then
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
    cd "${bin_path64}"
    ./"${bin_64}"
  else
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
    cd "${bin_path32}"
    ./"${bin_32}"
 fi   
}

execute_game_with_params() {
  local bin_32="${1}" 
  local bin_64="${2}"
  local bin_path32="${3}"
  local bin_path64="${4}"
  local lib_path32="${5}"
  local lib_path64="${6}"
  local arch=$(uname -m)
  if [ "$arch" == "x86_64" ]
  then
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
    cd "${bin_path64}"
    ./"${bin_64}" "$@"
  else
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
    cd "${bin_path32}"
    ./"${bin_32}" "$@"
 fi   
}

execute_game_aoss() {
  local bin_32="${1}" 
  local bin_64="${2}"
  local bin_path32="${3}"
  local bin_path64="${4}"
  local lib_path32="${5}"
  local lib_path64="${6}"
  local arch=$(uname -m)
  if [ "$arch" == "x86_64" ]
  then
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path64"
    cd "${bin_path64}"
   ./aoss  ./"${bin_64}"
  else
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$lib_path32"
    cd "${bin_path32}"
    ./aoss ./"${bin_32}"
 fi   
}

###
# DOSBox
###

run_dosbox() {
  local conf_1="${1}"
  local conf_2="${2}"
 ./dosbox/dosbox -conf "${conf_1}" -conf "${conf_2}"  -no-console -c exit 
}

###
# ScummVM
###

run_scummvm() {
  local conf="${1}"
 ./scummvm/scummvm -c "${conf}" --themepath=scummvm
}

###
# Wine
###

run_wine() {
  local game_path="${1}"
  local executable="${2}"
  local args="${3}"
  cd "${CURRENT_DIR}/prefix/${game_path}"
  export WINEPREFIX="${CURRENT_DIR}/prefix"
  echo "WINEPREFIX="$WINEPREFIX
  "${CURRENT_DIR}/wine_standalone/wine" "${game_path}" "${executable}" "${args}"
}

run_wine_virtual() {
  local game_path="${1}"
  local executable="${2}"
  local args="${3}"
  cd "${CURRENT_DIR}/prefix/${game_path}"
  export WINEPREFIX="${CURRENT_DIR}/prefix"
  echo "WINEPREFIX="$WINEPREFIX
  "${CURRENT_DIR}/wine_standalone/wine-virtual" "${game_path}" "${executable}" "${args}"
}
Download as text