Skip to content

Command line packager

Cecil edited this page Oct 31, 2015 · 5 revisions

Note: this is subject to change. - adding new options or changing the names or new yaml fields. This note is based on Shoes 3.2.23 r1980 (April 11, 2015)

Packaging from the command line

Packaging from the GUI involves lots of button clicks and testing and redoing. It's a bit of a pain if you want to automate your development. You can create a couple of small Ruby scripts that you run from the command line using the --ruby option (cshoes.exe --ruby scriptname.rb for the Windows brethren)

Shy files

You probably want to create a .shy unless your project is exactly one .rb file. A .shy is bit of magic binary numbers followed by some yaml followed by a tar ball. The yaml has fields. Here's and example of a script that creates a shy.

require 'shoes/packshoes'
shydesc = {}
shyfile = File.join("/","tmp", "shy", "ytm.shy")
shydesc['name'] = 'Yield to Maturity'
shydesc['version'] = '0.123'
shydesc['creator'] = 'the mighty OZ'
shydesc['launch'] = 'ytm.rb'
PackShoes.make_shy(shyfile, '/home/ccoupe/Projects/ytm', shydesc)

shyfile

This is the file to create. In the example, it's /tmp/shy/ytm.shy. Do not put it in the same directory or a subdirectory of that your shy-ing up. Don't do that unless you have infinite time and disk space. You don't have either.

shydesc

The name, version and creator values are pretty much ignored (that won't be true in future Shoes) so pick something that your users will understand if the see it displayed).

launch is the startup script in the directory that Shoes will run when the shy is executed on their system.

make_shy

The arguments should be apparent. The first is the absolute path of the .shy to create. The second argument is the directory/folder to package up into the .shy and the third argument is the desc hash.

Packaging

Now, I'm going to describe the script you write to drive packaging. After you created a .shy file if that's what your app needs. The 'test.rb' below just has one ruby script. Shoes only packs one file - a .rb or a .shy.

What's in the test.rb? Basically you require the packshoes.rb, fill out an platform specific opts hash and call one of the methods in PackShoes. There are many caveats, bewares and huh? . Please study lib/shoes/packshoes.rb in your Shoes.

require 'shoes/packshoes'
opts = {}
# -- windows
opts['app'] = '/home/ccoupe/Projects/dropouts/isp.rb'
opts['dnlhost'] = 'shoes.mvmanila.com'  # no http://
opts['dnlpath'] = '/public/select/win32.rb'
opts['shoesdist'] = '/home/ccoupe/.shoes/federales/package/shoes-3.2.18-gtk2-32.exe'
opts['relname'] = 'federales'
PackShoes.dnlif_exe opts
#PackShoes.repack_exe opts
#PackShoes.repack_exe opts do |msg| 
#  puts msg
#end

opts['app']

is the full pathname to the script (or .shy) to package. If you need to automate the creation of a shy you'll have to spend about 20 minutes and write that yourself - all the clues are in lib/shoes - just read what app_package does.

In the example, we're going to create a isp.exe that when the user runs it, it will download Shoes and install it (if needed) and then run isp.rb - download if needed - dnlif.

opts['dnlhost'] and opts['dnlpath']

Is where to download the Shoes distribution from. This is passed into the stub that runs on the users system dnlpath is the cgi script to run at dnlhost. That will return a full shoes.exe that will be installed if needed.

opts['shoesdist']

Is a the full path to the where Shoes previously downloaded the Shoes.exe you want to repack. In Windows, it will be in HOME\AppData\ probably AppData\shoes\federales\package but you'll want to verify that for yourself.

opts['relname']

I'm not sure if this used or not. Won't hurt to include it.

opts['winargs']

This is optional and only applies to Shoes 3.2.23 or newer and only for Windows. opts['winargs']='--console' causes the packaged app to open a command window along with the Shoes app windows. Handy if your app uses Ruby puts and/or C printfs and you want the user to see them. The console window is closed when the Shoes app is terminated.

which method in PackShoes?

dnlif_exe has already been explained. repack_exe is the choice to create an exe that has the full copy of Shoes plus your script/shy You can add a block to the repack_exe call but other than printing the progress messages it not all that useful.

What about those other opts[values]

Ah, you've been reading packshoes.rb. Good. Those are for the mythical long delayed secondary app installer which at this time is kind of working for some platforms but I'm not sure it does whats need for all platforms. You should not use them.

What about packaging for Linux and OSX ?

Use the same opts[] names above, with the appropriate values and call a different method

opts['arch'] = 'armhf' # armhf or x86_64 or i686
opts['dnlhost'] = 'walkabout.mvmanila.com'  # no http://
opts['dnlpath'] = "/public/select/#{opts['arch']}.rb"
opts['shoesdist'] = "/home/ccoupe/.shoes/federales/package/shoes-3.2.19-gtk2-#{opts['arch']}.install"
#PackShoes.dnlif_linux opts
#PackShoes.repack_linux opts do |msg|
#  puts msg
#end

Obviously, you'll want to change the version number to the current/proper shoes-3.2.xx

opts['arch'] = 'osx'
opts['dnlhost'] = 'walkabout.mvmanila.com'  # no http://
opts['dnlpath'] = "/public/select/#{opts['arch']}.rb"
opts['shoesdist'] = "/home/ccoupe/.shoes/federales/package/shoes-3.2.19-osx-10.9.tgz"
opts['packtmp'] = '/home/ccoupe/.shoes'
opts['relname'] = 'federales'
opts['shoesruby'] = 'x86_64'
#PackShoes.dnlif_osx opts
PackShoes.repack_osx opts do |msg|
  puts msg
end

Of course you have to change all those hard coded absolute paths to match what your doing.
Clone this wiki locally