Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)  (Read 2789 times)

astfgl

  • Bay Watcher
  • This is a really personal text: "Personal Text"
    • View Profile
DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« on: October 01, 2010, 09:53:12 am »

I don't know if anyone has done something like this yet...
Or if anyone even cares, but anyway:

Since v0.31.xx Mac OS X builds aren't shine .apps anymore, but simple executables.

I'd like DF on the Mac a little more Mac-like, and thus:


The
Dwarf Fortress
Mac OS X App
ReBundler
ShellScript!
v0.07



... which means a shellscript that converts the standard Mac build to an .app as it was in 0.28.xx builds (and a little better!)!! I don't know if I'm allowed to redistribute rebundled versions, thus I made a script that does the rebundling for you (well, and me). The whole thing is actually pretty ugly, but it works! It certainly lacks a cool name, but who cares (well I do, but not now!)



What you need:

1.) The build you actually want to use.
2.) Version 0.28.181.40d, since it was the last that was an .app.
3.) The script!

Let's see:

Ad 1.)
For PPC Macs the last working version is 0.31.12, which is here!
Btw. can we get PPC builds of the newer versions, please?

Newer versions only work on Intel Macs, thus you might want to use the latest, which is - as of now - 0.31.16.
Get it here!
If the newest version does not work though you are on an Intel Mac, you can try 0.31.12 from above. This seems to be the last version working on all Macs.

Games you already played should work, too and your saves should be preserved. (A backup might be a good idea nevertheless!)

Ad 2.) Click!

Ad 3.) Clack!



What do we do with this?

a) Put those 3 files into a separate directory and
b) Unpack them! (Hint: Doubleclick!)
c) You should now have 2 folders "Dwarf Fortress 0.28.181.40d" and "df_osx" and a file called "rebundler.sh"
If not ...errm... write a comment below!?

d) Now we need the Terminal. (Nota bene: The way to Mac-friendliness is NOT Mac-friendly!)
It should be somewhere in /Applications/Utilities/ or use Spotlight to find it.

e) Go to where you unpacked the files. I'd suppose, this might go like this:
Code: [Select]
cd Desktop
cd temporaryfolderijustmade
ls
If ls shows the files/folders from c) you're good.

f) Now we need to make sure the script is executable. (This might be redundant, since tar preserves permissions, but it won't hurt either...)
Code: [Select]
chmod +x rebundler.sh
Beware! The files you unpacked in c) will be gone inside the new bundle, once you do this next step. If you want to use a game you are currently playing do yourself a favour and make a backup! In principle nothing should be lost, but who knows ...

g) Finally, type:
Code: [Select]
./rebundler.shTo execute the script.

This will take half a second (+15 seconds as security measure) and present you a new directory called "newDF", which holds your shiny new .app! You can drop the dwarf-head into your /Applications, as all necessary files are inside the bundle (unlike the older releases*...)

If you ever happen to look for your savefiles, they are inside the bundle, too.
You can get inside by right-clicking/ctrl-clicking the icon and use "Show Package Contents". From there navigate to
Dwarf Fortress.app/Contents/Resources/workaround/data/save


If anyone has problems or suggestions or ...whatever... just ask!





*Does anybody know how the data/raw folders are located? I had to do a workaround - an .app inside the .app you actually use - to get those inside the bundle. This could use some cleaning!



Preliminary Changelog:

v0.01 - Initial release
v0.02 - Fix for PlistBuddyless Macs and missing locate-db. (Thanks to IAmThad)
v0.03 - Gives feedback now. Does some sanity checks.
v0.04 - Waits for 15 seconds so you can stop the script in case you want/have to.
v0.05 - New About Box. Hope that's good enough ...
v0.06 - Now writes a logfile. Please upload it, if it asks you to!
v0.07 - Added some info from SystemProfiler about the machine type to log.


« Last Edit: October 20, 2010, 03:41:35 pm by astfgl »
Logged

IAmThad

  • Escaped Lunatic
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #1 on: October 02, 2010, 12:05:55 am »

So, I tried this out, but it failed. First, I got an error when your script ran the locate command:
Code: [Select]
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:

  sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.

