├── LICENSE ├── README.md └── fnaify /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2018 Thomas Frohwein 2 | Copyright (c) 2018 Mariusz Zaborski 3 | 4 | Permission to use, copy, modify, and distribute this software for any 5 | purpose with or without fee is hereby granted, provided that the above 6 | copyright notice and this permission notice appear in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | fnaify 1.1-fbsd 2 | =============== 3 | 4 | created 2017-12-27 5 | by Thomas Frohwein (thfr) 6 | 7 | FreeBSD version 2018 8 | by Mariusz Zaborski (oshogbo@) 9 | 10 | Note: 11 | ----- 12 | Please notice that this is an unofficial fork of the fnity implemented by Thomas Frohwein. 13 | 14 | The orginal source code: https://thfr.info/cgi-bin/cvsweb/projects/fnaify/ 15 | 16 | The goal of this fork is to port the OpenBSD version of this script to FreeBSD. 17 | 18 | For more details: https://oshogbo.vexillium.org/blog/58/ 19 | 20 | Intro: 21 | ------ 22 | Script to get FNA-based games ready to run on {Free,Open}BSD 23 | 24 | FNA is a reimplementation of the Microsoft XNA Game Studio 4.0 Refresh libraries. 25 | Thanks to the great work by Ethan Lee (flibitijibibo) games using FNA are 26 | highly portable and can even run on {Free,Open}BSD. 27 | Please refer to https://fna-xna.github.io/ for more information about FNA 28 | 29 | Requirements: 30 | ------------- 31 | 32 | - SDL_GetPlatform to recognize OS. {Free,Open}BSD's SDL2 upgrade to 2.0.7 33 | achieves this by returning "Linux" until FNA patches to recognize 34 | *BSD platforms have been rolled out. 35 | You can check with [sdl2plat](https://github.com/thfrwn/sdl2plat) 36 | which platform is returned by SDL_GetPlatform. 37 | - mono: package available for -current, but not for 6.2 or 6.3. However, a 38 | version of mono with a few bugs can likely be built from the ports tree, by 39 | removing the line starting with `BROKEN` 40 | - game-specific libraries, like theoraplay, mojoshader, ... fnaify 41 | should abort and tell you which libraries need to be installed if 42 | some of them can't be found. 43 | 44 | Usage: 45 | ------ 46 | 47 | `fnaify [-v] [-h]` 48 | 49 | `-h`: display usage information 50 | `-v`: enable verbose output 51 | 52 | Status: 53 | ------- 54 | 55 | The following games have been reported to work with this script: 56 | 57 | * The Adventures of Shuggy (needs different FNA.dll than the bundled one) 58 | * Apotheon (needs a different FNA.dll than the bundled one) 59 | * Atom Zombie Smasher (needs [AZSNotSFML](https://github.com/flibitijibibo/AZSNotSFML)) 60 | * A Virus Named TOM 61 | * Bleed 62 | * Bleed 2 63 | * Brushwood Buddies (needs a different FNA.dll than the bundled one) 64 | * Capsized 65 | * Curse of the Crescent Isle DX (needs different FNA.dll than the bundled one) 66 | * Dust: An Elysian Tail 67 | * Escape Goat 68 | * Escape Goat 2 69 | * FEZ 70 | * Gateways 71 | * HackNet (only runs with -disableweb which is automaticall set by fnaify) 72 | * Hidden In Plain Sight 73 | * Hyphen 74 | * Overdriven Reloaded 75 | * Owlboy 76 | * Paladin 77 | * Press X to Not Die 78 | * Rogue Legacy 79 | * Shipwreck 80 | * Skulls of the Shogun 81 | * Soulcaster 1 82 | * Soulcaster 2 83 | * Stardew Valley (recommend data size limit of 2G) 84 | * TowerFall: Ascension 85 | * Wizorb (needs a different FNA.dll than the bundled one) 86 | * Wyv and Keep (needs a different FNA.dll than the bundled one) 87 | 88 | Caveats 89 | ------- 90 | 91 | * It is recommended to obtain copies of the FNA games that are DRM-free and can 92 | run without the Steam client. 93 | * Some FNA games use non-free libraries like FMOD/FMODStudio that are not 94 | available on {Open, Free}BSD. 95 | 96 | Release History 97 | --------------- 98 | 99 | 1.1-fbsd: rewritten to Bourne shell 100 | 1.1: fix bug selecting .exe by separating input variables 101 | 1.0: initial release 102 | -------------------------------------------------------------------------------- /fnaify: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ################## 4 | # fnaify 1.1 5 | # 6 | # created 2017-12-27 7 | # by Thomas Frohwein (thfr) 8 | # by Mariusz Zaborski (oshogbo) 9 | ################# 10 | # Script to get FNA-based games 11 | # ready to run on BSD 12 | # 13 | # FNA is a reimplementation of the Microsoft XNA Game Studio 4.0 Refresh libraries. 14 | # Thanks to the great work by Ethan Lee (flibitijibibo) games using FNA are 15 | # highly portable and can even run on BSD. 16 | # Please refer to https://fna-xna.github.io/ for more information about FNA 17 | ################## 18 | # License: ISC license 19 | ################## 20 | # Requirements: 21 | # 22 | # - SDL2 library that identifies as 'Linux' rather than 'BSD' 23 | # (needs to be compiled this way; patch to recognize BSD in 24 | # progress upstream) 25 | # - mono 26 | # - some additional libraries, like mojoshader, theorafile, etc 27 | ################## 28 | # Usage: 29 | # 30 | # fnaify [-v] [-h] 31 | # 32 | # -v: verbose output 33 | # -h: print usage information 34 | ########## 35 | # KNOWN BUGS: 36 | # 37 | ########### 38 | # TODO: 39 | # - add notice about libatomstb? 40 | # - provide a way to add in most recent FNA.dll? 41 | ######### 42 | 43 | ######### 44 | # Status of different FNA.dll versions 45 | ######### 46 | 47 | # Problematic FNA.dll versions: 48 | # FNA.dll 15.12.21.0 (Apotheon) 49 | # FNA.dll 0.0.0.1 (Adventures of Shuggy, Rex Rocket, Wizorb, Wyv and Keep) 50 | # FNA.dll 16.1.0.0 (Brushwood) 51 | 52 | # Working FNA.dll versions: 53 | 54 | # MonoGame.Framework.dll 3.0.0.0 (AVNT, Capsized, EscapeGoat, Rogue Legacy, Soulcaster1&2) 55 | # MonoGame.Framework.dll 3.1.2.0 (EscapeGoat2, Gateways, Skulls of the Shogun) 56 | # FNA.dll 16.5.0.0 (Bleed, Super Rad Raygun) 57 | # FNA.dll 16.7.0.0 (TowerFall: Ascension) 58 | # FNA.dll 16.8.0.0 (Paladin, Shipwreck) 59 | # FNA.dll 16.11.0.0 (FEZ) 60 | # FNA.dll 16.12.0.0 (Overdriven Reloaded, Square Heroes) 61 | # FNA.dll 17.2.0.0 (Hacknet) 62 | # FNA.dll 17.3.0.0 (Salt&Sanctuary) 63 | # FNA.dll 17.5.0.0 (Hidden in Plain Sight) 64 | # FNA.dll 17.6.0.0 (Bleed2, Dust: An Elysian Tail, Press X to Not Die) 65 | # FNA.dll 17.9.0.0 (Charlie Murder, The Dishwasher: Vampire Smile) 66 | # FNA.dll 17.11.0.0 (Flinthook, RCRU) -- **Note: These 2 titles have stability issues. Unclear if this may be related to the FNA.dll version.** 67 | # FNA.dll 17.12.0.0 (Curse of the Crescent Isle DX, Hyphen, Owlboy) 68 | 69 | 70 | ######### 71 | # Argument parsing and Usage 72 | ######### 73 | 74 | USAGE="Usage: `basename $0` -v -h" 75 | 76 | while [ $# -gt 0 ] 77 | do 78 | case "$1" in 79 | -h) echo $USAGE; exit 0;; 80 | -v) FNAIFY_DEBUG=1;; 81 | esac 82 | shift 83 | done 84 | 85 | ######### 86 | # VARIABLE AND FUNCTION DEFINITIONS 87 | ######### 88 | 89 | SAVEIFS=$IFS 90 | fna_warning=0 91 | 92 | #monofilearray: array of mono files that need to be removed from the game folder 93 | #ignoredarray: array of lib names to ignore for the configuration checking 94 | #needlibarray[*] is the array that will hold the names of needed libraries 95 | #foundlibarray[*] is the array of the libraries that were found to match 96 | # needlibarray 97 | #missinglibs[*] accumulates missing library names to inform user 98 | 99 | debug_echo() 100 | { 101 | if [ -z "$FNAIFY_DEBUG" ]; then 102 | return 103 | fi 104 | 105 | if [ "${1}" = '-n' ]; then 106 | printf "$2" 107 | else 108 | printf "$1\n" 109 | fi 110 | } 111 | 112 | debug_printdash() 113 | { 114 | if [ -z "$FNAIFY_DEBUG" ]; then 115 | return 116 | fi 117 | 118 | printdash $* 119 | } 120 | 121 | # printdash: print $1 number of dashes in one line, followed by newline 122 | printdash() 123 | { 124 | c=1 125 | while [ $c -le $1 ]; do 126 | echo -n - 127 | c=$((c+1)) 128 | done 129 | echo "" 130 | } 131 | 132 | # inarray: check if $1 is in array $2 (with simple grep) 133 | inarray() 134 | { 135 | firstarg="$1" 136 | shift 1 137 | echo "$*" | grep -q "$firstarg" 138 | } 139 | 140 | # validlib: returns 0 unless $1 is in ignoredarray, then returns 1 141 | # FIXME: this won't be able to deal with whitespace at the moment 142 | validlib() 143 | { 144 | for ig in $ignoredarray; do 145 | if [ "${ig}" = "${1}" ]; then 146 | return 1 147 | fi 148 | done 149 | return 0 150 | } 151 | 152 | # trunklibnam: truncate the name of the library (and remove '-2.0') to match BSD 153 | trunklibnam() 154 | { 155 | libnam="$1" 156 | libnam="$(echo "$libnam" | sed -n -E "s/(.*\.so)\.?.*/\1/p")" 157 | libnam="$(echo "$libnam" | sed -E "s/(libSDL2[^-]*)-2\.0(\.so.*)/\1\2/")" 158 | echo "$libnam" 159 | } 160 | 161 | 162 | libraryname() 163 | { 164 | version="$1" 165 | 166 | debug_echo "" 167 | if [ ! -e "$gamedir/$version" ]; then 168 | debug_echo "Couldn't find library directory $gamedir/$version" 169 | else 170 | debug_echo "Entering library directory $gamedir/$version" 171 | for file in $(ls "$gamedir/$version"); do 172 | # sort out libs (e.g. steam) that need to be ignored 173 | validlib $file 174 | if [ $? -eq 1 ]; then 175 | continue 176 | fi 177 | debug_echo -n "\tfound library file: $file" 178 | file=$(trunklibnam "$file") 179 | debug_echo " -> $file" 180 | inarray $file ${needlibarray} 181 | if [ $? -eq 0 ]; then 182 | debug_echo " - already in array" 183 | elif [ $? -eq 1 ]; then 184 | needlibarray="$needlibarray$file " 185 | else 186 | echo "\n\t - ERROR: inarray returned with unexpected error" 187 | echo "" 188 | exit 1 189 | fi 190 | done 191 | debug_echo "Done with library directory $gamedir/$version" 192 | fi 193 | } 194 | 195 | ignoredarray="libCSteamworks.so 196 | libsteam_api.so 197 | libSteamworksNative.so 198 | libcef.so 199 | libXNAWebRenderer.so 200 | libSteamWrapper.so 201 | libParisSteam.so 202 | steamwrapper.so 203 | libCommunityExpressSW.so 204 | libXNAFileDialog.so 205 | libfmod.so 206 | libfmodstudio.so 207 | libtiny_jpeg.so 208 | libGalaxy64.so 209 | libGalaxyCSharpGlue.so 210 | libGalaxy.so" 211 | 212 | monofilearray="System.dll 213 | Mono.Posix.dll 214 | Mono.Security.dll 215 | System.Configuration.dll 216 | System.Core.dll 217 | System.Data.dll 218 | System.Xml.dll 219 | System.Security.dll 220 | System.Runtime.Serialization.dll 221 | mscorlib.dll 222 | System.Drawing.dll 223 | monoconfig 224 | System.Xml.Linq.dll 225 | WindowsBase.dll 226 | monomachineconfig 227 | I18N.CJK.dll 228 | I18N.MidEast.dll 229 | I18N.Other.dll 230 | I18N.Rare.dll 231 | I18N.West.dll 232 | I18N.dll 233 | Microsoft.CSharp.dll 234 | Mono.CSharp.dll 235 | System.ServiceModel.dll" 236 | 237 | ####################################################################### 238 | 239 | ####### 240 | # MAIN SCRIPT 241 | ####### 242 | 243 | gamedir="`pwd`" 244 | 245 | echo "" 246 | 247 | # scriptfilearray: array of files that are identified as a possible launchscript 248 | debug_echo "Trying to identify the launch script file automatically..." 249 | 250 | scount=0 251 | scriptfilearray="" 252 | sfile="" 253 | IFS=" 254 | " 255 | for sfile in $(find . -maxdepth 1 -type f | grep -Ev "\.[^/]|mono.*config$" | cut -f 2 -d "/") 256 | do 257 | debug_echo "\tfound candidate for launch script file: $sfile" 258 | if [ -z "${scriptfilearray}" ]; then 259 | scriptfilearray="$sfile" 260 | else 261 | scriptfilearray="$scriptfilearray $sfile" 262 | fi 263 | scount=$((scount + 1)) 264 | done 265 | IFS=$SAVEIFS 266 | 267 | if [ $scount -gt 1 ]; then 268 | i=0 269 | for fsc in $scriptfilearray; do 270 | echo "$i: ${fsc}" 271 | i=$((i + 1)) 272 | done 273 | echo -n "Enter number of the file to use as the launch script: " 274 | read input_script 275 | # XXXosho: Very, very ogly... but I don't care. 276 | i=0 277 | for fsc in $scriptfilearray; do 278 | if [ $i -eq $input_script ]; then 279 | scriptfile="${fsc}" 280 | break 281 | fi 282 | i=$((i + 1)) 283 | done 284 | if [ -z "${scriptfile}" ]; then 285 | echo "BAD NUMBER" 286 | exit 1 287 | fi 288 | elif [ $scount -eq 1 ]; then 289 | scriptfile="$scriptfilearray" 290 | else 291 | echo "WARNING: failed to identify a pre-existing launch script." 292 | echo -n "Please enter a name for the launch script to be created: " 293 | read scriptfile 294 | fi 295 | 296 | debug_echo "Identified the following file as the launch script: $scriptfile\n" 297 | 298 | # path and file variable definitions 299 | fullscriptpath="`pwd`/$scriptfile" 300 | IFS=" 301 | " 302 | exefile="" 303 | nexefile=0 304 | for xfile in $(ls "$gamedir" | grep "\.exe$"); do 305 | exefile="$exefile$xfile " 306 | nexefile=$((nexefile + 1)) 307 | done 308 | IFS=$SAVEIFS 309 | 310 | # configfilesarray: array of files in gamedir ending in '.config' 311 | configfilesarray="" 312 | nconfigfilesarray=0 313 | debug_echo "Identifying config files..." 314 | IFS=" 315 | " 316 | for cfile in $(ls "$gamedir" | grep "\.config$"); do 317 | debug_echo "\tfound config file: $cfile" 318 | configfilesarray="$configfilesarray$cfile " 319 | nconfigfilesarray=$((nconfigfilesarray + 1)) 320 | done 321 | IFS=$SAVEIFS 322 | debug_echo "Done identifying config files.\n" 323 | 324 | #### 325 | # identify required libraries 326 | #### 327 | # - at the moment will check 3 sources: lib64, lib, and .config files 328 | # - filenames not whitespace-safe, but should not be used in such files anyway 329 | #### 330 | 331 | debug_echo "Identifying libraries required by the game..." 332 | debug_printdash 45 333 | 334 | # get library names from lib64 and lib folder 335 | needlibarray="" 336 | libraryname "lib64" 337 | libraryname "lib" 338 | 339 | # get library names from .config files 340 | debug_echo "Obtaining library names from the following config files" 341 | 342 | # check that configfilesarray isn't empty 343 | if [ $nconfigfilesarray -lt 1 ]; then 344 | debug_echo "No config files found." 345 | else 346 | cfile="" # empty the variable because it has been used before 347 | for cfile in $configfilesarray; do 348 | debug_echo "\t$cfile" 349 | linuxlines=$(grep "os\=\"linux" "$gamedir/$cfile") 350 | # FIXME: this sed call would probably get messed up if there is 351 | # whitespace 352 | for libstring in $(echo "$linuxlines" | sed -n -E "s/.*target=\"([^\"]+).*/\1/p") 353 | do 354 | # Fix where library name includes directory information 355 | # remove "./" at the beginning of librarynames 356 | libstring=$(echo "$libstring" | sed -E 's/^.\///') 357 | # remove directories at the start of lib name 358 | libstring=$(echo "$libstring" | sed -E 's/^.*\///') 359 | debug_echo -n "\t\tFound library string: $libstring" 360 | # sort out libs (e.g. steam) that need to be ignored 361 | validlib $libstring 362 | if [ $? -eq 1 ]; then 363 | debug_echo " - ignored" 364 | continue 365 | fi 366 | # truncate/fix SDL2 names{,s} 367 | libstring=$(trunklibnam "$libstring") 368 | debug_echo -n " -> $libstring" 369 | #needlibarray[${#needlibarray[*]} + 1]=$libstring 370 | # check if libstring is already in needlibarray. 371 | # add to needlibarray only if not. 372 | inarray $libstring $needlibarray 373 | if [ $? -eq 0 ]; then 374 | debug_echo " - already in array" 375 | elif [ $? -eq 1 ]; then 376 | needlibarray="$needlibarray$libstring " 377 | debug_echo " - added to array" 378 | else 379 | echo "\n\t - ERROR: inarray returned with unexpected error" 380 | echo "" 381 | exit 1 382 | fi 383 | done 384 | done 385 | debug_echo "Done with identifying libraries in config files" 386 | fi 387 | debug_echo "Done with identification of needed libraries." 388 | 389 | # Fix libpngXX.so filename 390 | # XXXosho: check that 391 | debug_echo -n "Fixing libpng filenames if present..." 392 | needlibarray=`echo "${needlibarray}" | sed -E "s/(libpng)..(\.so.*) /\1\2/"` 393 | debug_echo " done.\n" 394 | 395 | # Check if the libraries are available on the system (/usr/local/lib). 396 | # If not, break and inform user which libraries need to be installed. 397 | echo "Checking installed libraries..." 398 | 399 | missinglibs="" 400 | for needlib in ${needlibarray}; do 401 | if ls /usr/local/lib | grep -q "^$needlib"; then 402 | debug_echo "\tfound system lib for: $needlib" 403 | else 404 | if echo "$needlib" | grep -q 'libfreetype\.so.*' ; then 405 | debug_echo "\tfound libfreetype (see /usr/X11R6/lib)" 406 | else 407 | debug_echo "\tNot found: $needlib" 408 | missinglibs="$missinglibs$needlib " 409 | fi 410 | fi 411 | done 412 | debug_echo "" 413 | 414 | # Check if mono is available 415 | debug_echo -n "Checking that mono can be called..." 416 | missingmono=0 417 | #whence mono > /dev/null # XXXosho: not portable ;/ 418 | ls /usr/local/bin/mono > /dev/null # XXXosho: wierd idea 419 | if [ $? -ne 0 ]; then 420 | echo " Couldn't find mono in PATH" 421 | missingmono=1 422 | else 423 | debug_echo " Found mono.\n" 424 | fi 425 | 426 | # check version of framework library (FNA.dll or MonoGame.Framework.dll) 427 | if [ $missingmono -lt 1 ]; then 428 | debug_echo "Checking version of framework library..." 429 | # FIXME: the following code assumes that only one of FNA.dll and MonoGame.Framework.dll is present 430 | if [ -e "$gamedir/FNA.dll" ]; then 431 | fnaversion=`monodis --assembly "$gamedir/FNA.dll" | grep "Version" | tr -d [:alpha:] | tr -d " " | tr -d \:` 432 | fnamajor=`echo "$fnaversion" | sed -n -E "s/\..*//p"` 433 | fnaminor=`echo "$fnaversion" | sed -n -E "s/[0-9]+\.([0-9]+)\.[0-9]+\.[0-9]+/\1/p"` 434 | debug_echo "\tFound FNA.dll version $fnaversion" 435 | debug_echo "fnamajor: $fnamajor" 436 | debug_echo "fnaminor: $fnaminor" 437 | if [ $fnamajor -lt 16 ] || ( [ $fnamajor -eq 16 ] && [ $fnaminor -lt 5 ] ) 438 | then 439 | fna_warning=1 440 | fi 441 | elif [ -e "$gamedir/MonoGame.Framework.dll" ] 442 | then 443 | mgversion=`monodis --assembly "$gamedir/MonoGame.Framework.dll" | grep "Version" | tr -d [:alpha:] | tr -d " " | tr -d \:` 444 | debug_echo "\tFound MonoGame.Framework.dll version $mgversion" 445 | else 446 | echo "WARNING: Could not find framework library (FNA.dll or MonoGame.Framework.dll) in $gamedir" 447 | fi 448 | else 449 | debug_echo "Can't check version of framework library because couldn't find mono" 450 | fi 451 | echo "" 452 | 453 | echo -n "Result of configuration testing: " 454 | if [ -n "${missinglibs}" -o "${missingmono}" -eq 1 ]; then 455 | echo "FAILED" 456 | printdash 39 457 | 458 | echo "The following requirements were not met:" 459 | if [ $missingmono -eq 1 ]; then 460 | echo -n - - 461 | echo " Could not find 'mono' in PATH" 462 | fi 463 | if [ -z "${missinglibs}" ]; then 464 | echo -n - - 465 | echo " Could not find library: $missinglibs" 466 | fi 467 | echo "" 468 | exit 1 469 | fi 470 | echo "SUCCESS" 471 | debug_printdash 40 472 | 473 | #### 474 | # replace all occurences of 'linux' in .config files (dllmap) with 'openbsd' 475 | # (this won't be needed after fna 18.01+ rolled out) 476 | 477 | echo "" 478 | echo "Adjusting config files for BSD..." 479 | 480 | # create backup .linux files of the original .config files 481 | debug_echo -n "\t(creating copy of original config files with suffix '.linux')... " 482 | IFS=" 483 | " 484 | for file in $(ls "$gamedir" | grep "\.config$") 485 | do 486 | if [ ! -e "$gamedir/$file.linux" ]; then 487 | cp -p "$gamedir/$file" "$gamedir/$file.linux" 488 | fi 489 | done 490 | IFS=$SAVEIFS 491 | debug_echo "done." 492 | 493 | # replace all terms in *.config 494 | IFS=" 495 | " 496 | for file in $(ls "$gamedir" | grep "\.config$") 497 | do 498 | # someone may be able to provide a more compact solution for this section 499 | # remove "./" at the beginning of any target="..." 500 | sed -i -E 's/target=".\//target="/g' "$gamedir/$file" 501 | # remove directory lib{,64} at the start of any target="..." 502 | sed -i -E 's/target="lib64\//target="/g' "$gamedir/$file" 503 | sed -i -E 's/target="lib\//target="/g' "$gamedir/$file" 504 | sed -i -E 's/os="linux/os="freebsd/g' "$gamedir/$file" 505 | # remove suffix numbers 506 | sed -i -E 's/\(target=".*\).so.*"/\1.so"/g' "$gamedir/$file" 507 | # fix SDL2 naming by removing the '-2.0' 508 | sed -i -E 's/target="libSDL2-2.0.so/target="libSDL2.so/g' "$gamedir/$file" 509 | # FIXME: find out where 'dll=' is used with .so and how often 510 | # (there was an example with libfreetype in this place somewhere) 511 | #XXXosho: sed -i -E 's/(dll="lib[a-zA-Z]*\.so)[\.0-9]*(.*)$/\1\2/g' "$gamedir/$file" 512 | done 513 | IFS=$SAVEIFS 514 | debug_echo "Config files adjusted." 515 | 516 | # Move interfering mono files out of the way 517 | debug_echo -n "Moving some bundled dll files into linux-files subfolder... " 518 | for file in $monofilearray; do 519 | if [ -e "$gamedir/$file" ]; then 520 | debug_echo "Found bundled mono file: $file" 521 | if [ ! -e "$gamedir/linux-files" ] 522 | then 523 | mkdir "$gamedir/linux-files" 524 | fi 525 | mv "$gamedir/$file" "$gamedir/linux-files" 526 | fi 527 | done 528 | debug_echo " done." 529 | 530 | ### 531 | # create wrapper script in the game folder, set correct .exe in script, and set to executable 532 | 533 | if [ $nexefile -gt 1 ]; then 534 | i=0 535 | for ex in $exefile; do 536 | echo "$i: $ex" 537 | i=$((i + 1)) 538 | done 539 | echo -n "Enter number of .exe file to choose for wrapper script: " 540 | read input_script 541 | # XXXosho: Very, very ogly... but I don't care. 542 | i=0 543 | for ex in $exefile; do 544 | if [ $i -eq $input_script ]; then 545 | selectexe="${ex}" 546 | break 547 | fi 548 | i=$((i + 1)) 549 | done 550 | if [ -z "${selectexe}" ]; then 551 | echo "BAD NUMBER" 552 | exit 1 553 | fi 554 | elif [ $nexefile -eq 1 ]; then 555 | selectexe="$exefile" 556 | else 557 | echo "ERROR: no .exe file found" 558 | echo "" 559 | exit 1 560 | fi 561 | 562 | echo "Replacing launcher script with BSD variant..." 563 | # if not exists, make backup of original script for linux 564 | debug_echo -n "\t(creating copy of original launcher script with suffix '.linux')... " 565 | if [ ! -e "$fullscriptpath.linux" ] 566 | then 567 | cp -p "$fullscriptpath" "$fullscriptpath.linux" 568 | fi 569 | debug_echo "done." 570 | 571 | exe_flags="" 572 | exe_env="" 573 | 574 | ls "$gamedir" | fgrep -iqm 1 "hacknet" 575 | case $? in 576 | 0) exe_flags="-disableweb";; 577 | 1) ;; 578 | *) print "Error in running 'ls | fgrep'"; exit 1;; 579 | esac 580 | 581 | ls "$gamedir" | fgrep -iqm 1 "wizorb" 582 | case $? in 583 | 0) exe_env="MONO_IOMAP=all";; 584 | 1) ;; 585 | *) print "Error in running 'ls | fgrep'"; exit 1;; 586 | esac 587 | 588 | # The content of the wrapper script 589 | cat < $fullscriptpath 590 | #!/bin/sh 591 | 592 | # fnaify wrapper script for launching FNA games on BSD 593 | 594 | # run mono with LD_LIBRARY_PATH to find native BSD libraries 595 | LD_LIBRARY_PATH=/usr/local/lib $exe_env mono $selectexe $exe_flags \$* 596 | EOF 597 | 598 | chmod +x "$fullscriptpath" 599 | 600 | debug_echo "Launcher script replaced.\n" 601 | debug_echo "SETUP COMPLETE" 602 | debug_printdash 14 603 | 604 | echo "" 605 | echo "You should now be able to start the game by running:" 606 | echo "" 607 | echo "\$ ./$scriptfile" 608 | echo "" 609 | 610 | if [ $fna_warning -eq 1 ] 611 | then 612 | echo "WARNING: version of FNA.dll potentially incompatble!" 613 | echo "If unable to launch with this version, consider replacing with newer version." 614 | echo "Source available at https://github.com/FNA-XNA/FNA/releases" 615 | echo "" 616 | fi 617 | --------------------------------------------------------------------------------