Here’s a brief Ruby scriptone that demos Shoes’ events and animationand it’s been injected into an EXE and a DMG:
These are web installers. Using native calls on each platform, they’ll install Shoes if no Shoes is found on the system. (If you already have Shoes installed, though, it won’t update for you.) Not a big deal, not worth mentioning really. Installers.
But, hold up. What if I told you that Shoes can build EXEs and DMGs on any of its platforms? Without needing a compiler. You can build EXEs and DMGs from Windows. And from Linux. And from OS X.
This is the built-in packager, which can be brought up with
shoes -p (or
shoes --package on Windows and Linux. On OS X, it’s in the Shoes main menu. (Or ⌘-x.)
Even as Ron Popeil is to the unflavored turkey, so is Shoes to these most willing binaries.
If you poke around with a hex editor inside Windows’ PE binary format, you’ll find an .rsrc section at the end of the file which contains the icons and dialog boxes. I insert the Ruby script into this mess.
binj = Binject::EXE.new("blank.exe") binj.inject("SHOES_FILENAME", "simple-accordion.rb") File.open("simple-accordion.rb") do |f| binj.inject("SHOES_PAYLOAD", f) end binj.save("accordion.exe")
The blank.exe is the empty web installer. It’s an executable that scans its own resources and then bases its moves on what it finds. If it finds a Ruby script (or Shy file) in the
SHOES_PAYLOAD resource, it’ll run it. And if it finds an installer in the
SHOES_SETUP resource, it’ll run the installer rather than going out to the web.
So, yeah, blank.exe comes with Shoes and we inject when you go to package. Yeah?
Fabricating DMGs is a different kind of binary hacking. In this case, we’ve got to build an HFS+ partition and then convert that to a DMG.
One would start by making a small, raw HFS+ file and gzipping it.
$ dd if=/dev/zero of=blank.hfs bs=512K count=1 $ mkfs.hfsplus -v Shoes blank.hfs $ gzip blank.hfs $ mv blank.hfs.gz blank.hfz
This blank disk gets included with Shoes as well. And at runtime, we use our extension to build the innards of the DMG.
binj = Binject::DMG.new("blank.hfz", "Accordion") binj.inject_dir("Accordion.app", "/tmp/accordion.app") binj.chmod_file(0755, "Accordion.app/Contents/MacOS/accordion-launch") binj.save("accordion.dmg")
This amazing code is only possible due to tons of incredible work by the XPwn dev team. First of all, their DMG and HFS+ code is totally portable and only depends on zlib. But also, the API is just too easy. Their project is going to catch on big, not only in jail breaking the iPhone from any platform, but in building DMGs from the commandline on OS X itself!
Since both anal_pe and XPwn are GPL, I’m afraid this extension must be GPL as well. The rest of Shoes is MIT. Which is okay I guess since the packager isn’t really needed to run Shoes apps.
This is all a bleeding fresh part of today’s builds.
As for Linux. I’m not decided as to what to do about generating Linux binaries. Either using makeself or plain shell scripting will do. But do I download binaries or automate package manager steps? The unsurety.