Later, the script returns the following:
Code: [Select]
./rebundler.sh: line 79: : command not found
Line 79 is where you attempt to execute PlistBuddy, which locate couldn't find. Then, upon further inspection, I discovered that I don't have a copy of PlistBuddy anywhere on my computer, so the above command would have failed anyway.

A bit of research indicates that distributing PlistBuddy is controversial, but perhaps you could include a link to a site that has it available?

As for locating the data / raw folders, I'd bet the folder locations are hardcoded into dwarfort.exe, so that may be tricky.
Logged

astfgl

  • Bay Watcher
  • This is a really personal text: "Personal Text"
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #2 on: October 02, 2010, 04:20:34 am »

Hey! Thanks for the feedback...

So, I tried this out, but it failed. First, I got an error when your script ran the locate command:

This is strange. What version of MacOSX are you on?
As far as I remember on the Mac (as on many other UNIXEN) the locate-db is maintained by one of the weekly cronscripts. Have you ever had your machine turned on long enough to have one of these running? E.g. over night?
You can run this stuff manually (e.g. through MacJanitor, provided you want a GUI...). It might be a good idea since tons of other things are handled by those scripts!



Line 79 is where you attempt to execute PlistBuddy, which locate couldn't find. Then, upon further inspection, I discovered that I don't have a copy of PlistBuddy anywhere on my computer, so the above command would have failed anyway.

