Class: Tebako::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/tebako/cli.rb

Overview

Tebako packager front-end

Constant Summary collapse

CWD_DESCRIPTION =
<<~DESC
  Current working directory for packaged application. This directory shall be specified relative to root.
  #{" " * 65}# If this parameter is not set, the application will start in the current directory of the host file system.
DESC
REF_DESCRIPTION =
<<~DESC
  "Referenced tebako run-time package; 'tebako-runtime' by default".
  #{" " * 65}# This option specifies the tebako runtime to be used by the application on Windows and if mode is 'application' only .
DESC
RGP_DESCRIPTION =
<<~DESC
  Current working directory for packaged application. This directory shall be specified relative to root.
  #{" " * 65}# If this parameter is not set, the application will start in the current directory of the host file system.
DESC
RUNTIME_DESCRIPTION =
<<~DESC
  Runtime provenance: 'prebuilt' resolves/downloads a prebuilt tebako runtime package (default for the
  #{" " * 65}# 'bundle', 'classic', 'lean' and 'fat' modes); 'source' keeps the Stage-2 source build
  #{" " * 65}# (not available for 'lean'/'fat' -- the bootstrap resolves tebako-runtime-ruby releases
  #{" " * 65}# at run time). Modes other than those always build from source.
DESC
IMAGE_DESCRIPTION =
<<~DESC
  Additional image to stitch into the package, '<path>:<mount-point>'; repeatable, mount points
  #{" " * 65}# must be distinct. Prebuilt runtime only.
DESC
MODE_DESCRIPTION =
<<~DESC
  Tebako press mode, 'lean' by default.
  #{" " * 65}# 'lean' presses a three-part package (tebako-bootstrap + application image(s) + tpkg trailer);
  #{" " * 65}# the runtime is resolved into the shared cache at first run.
  #{" " * 65}# 'fat' is 'lean' plus the runtime package as a payload slot -- the first run installs it
  #{" " * 65}# into the cache without network access.
  #{" " * 65}# 'classic' stitches the application image onto a prebuilt runtime (Stage-3A layout);
  #{" " * 65}# 'bundle', 'both', 'application' and 'runtime' keep their legacy behaviors.
DESC

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/tebako/cli.rb', line 245

def self.exit_on_failure?
  true
end

Instance Method Details

#cleanObject



131
132
133
134
135
# File 'lib/tebako/cli.rb', line 131

def clean
  (om, cm) = bootstrap(clean: true)
  cm.clean_cache
  extra_win_clean([om.deps])
end

#clean_rubyObject



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/tebako/cli.rb', line 141

def clean_ruby
  puts "Cleaning Ruby sources from tebako packaging environment"
  (om,) = bootstrap(clean: true)

  suffix = options["Ruby"].nil? ? "" : "_#{options["Ruby"]}"
  nmr = Dir.glob(File.join(om.deps, "src", "_ruby#{suffix}*"))
  nms = Dir.glob(File.join(om.deps, "stash#{suffix}*"))

  FileUtils.rm_rf(nmr + nms, secure: true)
  extra_win_clean(nmr)
end

#hashObject



154
155
156
# File 'lib/tebako/cli.rb', line 154

def hash
  print Digest::SHA256.hexdigest [File.read(File.join(source, "CMakeLists.txt")), Tebako::VERSION].join
end

#pressObject



220
221
222
223
224
225
226
227
228
229
# File 'lib/tebako/cli.rb', line 220

def press
  validate_press_options
  (om, cm) = bootstrap

  do_press(om)
  cm.ensure_version_file
rescue Tebako::Error => e
  puts "Tebako script failed: #{e.message} [#{e.error_code}]"
  exit e.error_code
end

#setupObject



235
236
237
238
239
240
241
242
243
# File 'lib/tebako/cli.rb', line 235

def setup
  (om, cm) = bootstrap

  do_setup(om)
  cm.ensure_version_file
rescue Tebako::Error => e
  puts "Tebako script failed: #{e.message} [#{e.error_code}]"
  exit e.error_code
end