Class: Wrapp::DMGBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/wrapp/dmg_builder.rb

Constant Summary collapse

BIG_SOURCE_FOLDER_SIZE =
100

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_path, opts = {}) ⇒ DMGBuilder

Returns a new instance of DMGBuilder.



9
10
11
12
# File 'lib/wrapp/dmg_builder.rb', line 9

def initialize(app_path, opts = {})
  @app_path = app_path
  @opts = opts
end

Instance Attribute Details

#app_pathObject (readonly)

Returns the value of attribute app_path.



7
8
9
# File 'lib/wrapp/dmg_builder.rb', line 7

def app_path
  @app_path
end

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/wrapp/dmg_builder.rb', line 14

def create
  Dir.mktmpdir('wrapp_dmg') { |dir|
    FileUtils.cp_r(source_path, dir)

    if @opts[:add_applications_link]
      File.symlink('/Applications', File.join(dir, 'Applications'))
    end

    cmd = %w(hdiutil create)
    cmd << "-srcfolder '#{dir}'"
    # NOTE: There is a known bug in hdiutil that causes the image creation
    # to fail, see: https://discussions.apple.com/thread/5667409
    # Therefore we have to explicitely set the dmg size for bigger sources.
    cmd << "-megabytes #{dmg_size}" if big_source_folder?
    cmd << "'#{dmg_filename}'"
    system(cmd.join(' '))
  }
end