Open ghost opened 5 years ago
I definitely would not expect this to work on macOS as is. The things it's trying to mount there are very Linux specific. I don't have a macOS box nor do I know enough about it to figure out what the equivalents would be on macOS.
Yes, but maybe this issue can help figure out a solution regardless.
As far as I can see we need:
Is this correct?
The reason I mount dbus and pulseaudio bits along with /dev/dri
in the container is to provide access to audio and video inside the container. So I think the solution on macOS is to figure out the equivalent set of mounts/options and use those. I don't know that installing dbus or pulseaudio is actually necessary. Ideally, we just want to expose the host system's audio and video without requiring you to install new things.
Alright. The SO Question linked above claims that docker for mac has no audio passthrough, so pulseaudio might be a good way to do it.
For Video it seems that we also need something else as well, this Medium Post suggests using socat and xquartz on the host.
Maybe we could use the anyways required setup step of the catalauncher to ask about the host system and configure the app/pull the right image depending on the system? If this works we could ask the users to install xquartz and pulseaudio first, before starting catalauncher.
Alright. The SO Question linked above claims that docker for mac has no audio passthrough, so pulseaudio might be a good way to do it.
Ah, I see. Yes, in that case it probably makes sense to use pulseaudio and xquartz.
I think it would make sense to have the setup phase check the OS and tell you to install these things on macOS. I don't think this would affect the container, though. What we might need to do is change what we run in the container in order to handle both macOS and Linux hosts.
It occurs to me that it might be simpler to just run the game without Docker on macOS. There are macOS builds that the launcher could download. I just used Docker on Linux because that means you don't have to install any libraries on the host system. But installing pulseaudio and xquartz on macOS seems like a much bigger pain than just installing some SDL libs. The setup command could check for the libs on macOS instead of checking for Docker.
That's very true. Here is some more info on the needed deps.
To build Cataclysm on Mac you'll need Command Line Tools for Xcode and the Homebrew package manager.
...
...SDL shared libraries can be installed using a package manager:
For Homebrew:
brew install sdl2 sdl2_image sdl2_ttf
with sound:
brew install sdl2_mixer libvorbis libogg
I have verified that these dependencies are not needed when using the latest build.
So we might only check for the os and be good to go.
I have verified that these dependencies are not needed when using the latest build.
Really? So both sound and tilesets work without having any of those libs installed? That just doesn't seem possible unless the builds are done statically. While I can't check the build files I'm fairly sure they are dynamic just based on the file size of the OSX downloads.
Well, I downloaded the latest build and did not install these deps on my work machine (which didn't have those installed, since I don't play games there) and it worked. Granted, I'm not 100% sure if those things were already installed for some reason, but I explicitly removed those before trying it again.
brew uninstall --ignore-dependencies sdl2 sdl2_image sdl2_ttf sdl2_mixer
But maybe I'm wrong?
EDIT: Let me clarify the above statement. I downloaded the latest experimental build and tried it without deps and it worked. I had some issues that initially my start screen was not drawn so I assumed at first something went wrong. So I installed the deps. Started it again. Same issue. But when I moved around on the start screen going to MOTD the screen go drawn. So I removed the deps and tried again and had the same behavior (start screen not drawn, moving to MOTD and back and it worked). I now just realized that I have verified that the start screen worked, but not the game itself. So I'll have to try this again tomorrow in my lunch break.
I'm guessing you have the deps installed on your system some other way rather than with brew
. Just search for libsdl (it may be named libSDL
).
Or use ldd
(or whatever the macOS equivalent) to see what the cataclysm-tiles binary links against.
Sorry for being absent. I didn't manage to get the data from my work computer but here are the results of otool -L for the brew built cataclysm-tiles:
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1256.14.0)
/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.4.0)
@rpath/SDL2_mixer.framework/Versions/A/SDL2_mixer (compatibility version 1.0.0, current version 1.0.0)
@rpath/Vorbis.framework/Versions/A/Vorbis (compatibility version 7.0.0, current version 7.5.0)
@rpath/Ogg.framework/Versions/A/Ogg (compatibility version 9.0.0, current version 9.1.0)
/usr/local/opt/lua/lib/liblua.5.2.dylib (compatibility version 5.2.0, current version 5.2.4)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
@rpath/SDL2.framework/Versions/A/SDL2 (compatibility version 1.0.0, current version 3.1.0)
@rpath/SDL2_image.framework/Versions/A/SDL2_image (compatibility version 1.0.0, current version 1.0.0)
@rpath/SDL2_ttf.framework/Versions/A/SDL2_ttf (compatibility version 11.0.0, current version 11.2.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
So I guess you're right then.
I'm not at all familiar with go but I guess we need to find out which OS we're running the launcher on. Here's a SO question covering just that.
It looks to me that we're looking for the sys.GOOS constant.
This can be used in the setup step to find out which os we're on and if we're on darwin, we can print a message about the above mentioned dependencies.
In the launch step we should change launchGame so that when we're running on darwin, we just run the build directly. Beforehand we should copy savegames, mods, memorial data and configs into the appropriate places.
I was also thinking about how to preserve user data between builds. Those builds are coming as bundles and basically look like this:
I think it could work like this:
It might also be possible to simply create symlinks from ~/.catalauncher to the appropriate places, that might make it easier.
More about the location of saves etc. …
First of all this build option for macOS seems relevant:
USE_HOME_DIR=1 places user files (config, saves, graveyard, etc) in the user's home directory. For curses builds, this is /Users/
/.cataclysm-dda, for SDL builds it is /Users/ /Library/Application Support/Cataclysm.
The script which builds the …builds has this option enabled so the right place for user data would be this one then: /Users/
- when new build is found:
- before putting the build into its appropriate place, copy the appropriate data out of the (now old build) bundle into ~/.catalauncher
- copy the build
- copy the data into the build bundle
That middle step isn't necessary. There's no reason to not just unpack the new build and copy the relevant bits from old to new.
I'd love to use symlinks as you suggest but from my testing Cataclysm does not handle these properly (it doesn't actually follow the link).
Re: issues described in #2 by @oliverwalton.
So in theory I think this can work on macOS. But in practice I don't own a Mac and I have no easy way of testing this code on one.
I think there are a couple ways to get this working on macOS.
/dev/dri
, /tmp/.X11-unix
, etc. If it's possible to use Docker on macOS in a similar way, all those references would need to be different. However, based on discussion in #1 this might require installing things like pulseaudio on the macOS host, which is the kind of pain this launcher aims to prevent.A PR to implement one of these approaches would be welcome!
macOS: 10.13.6 (High Sierra) Docker Version: 18.09.1 catalauncher: 0.0.1 (x86 darwin)
When trying to use this on macOS I get the following error:
When trying to add those dirs to docker:
I get this error: