# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import os import platform import shutil import subprocess import tempfile from pathlib import Path
from mozperftest.layers import Layer
# Add here any option that might point to a DMG file we want to extract. The key # is name of the option and the value, the file in the DMG we want to use for # the option.
POTENTIAL_DMGS = { "browsertime-binary": "Contents/MacOS/firefox", "xpcshell-xre-path": "Contents/MacOS", "mochitest-binary": "Contents/MacOS/firefox",
}
class MacosDevice(Layer): """Runs on macOS to mount DMGs if we see one."""
name = "macos"
activated = platform.system() == "Darwin"
# mounting the DMG with hdiutil
cmd = f"hdiutil attach -nobrowse -mountpoint {str(mount)} {dmg}" try:
self._run_process(cmd.split()) except subprocess.CalledProcessError:
self.error(f"Can't mount {dmg}") if mount.exists():
shutil.rmtree(str(mount)) raise
# browse the mounted volume, to look for the app.
found = False try: for f in os.listdir(str(mount)): ifnot f.endswith(".app"): continue
app = mount / f
shutil.copytree(str(app), str(target))
found = True break finally: try:
self._run_process(f"hdiutil detach {str(mount)}".split()) except subprocess.CalledProcessError as e: # noqa
self.warning("Detach failed {e.stdout}") finally: if mount.exists():
shutil.rmtree(str(mount)) ifnot found:
self.error(f"No app file found in {dmg}") raise IOError(dmg)
def run(self, metadata): # Each DMG is mounted, then we look for the .app # directory in it, which is copied in a directory # alongside the .dmg file. That directory # is removed during teardown. for option, path_in_dmg in POTENTIAL_DMGS.items():
value = self.get_arg(option)
if value isNoneornot value.endswith(".dmg"): continue
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.