mesaport.Installer.extractor

 1import os
 2import shlex
 3import shutil
 4import subprocess
 5import tarfile
 6import zipfile
 7
 8from rich import console, print
 9
10def extract_mesa(directory, ostype, cleanAfter, sdk_download, mesa_zip, logfile):
11    """Extract the MESA SDK and MESA zip files.
12
13    Args:
14        sdk_download (path): Path to the downloaded MESA SDK.
15        mesa_zip (path): Path to the downloaded MESA zip file.
16        logfile (file): File to write the output logs of the installation to.
17    """        
18    if ostype == "Linux":
19        with console.Console().status("[green b]Extracting MESA Linux SDK", spinner="moon"):
20            with tarfile.open(sdk_download, 'r:gz') as tarball:
21                if os.path.exists( os.path.join(directory, 'mesasdk') ):
22                    shutil.rmtree( os.path.join(directory, 'mesasdk') )
23                tarball.extractall(directory )
24            if cleanAfter:
25                os.remove(sdk_download)
26        print("[blue b]MESA Linux SDK extraction complete.\n")
27    elif "macOS" in ostype:
28        with console.Console().status("[green b]Installing MESA SDK package for macOS", spinner="moon"):
29            subprocess.Popen(shlex.split(f"sudo installer -pkg {sdk_download} -target /"),
30                            stdout=logfile, stderr=logfile).wait()
31            if cleanAfter:
32                os.remove(sdk_download)
33        print("[blue b]MESA SDK package installation complete.\n")
34
35    with console.Console().status("[green b]Extracting MESA", spinner="moon"):
36        with zipfile.ZipFile(mesa_zip, 'r') as zip_ref:
37            zip_ref.extractall(directory)
38        if cleanAfter:
39            os.remove(mesa_zip)
40    print("[blue b]MESA extraction complete.\n")
41    
def extract_mesa(directory, ostype, cleanAfter, sdk_download, mesa_zip, logfile):
11def extract_mesa(directory, ostype, cleanAfter, sdk_download, mesa_zip, logfile):
12    """Extract the MESA SDK and MESA zip files.
13
14    Args:
15        sdk_download (path): Path to the downloaded MESA SDK.
16        mesa_zip (path): Path to the downloaded MESA zip file.
17        logfile (file): File to write the output logs of the installation to.
18    """        
19    if ostype == "Linux":
20        with console.Console().status("[green b]Extracting MESA Linux SDK", spinner="moon"):
21            with tarfile.open(sdk_download, 'r:gz') as tarball:
22                if os.path.exists( os.path.join(directory, 'mesasdk') ):
23                    shutil.rmtree( os.path.join(directory, 'mesasdk') )
24                tarball.extractall(directory )
25            if cleanAfter:
26                os.remove(sdk_download)
27        print("[blue b]MESA Linux SDK extraction complete.\n")
28    elif "macOS" in ostype:
29        with console.Console().status("[green b]Installing MESA SDK package for macOS", spinner="moon"):
30            subprocess.Popen(shlex.split(f"sudo installer -pkg {sdk_download} -target /"),
31                            stdout=logfile, stderr=logfile).wait()
32            if cleanAfter:
33                os.remove(sdk_download)
34        print("[blue b]MESA SDK package installation complete.\n")
35
36    with console.Console().status("[green b]Extracting MESA", spinner="moon"):
37        with zipfile.ZipFile(mesa_zip, 'r') as zip_ref:
38            zip_ref.extractall(directory)
39        if cleanAfter:
40            os.remove(mesa_zip)
41    print("[blue b]MESA extraction complete.\n")

Extract the MESA SDK and MESA zip files.

Arguments:
  • sdk_download (path): Path to the downloaded MESA SDK.
  • mesa_zip (path): Path to the downloaded MESA zip file.
  • logfile (file): File to write the output logs of the installation to.