Skip to content

How to install BG2 Tweak pack into BGEE, BG2EE and IWDEE on Linux + modfix script

jde33jde33 Member Posts: 24
edited October 2016 in General Modding
THREAD UPDATE: Tweak pack no longer work on BG:EE + SoD dlc since it's release. (v2.0)
A list of the working mods is here The method will continue to work for IWD 1.4 and may work for BG2:EE 2.0 - If your running into Case Trouble with your mod for BG:EE there are some possible alternate solutions in the thread.

--

If your trying to install mods into BG:EE, BG2:EE or IWD:EE from Steam on Linux, and they don't work.. this is probably the thread your looking for.

I spent several hours tracking down why, what and how to fix this while trying to install the BG2 Tweak Pack from gibberlings3.net on the 3 installed games from Steam. - The trouble with most of these mods seems to be they were written on (primitive) OS's that are case insensitive for file names.. and even the game itself being some 15~ years old and created with w32/fat in mind has this problem with the original files. (Beamdog.. really? You need to fix that and make everything lower case.)

WeiDU on Linux uses a utility to try to fix this but it's not very good.. it's called "tolower" and what it does is recursively renames all your files to lower case. There is no way to roll it back and it actually breaks the Steam version of the games (by altering the libpath) if the mod your installing patches the binary chitin.key file. So after trying a few different things, suffering through many reinstalls and segfaults and straces trying to figure out what the game was looking for and what files should be where I decided to write a script to recursively link all the default files to a lower and a upper case version of their name. This seems to work so I'm going to share and give you a guide here.

One note of caution.. this isn't exactly a clean solution to the problem.. it is however non-destructive unlike tolower. It also modifies your file system so the usual disclaimer applies here. The script is set to operate on data, lang and override folders.. you'll have to edit the script if you need it to work on something else. This may work for other mods but if a mod for some ungodly reason uses MixeD caSE in the file names that it expects.. your pretty much screwed.


Step 1: Install WeiDU on Linux.
Download the Linux binaries: http://www.weidu.org/~thebigg/