This is even stranger.
You should have gotten atleast any version of it, via an Apple update. They usually are inside those receipts the updates leave for later permission-repair (and maybe else!?). I, for an example, have 8 instances and it seems even different versions (though they don't have version output, atleast there are different MD5 sums...):

Code: [Select]
/Library/Receipts/AdditionalEssentials.pkg/Contents/Resources/PlistBuddy
/Library/Receipts/DeveloperTools.pkg/Contents/Resources/PlistBuddy
[...]



A bit of research indicates that distributing PlistBuddy is controversial, but perhaps you could include a link to a site that has it available?

I just uploaded a new version (see first post), which will work even when no instance of PB is found. You won't get the version number in the bundles about-box, though. But that shouldn't hurt too much ;)
Maybe I should just replace PB with some generic sed-magic anyway. It shouldn't be that hard to regex for the version-string and replace it... Or maybe rebuild the Plist from scratch, with the number in place ... I'll have to look into that.
On the other hand, I remember reading somewhere, that on newer versions of MacOS (like 10.5/.6, I don't really know) PlistBuddy is somewhere in the systems path, thus no need to locate it... Can someone confirm this?



As for locating the data / raw folders, I'd bet the folder locations are hardcoded into dwarfort.exe, so that may be tricky.

... feared so! Guess my workaround is not that bad ;)
The redundant files are minimal (few hundred kb), so no real overhead.
And it actually works seamless (once it's all where it belongs ;) )



First thing I should probably fix is the feedback it gives (as of now it's none at all, expect for start and end.)
And most important add some more sanity-checks and error handling. It's not failsafe at all, as you already noticed.


« Last Edit: October 02, 2010, 04:44:55 am by astfgl »
Logged

astfgl

  • Bay Watcher
  • This is a really personal text: "Personal Text"
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #3 on: October 05, 2010, 12:30:31 pm »

First thing I should probably fix is the feedback it gives (as of now it's none at all, expect for start and end.)
And most important add some more sanity-checks and error handling. It's not failsafe at all, as you already noticed.

Updated!! (see first post)
It should be overall better now. Not really failsafe (as in idiotproof :P) yet, but atleast to feedback it gives should help finding errors/bugs!
« Last Edit: October 05, 2010, 12:34:31 pm by astfgl »
Logged

SamMan55

  • Escaped Lunatic
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #4 on: October 05, 2010, 03:24:52 pm »

Your Shiny person. Thank on app builder.
Logged

astfgl

  • Bay Watcher
  • This is a really personal text: "Personal Text"
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #5 on: October 06, 2010, 07:27:37 am »

Your Shiny person. Thank on app builder.

You're welcome!

I suppose it did work for you, didn't it? I'm especially curious since I don't own an Intel Mac (I like my old PPC iBook G4 just too much to throw it away...) if it works out on those. I tried to have it sort the files to their correct location in the newer releases, too. But I can't test if that actually works, since those are Intel Mac only*.

*As far as I understood they don't even cut it on all Intel Macs!?

SamMan55

  • Escaped Lunatic
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #6 on: October 06, 2010, 03:23:20 pm »

Your Shiny person. Thank on app builder.

You're welcome!

I suppose it did work for you, didn't it? I'm especially curious since I don't own an Intel Mac (I like my old PPC iBook G4 just too much to throw it away...) if it works out on those. I tried to have it sort the files to their correct location in the newer releases, too. But I can't test if that actually works, since those are Intel Mac only*.

*As far as I understood they don't even cut it on all Intel Macs!?

it work's fine.
Logged

astfgl

  • Bay Watcher
  • This is a really personal text: "Personal Text"
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #7 on: October 07, 2010, 10:56:05 am »

Updated!! (see first post)
I just added a new version of the script. It just changes some things in the About Box ...
I hope this satisfies licensing needs, that prevent v0.31.12 being on the old releases page.

For those interested read Dwarf Fortress Frontpage on 09/15/2010, or:
Spoiler (click to show/hide)


« Last Edit: October 08, 2010, 06:10:32 am by astfgl »
Logged

astfgl

  • Bay Watcher
  • This is a really personal text: "Personal Text"
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #8 on: October 08, 2010, 06:14:31 am »

Updated!! (see first post)

The script now generates a logfile. It'll tell you if something seems wrong and it'll ask you to post the logfile here. Please do so!

truckman1

  • Bay Watcher
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #9 on: October 08, 2010, 11:23:48 pm »

I was waiting for one of these, I'll be sure to use this eventually, once I finish some other crap on my to-do list.
Logged
Spoiler (click to show/hide)
That's the point, it wouldn't be as fun to crush their souls if they didn't have souls to begin with.

astfgl

  • Bay Watcher
  • This is a really personal text: "Personal Text"
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #10 on: October 09, 2010, 04:10:27 pm »

I was waiting for one of these, I'll be sure to use this eventually, once I finish some other crap on my to-do list.

Spoiler (click to show/hide)

Go ahead and try it... And please report back if you did. I'd really like some feedback on the newer versions, as I can only test v0.31.12 on my PPC Mac.
« Last Edit: October 09, 2010, 04:12:51 pm by astfgl »
Logged

Puriri

  • Bay Watcher
    • View Profile
    • My LEGO MOCs
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #11 on: October 20, 2010, 09:31:45 am »

Okay I tried it and everything worked. I got the app bundle and everything. But if I try opening it it starts opening then just stops.

I haven't moved the app out of the folder or anything so I don't know if I could have changed it.

astfgl

  • Bay Watcher
  • This is a really personal text: "Personal Text"
    • View Profile
Re: DF Mac OS X App ReBundler (incl. Hints for PPC and Intel Macs)
« Reply #12 on: October 20, 2010, 01:26:09 pm »

Okay I tried it and everything worked. I got the app bundle and everything. But if I try opening it it starts opening then just stops.

Could you get me the log file?
It should be named rebundler.log ...

Open the file in TextEdit and post it here (preferably in a Spoiler, I suppose...)



I haven't moved the app out of the folder or anything so I don't know if I could have changed it.

You should be able to put it everywhere you want. I suppose /Applications might be a good idea... But it's not mandatory!


Just a thought: What kind of Mac did you try it on? If it was an old PPC Mac, that's what happens if you try this with a newer version of DF (latest that works is 0.31.12...).

You could try the following:
Right-/ctrl-click the icon and choose "Show Package Contents". Then navigate to "Contents/Resources/workaround". Does the Dwarfhead look allright in there? Or does it have the "No-Go"-Sign?


I just added a new version, which logs the machine type. This should make it more convenient since all needed info is automatically logged.
« Last Edit: October 20, 2010, 03:45:43 pm by astfgl »
Logged