code: def build_dmg(sudo):
      print("Building disk image...")
      # Since we removed the dist directory at the start of the script,
      # our pkg should be the only file there.
      pkg = os.listdir(DIST_DIR)[0]
      fn, ext = os.path.splitext(pkg)
      dmg = fn + ".dmg"
      srcfolder = os.path.join(DIST_DIR, pkg)
      dstfolder = os.path.join(DIST_DMG_DIR, dmg)
      # build disk image
      try:
          os.mkdir(DIST_DMG_DIR)
      except OSError:
          pass
      try:
          os.unlink(dstfolder)
      except OSError:
          pass
      cmd = f"hdiutil create -srcfolder {srcfolder} {dstfolder}"
      if sudo:
          cmd = f"sudo {cmd}"
      shellcmd(cmd)
  
file_path: dipy/tools/osxbuild.py
imports: import os
  import sys
  import shutil
  import subprocess
  from optparse import OptionParser
  from getpass import getuser
label_desc: Use image node_id 3 for calling a global function with example usage: build_dmg(sudo) without return types