Skip to content

Merge Packaging on Windows

Cecil edited this page Jun 3, 2018 · 1 revision

Merge Packaging

This is the way to build and package an application that hides Shoes-ness as much as possible. It's called Merge because it copies your app and files into a copy of Shoes and arranges to your app to start instead of shoes.rb (the splash screen). Then we create an installer for that combination.

The result is an application that doesn't depend of Shoes being installed somewhere. The app is installed in system locations like Program Files (x86) or /usr/local/bin

For Windows, the result will install in Windows 10. That's HUUGE!

There is a downside to all this goodness. You will have to do some more work and more importantly you can't package across platforms with merge packaging. If you want to make and exe, the merge packaging has to be done on a Windows system running Shoes. If you want to make a Debian .deb, you need to do that on a Linux system running Shoes

Command Line or GUI?

You can do both. There is a GUI wizard to help you define your app and build a configuration file. That configuration file can be used by the GUI to create the installer. Or, if you like scripting your builds, you can pass the configuration file to a tiny Ruby command line program that you create.

You can find Merge Packaging as a menu option in Cobbler. That launches the GUI. It is recommended you use the GUI to build the configuration file.

Windows GUI

Did I mention this result will install on Window 10?

This scheme requires two additional programs be installed. ResourceHacker and NSIS Unicode. The Cobbler screen will help you download and install them but you do have to tell Cobbler where you installed them and you should save that so you don't have to do it over and over.

merge-windows

NSIS creates the installer and if you don't customize it the installer is going to look a lot like Shoes and not like your application. Sadly NSIS has funny rules about Image formats. They have two old-time .bmp images (bmp-1) and you really want the sizes to match what is expected (or very, very close). You should have a couple of icons. One for the application that you store in your app folder and that you tell Shoes code to use app.set_window_icon_path. You also need an Icon for the installer created exe. They can be different files and probably should be. In the screen shots below the app is just one file 'isp.rb' in the dropouts folder.

win-wizard1

win-wizard2

win-wizard3

I chose to save the configuration is an isp.yaml file.

Windows command line

You need to create a short ruby script and we want the yaml file we created from the Wizard. Cd to where you saved the yaml file and create win-merge.rb file. Then we use command line Shoes to the merge with `cshoes.exe --ruby cmd-merge isp.yaml

Here is win-merge.rb.

# run this with cshoes.exe --ruby win-merge.rb file.yaml
require 'fileutils'
include FileUtils
require 'yaml'
opts = YAML.load_file(ARGV[0])
opts['packdir'] = Dir.getwd
home = ENV['HOME']
#appdata = ENV['APPDATALOCAL']
appdata = "#{home}\\APPDATA\\Local" if !appdata
appdata = appdata.tr("\\",'/')
util = YAML.load_file("#{appdata}/shoes/package/util.yaml")
opts['RESH'] = util['rhp']
opts['NSIS'] = util['nsp']
GEMS_DIR = File.join(appdata, '.shoes','+gem')
puts "DIR = #{DIR}"
puts "GEMS_DIR = #{GEMS_DIR}"
require "package/merge-exe"
PackShoes::merge_exe(opts) {|t| $stderr.puts t}

The only trick here is that it knows where cobbler downloaded and installed ResourceHacker and NSIS. If you didn't do that then set the opts[] to point to where you did install them

Clone this wiki locally