The original instructions from G3 are here: http://www.gibberlings3.net/readmes/readme-bg2tweaks.html
Do not follow them, they are just here for reference.
Linux
Download the latest version of WeiDU for Linux from weidu.org and extract (at least) the WeiDU, weinstall and tolower executables in a $PATH directory (E.G. /usr/bin). Following that, open a terminal, cd to your BG2 installation directory, run `tolower' and answer Y to both queries.

You can avoid running the second option (linux.ini) if you've already ran it once in the same directory. To save time, the archive is already tolowered, so there's no need to run the first option (lowercasing file names) either if you've extracted only this mod since the last time you lower cased file name. If you're unsure, running tolower and choosing both options is the safe bet.

After that, run 'weinstall bg2_tweaks' from your game installation directory to install or uninstall the mod.
The instructions tell you to extract the files into /usr/bin, this works but its poor form to do so. /usr/local/bin or ~/bin are saner choices. (You can add a directory of your choosing to your executable path by doing "export PATH=$PATH:/new/path" and/or adding that to your ~/.bash_profile)


Step 2: Download stuff
Download the BG2 Tweak Pack here.
(The same pack is used for all EE games, despite being called BG2 Tweak Pack)
http://www.gibberlings3.net/bg2tweaks/index.php

And get my script here.
https://mega.nz/#!Hst1kZ6Z!gVCwIoXU6THZu-l4jnWqhIUc0kXe1CzQ5iMkaw2t69s


Step 3: Extract everything.
Locate your game folder.
Should be something like ...?? /steamapps/common/Baldur's Gate Enhanced Edition/
You can find out where you installed it in Steam.

Open a terminal to that folder and copy the files you downloaded into it.

Extract the Tweak Pack and my script in the game folder.
tar -xzvf lin-bg2_tweaks-v16.tar.gz
tar -xjvpf modlink.tar.bz2


Step 4: Fix and patch
You should take a look at the script to see what it does, it's not rocket science but its good to know what its going to do. Essentially its going to crawl through your data, lang and override folders and create UPPER and lower case symbolic links for all bif and tlk files.

Run the modlink.sh script.
./modlink.sh

(modlink.sh will dump out a bunch of errors about links existing and not being able to remove stuff, this is expected behaviour.. I hope >.> .. You only need to run it once. Also modlink.sh takes the place of tolower, you no longer need to or should run tolower.)

Then install the mod via
weinstall bg2_tweaks

That should pretty much do it..


If some ppl want me to work on getting their mod Linux compatible, or altering my script to get it to work with their mod just hit me up. I'll see if I can spring the time to help you.


Rock on guys.
-- JD sysadmin extraordinaire
Post edited by jde33 on

Comments

  • NervalNerval Member Posts: 10
    Hello,

    Thanks for the script.

    I hit a problem similar to yours, eg. after having installed bg2_tweaks I have a segfault, using the GOG version on linux.

    Is your script working for this case? In fact I did something very similar: I created a "ghost" arborescence which symlinks everything exactly, while tolowering the original game folder (I kept a backup of course...).

    I now have a "game_symlink" and a "game_tolower" folders, and I launch start.sh targetting game_symlink as if it was the original "game" folder. I'm not sure I'm clear?

    Anyway, I hit a segfault. The coredump gives the following stack trace:

    Program terminated with signal SIGSEGV, Segmentation fault.
    #0 0x087b4017 in fontGetDefaultSize ()
    [Current thread is 1 (Thread 0xf6ef3700 (LWP 3458))]
    (gdb) bt
    #0 0x087b4017 in fontGetDefaultSize ()
    #1 0x08761e4d in CVidFont::SetResRef(CResRef const&, int) ()
    #2 0x08258d2a in CBaldurChitin::PreLoadFonts() ()
    #3 0x0875dc98 in CVidMode::ActivateVideoMode() ()
    #4 0x08744da2 in CChitin::InitializeServices() ()
    #5 0x08749a43 in CChitin::WinMain() ()
    #6 0x0824fd0d in main ()

    So, I cannot really play with the mods installed. If I use the orifinal folder though, the one I did a backup of and that I didn't edit in any way, I can launch the game (well, duh..), and I can also copy the modded override folder inside and play! So, I get the few rule tweaks I wanted. However, the dialog.tlk got changed or something and I now have "Illegal: xxxxxx" for all the items descriptions. Pretty annoying.

    So, in this case, would your script actually permits to entirely play? Is it actually different from what I did? It seems pretty similar.
  • jde33jde33 Member Posts: 24
    edited April 2016
    Not sure exactly what you did but you should never run tolower, only my script. (tolower is a destructive script that changes the casing on the original game files, my script only links the files and allows them to be patched by the various mod patch scripts.) You can't run both. You can also try strace to see what the game is looking for and why its crashing or just reinstall it.

    I haven't flushed out all cases and all mods and I'm sure there are some problems to be found.. but for me its pretty much broken now as these mods won't (by in large) apply to the Siege of Dragonspear update. (confirmation on that for BG2:EE 2.0?) IWD:EE 1.4 will still work tho.

    Beamdog also put in a mention in the patch notes that they fixed the patching for mods on various platforms so it could be that we won't even need this anymore on future mods. I'm not sure why they didn't lowercase everything though they have the power to do this and that would fix every mod on every platform as Android has the same problem. Currently some files have ALL UPERCASE, lower case, and Mixed Case file names. Part of the pain I guess developing on Windows and then porting.. Dev's (and moders) don't think about these things. Visual Studio is available on Linux now so maybe that will help people reliant on that tool.
    Post edited by jde33 on
  • kotekokoteko Member Posts: 179
    Guys, there's an easier and less error-prone solution. Create a ntfs partition (or loopback file), mount it with "windows_names" and "ignore_case" options, and copy your BG copy in there. Safe and sound.

    Also, Steam can be configured to use a separate partition, so if you use that you don't even have to copy. You let Steam install your IE games in the ntfs partition, so you also get the updates.
  • NervalNerval Member Posts: 10
    Hey,

    Thanks, but I don't want to mess with my partitions just for one game. And using ntfs I'd be forced to defrag once a while ;) .

    Nah, I made a small script that does pretty much the same thing as the one presented in this thread (I proposed it elsewhere, you can probably find it in my history or something). It works pretty well and so far I was able to install mods on BGEE, BGIIEE and IWDEE.
  • kotekokoteko Member Posts: 179
    edited April 2016
    @Nerval: No, you wouldn't. NTFS is not FAT. You don't need to defrag just as you don't need to do it with EXT (but a file check might be good every once in a while, and if haven't noticed, it's automatically performed at startup for EXT too, on Linux systems). To be clear, fragmentation can happen on both NTFS and EXT, for heavy and "weird" use - but you can absolutely live with it, if you have a relatively modern drive. A BG-specific partition wouldn't care. Filesystem check instead is important on both, and usually automated. You can configure it in /etc/fstab.

    Also, as I mentioned, this can also be done without partitions: you just create a loopback file formatted with ntfs. I have yet to try it, though, but there's no reasons it wouldn't work (it does work for virtual machines, for example).

    Of course, you are free to use a script that requires manual handling: I, using Steam, am very happy to be able to use mods and update BG seamlessly :)
  • kotekokoteko Member Posts: 179
    edited April 2016
    @Nerval: I've checked your script out. A bit messy to create symlinks but clever :) however, your removal instructions are wrong, and the script can't cope with mixed case filenames in mods (which are, luckily, rare).
  • jde33jde33 Member Posts: 24
    edited May 2016
    @koteko Yes, I consider this to be broken atm. It's here for reference. I'll revisit this and fix this up at some point if needed when things get settled a little more. (modmerge?/beamdog patches changing format?/dlc folders?)

    If your looking for a filesystem, I believe ZFS can be mounted in a case insensitive way via casesensitivity flag. I haven't tried it but what you'd do is create a dataset for your BG folder, or steam folder. (tank/games/steam) set the casesensitivity flag to insensitive, and install the game into that dataset. You probably need to set the flag before you install the game as most ZFS flags work that way, not sure about this one though.

    (He's joking btw, but any filesystem that uses extents would need defrag.. thats.. like all of them basically even ext4. Not that anyone would but ya)

    I think the ZFS dataset would prob be the slickest way to do it tho.. no loopback, no partitions, no mounting.. you would however need to have a ZFS drive in your rig.
    Post edited by jde33 on
  • kotekokoteko Member Posts: 179
    edited May 2016
    jde33 said:

    (He's joking btw, but any filesystem that uses extents would need defrag.. thats.. like all of them basically even ext4. Not that anyone would but ya)

    "Would" - yeah, they all fragment, but so slowly nobody cares :P or should care. The only serious case I've seen is with a heavy use for huge torrent downloads, and for older hard drives.

    I didn't know about ZFS datasets. That is definitely the best way to handle this (if it works as you are suggesting - will have to check that :P). Very cool!
  • UlbUlb Member Posts: 295
    edited May 2016
    wrong thread, sorry I'm an idiot. :)
    Post edited by Ulb on
  • jde33jde33 Member Posts: 24
    edited May 2016
    @koteko Ya, I'd lay it out something like this.

    Drive 1 - Ext4 / + swap
    Drive 2 - ZFS tank
    ZFS mount /mnt/tank
    mkdir /mnt/tank/games/
    make dataset Steam on /mnt/tank/games
    In steam create Library on /mnt/tank/games/Steam but don't install yet.
    Set casesensitivity flag to that dataset
    Install BG in Steam
    Snapshot ZFS so you can rollback if you mod fails without reinstalling. (zfs snapshot -r tank/games/steam@bgvanilla1)

    test test test. rollback as needed (zfs rollback tank/games/steam@bgvanilla1)

    Something like that.. I guess one would have to be fairly versed in ZFS to know how to do that stuff but if you know it you should get my drift. ZFS also isn't the fastest filesystem out there for gaming (its faster than NTFS tho) so you may want to put new games on to ext4
  • kotekokoteko Member Posts: 179
    Truly @jde33, I doubt there's any noticeable difference with games. I have all BGs on NTFS now and they work great, saving/loading is blazing fast. I don't know of any other game that requires case insensitivity so all the others are on ext4.
  • kotekokoteko Member Posts: 179
    edited May 2016
    Also, your proposal requires an additional Drive.. so there's really no difference with my NTFS approach.

    I had understood that "ZFS Datasets" were a sort of user-space filesystem, so I wouldn't have to create a partition or a loopback - just configure an existing folder in my ext4 FS to be "formatted" as ZFS. That sounded very clean for this particular application (a Steam library).

    If I still have to create a partition/own another drive, what do I gain compared to ntfs?
  • jde33jde33 Member Posts: 24
    edited May 2016
    You'd have to want it for some reason. The reason you use two drives is ZFS isn't in the mainline kernel, It's prob safe to boot off it in Linux (FreeBSD does) but I don't know of any distro's that do that. (maybe Gentoo with rootfs? I believe Ubuntu was also supposed to include it in their base 16.04 LTS but maybe they backed out due to the licence? Not sure the licence has always been the issue with ZFS because Sun wrote it to give Solaris a competitive edge over Linux and they didn't want Linux to steal it. I use FreeBSD a lot and FreeBSD doesn't have this issue.)

    I mean I could talk about ZFS's features and the like but that's kinda not the point. The reason we play games on Linux at all is because we want our working environment to be a particular way and we don't want to dual boot or use some other crap workaround. We use our computers for more than just BG or games after all. If that working environment for your desired system includes a powerful file system like ZFS in its image and design then you have a solution builtin for dealing with this. If you want to use loopback devices, samba shares, or whatever else than thats up to you as well.

    All I'm doing is sharing the information for how it can be done.. it's up to you to implement it the way you want. ZFS can be case insensitive and that way is fairly slick and you get a lot of power and control ability to manage your data but you may prefer a simpler setup.
    Post edited by jde33 on
  • kotekokoteko Member Posts: 179
    OK I get what you mean. If you go the extra mile to setup a drive with ZFS, then you have the power of datasets, rollback, folders with case sensitivity or insensitivity etc.

    I personally won't do it, since I only use a small 20GB partition for BG games and ntfs is enough. But it's good to know the possibility is there.
  • jde33jde33 Member Posts: 24
    edited May 2016
    Not to get too far off topic here but I got the answer for you btw on ZFS in Ubuntu here.
    "We at Canonical have conducted a legal review, including discussion with the industry’s leading software freedom legal counsel, of the licenses that apply to the Linux kernel and to ZFS. And in doing so, we have concluded that we are acting within the rights granted and in compliance with their terms of both of those licenses. Others have independently achieved the same conclusion. Differing opinions exist, but please bear in mind that these are opinions."
    Great news, maybe in a few years we'll see ZFS replacing Ext4.

    Anyhow back to this thread.. I intend to fix this and do a write up on it but I'm expecting a patch from Beamdog and I'm hoping they include a system for mods that doesn't involve weidu.
Sign In or Register to comment.