Generate Hydra Fastfetch emblem and verify packaged ASCII art
This commit is contained in:
+17
-5
@@ -352,14 +352,25 @@ def terminal_ux_iso():
|
||||
return bytes(data)
|
||||
|
||||
|
||||
def verify_terminal_ux_branding(output, errors):
|
||||
rendered = re.sub(r'\x1b\[[0-?]*[ -/]*[@-~]', '', output)
|
||||
def verify_terminal_ux_branding(output, errors, logo):
|
||||
ansi = r'\x1b\[[0-?]*[ -/]*[@-~]'
|
||||
rendered = re.sub(ansi, '', output)
|
||||
if errors.strip() or re.search(r'\b(error|failed|unknown module)\b', rendered, re.I):
|
||||
raise SmokeError('Installed default Fastfetch emitted errors: ' + (errors or rendered)[-1500:])
|
||||
if not re.search(r'\bOS\s*:\s*Hydra OS\b', rendered):
|
||||
raise SmokeError('Installed default Fastfetch did not render the Hydra OS pretty name')
|
||||
if 'H Y D R A O S' not in rendered or rendered.count('(o >') != 3:
|
||||
raise SmokeError('Installed default Fastfetch did not render the three-headed Hydra logo')
|
||||
expected = [line.rstrip() for line in re.sub(r'\$[1-9]|' + ansi, '', logo).splitlines()
|
||||
if line.strip()]
|
||||
caption = 'H Y D R A O S'
|
||||
if (not any(line.strip() == caption for line in expected)
|
||||
or not any(line.strip() != caption for line in expected)):
|
||||
raise SmokeError('Packaged Fastfetch logo must contain art and the Hydra OS caption')
|
||||
width = max(map(len, expected))
|
||||
lines = iter(rendered.splitlines())
|
||||
for row in expected:
|
||||
if not any(line[:width].rstrip() == row
|
||||
and (len(line) <= width or line[width].isspace()) for line in lines):
|
||||
raise SmokeError('Installed default Fastfetch did not render the complete packaged Hydra logo')
|
||||
return rendered
|
||||
|
||||
|
||||
@@ -414,7 +425,8 @@ fetch = subprocess.run(['fastfetch', '--pipe', 'false', '--show-errors'],
|
||||
capture_output=True, text=True, timeout=30)
|
||||
if fetch.returncode:
|
||||
raise SmokeError('Installed default Fastfetch failed: ' + fetch.stderr[-1500:])
|
||||
fastfetch_output = verify_terminal_ux_branding(fetch.stdout, fetch.stderr)
|
||||
fastfetch_output = verify_terminal_ux_branding(
|
||||
fetch.stdout, fetch.stderr, Path('/usr/share/hydra/fastfetch.txt').read_text())
|
||||
config_hash = hashlib.sha256(Path('/etc/fastfetch/config.jsonc').read_bytes()).hexdigest()
|
||||
logo_hash = hashlib.sha256(Path('/usr/share/hydra/fastfetch.txt').read_bytes()).hexdigest()
|
||||
base = Path(tempfile.mkdtemp(prefix='hux-', dir='/tmp'))
|
||||
|
||||
Reference in New Issue
Block a user