def build_bare_dmg()

in legacy/autodmg_cache_builder/autodmg_org.py [0:0]


def build_bare_dmg(source, cache, logpath, loglevel, repo_path):
  """Build a bare OS DMG for Donation/bare usage."""
  dmg_output_path = os.path.join(cache, 'Bare.hfs.dmg')
  if os.path.isfile(dmg_output_path):
    print "Donation image already found, not building.\n"
    return
  print "Creating AutoDMG-donation.adtmpl."
  templatepath = os.path.join(cache, 'AutoDMG-bare.adtmpl')

  plist = dict()
  plist["ApplyUpdates"] = True
  plist["SourcePath"] = source
  plist["TemplateFormat"] = "1.0"
  plist["VolumeName"] = "Macintosh HD"

  # Complete the AutoDMG-donation.adtmpl template
  plistlib.writePlist(plist, templatepath)
  autodmg_cmd = [
    '/Applications/AutoDMG.app/Contents/MacOS/AutoDMG'
  ]
  if os.getuid() == 0:
    # We are running as root
    print "Running as root."
    autodmg_cmd.append('--root')

  logfile = os.path.join(logpath, 'bare.log')

  # Now kick off the AutoDMG build
  print "Building bare image..."
  if os.path.isfile(dmg_output_path):
    os.remove(dmg_output_path)
  cmd = autodmg_cmd + [
    '-L', loglevel,
    '-l', logfile,
    'build', templatepath,
    '--download-updates',
    '-o', dmg_output_path]
  run(cmd)
  print "Moving bare image to DS Repo."
  populate_ds_repo(dmg_output_path, repo_path)