class Netfira::InstallerGenerator
noinspection SpellCheckingInspection
Constants
- GEM_ROOT
- REQUIRED_VALUES
- VERSION
Attributes
auth_server[RW]
icon[R]
Because the writers are created en masse: noinspection RubyResolve
installer_filename[RW]
installer_name[RW]
output_device[RW]
shop_id[RW]
shop_url[RW]
signing_cert[R]
Because the writers are created en masse: noinspection RubyResolve
signing_description[RW]
signing_key[R]
Because the writers are created en masse: noinspection RubyResolve
signing_url[RW]
source[R]
Because the writers are created en masse: noinspection RubyResolve
sync_url[RW]
target[RW]
temp_dir[RW]
use_ssl[RW]
Public Class Methods
new()
click to toggle source
# File lib/netfira/installer_generator.rb, line 34 def initialize self.output_device = :null self.use_ssl = true self.installer_name = 'Netfira Installer' self.installer_filename = 'netfira_dlm.exe' self.temp_dir = 'netfireb' self.auth_server = 'auth.netfira.biz' end
preflight!()
click to toggle source
# File lib/netfira/installer_generator.rb, line 17 def self.preflight! [Binary::Makensis, Binary::Signcode].each do |klass| raise "No binaries available from [ #{klass.bin_files.join ' | '} ]" unless klass.available? end end
Public Instance Methods
generate!()
click to toggle source
# File lib/netfira/installer_generator.rb, line 55 def generate! # Ensure we have all our binary friends self.class.preflight! # Ensure we have no missing required values require_values! REQUIRED_VALUES # Make a temporary build dir build_dir = Pathname(Dir.tmpdir) + SecureRandom.uuid mkdir build_dir begin # Copy the source exe and icon to the build dir cp icon, build_dir + 'setup.ico' cp source, build_dir + installer_filename # Write the NSIS script to the build dir File.write build_dir + 'nsis_script.nsi', render_nsis_template # Run makensis makensis build_dir or raise Exception, 'makensis failed' output_path = build_dir + 'nsis_generated.exe' # Run signcode if signing_key || signing_cert require_values! %i[signing_key signing_cert] input_path = output_path output_path = build_dir + 'signed.exe' signcode input_path, output_path or raise Exception, 'signcode failed' end # Write target file mkdir_p File.dirname(target) mv output_path, target ensure rm_rf build_dir end end
Private Instance Methods
makensis(build_dir)
click to toggle source
# File lib/netfira/installer_generator.rb, line 121 def makensis(build_dir) b = Binary::Makensis.new b.template_file_name = 'nsis_script.nsi' b.build_dir = build_dir b.run output_device end
render_nsis_template()
click to toggle source
# File lib/netfira/installer_generator.rb, line 105 def render_nsis_template # noinspection RubyStringKeysInHashInspection,SpellCheckingInspection values = { 'INSTALLER_NAME' => installer_name, 'TEMP_DIR' => temp_dir, 'INSTALLER_FILENAME' => installer_filename, 'SHOP_ID' => shop_id, 'AUTHENTICATION_SERVER' => auth_server, 'WEBSTORE_SYNC_URL' => sync_url, 'WEBSTORE_FRONT_URL' => shop_url, 'SHOP_ADDRESS' => URI.parse(sync_url).host, 'NO_USE_SSL' => use_ssl ? '0' : '1' } NsisTemplate.sub values end
require_values!(keys)
click to toggle source
# File lib/netfira/installer_generator.rb, line 100 def require_values!(keys) missing = keys.select { |key| send(key).nil? } raise Exception, "Missing value(s) for #{missing.join ', '}" unless missing.empty? end
signcode(source, target)
click to toggle source
# File lib/netfira/installer_generator.rb, line 128 def signcode(source, target) b = Binary::Signcode.new b.spc_path = signing_cert b.key_path = signing_key b.url = signing_url || shop_url b.description = signing_description || installer_name b.source_path = source b.target_path = target b.run output_device end