<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract_dmg(self, path='.'):
 """ Extract builds with .dmg extension Will only work if `hdiutil` is available. @type path: @param path: """

        dmg_fd, dmg_fn = tempfile.mkstemp(prefix='fuzzfetch-', suffix='.dmg')
        os.close(dmg_fd)
        out_tmp = tempfile.mkdtemp(prefix='fuzzfetch-', suffix='.tmp')
        try:
            _download_url(self.artifact_url('dmg'), dmg_fn)
            if std_platform.system() == 'Darwin':
                LOG.info('.. extracting')
                subprocess.check_call(['hdiutil', 'attach', '-quiet', '-mountpoint', out_tmp, dmg_fn])
                try:
                    apps = [mt for mt in os.listdir(out_tmp) if mt.endswith('app')]
                    assert len(apps) == 1
                    shutil.copytree(os.path.join(out_tmp, apps[0]), os.path.join(path, apps[0]), symlinks=True)
                finally:
                    subprocess.check_call(['hdiutil', 'detach', '-quiet', out_tmp])
            else:
                LOG.warning('.. can\'t extract target.dmg on %s', std_platform.system())
                shutil.copy(dmg_fn, os.path.join(path, 'target.dmg'))
        finally:
            shutil.rmtree(out_tmp, onerror=onerror)
            os.unlink(dmg_fn)