pmb.helpers.frontend: Print paths as a shell-friendly string (MR 2337)

Instead of

    [PosixPath('/home/newbyte/.local/var/pmbootstrap/cache_git/pmaports')]

you get

    /home/neboula/.local/var/pmbootstrap/cache_git/pmaports

like before.

Fixes envkernel.sh failing during activation.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2378
This commit is contained in:
Newbyte 2024-06-24 21:12:31 +02:00
parent d50ce1c59b
commit 8c0bc2e0e8
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -7,6 +7,7 @@ from pmb.helpers import logging
import os import os
from pathlib import Path from pathlib import Path
import sys import sys
from typing import Any
import pmb.aportgen import pmb.aportgen
import pmb.build import pmb.build
@ -248,7 +249,21 @@ def config(args: PmbArgs):
value = getattr(config, args.name) value = getattr(config, args.name)
else: else:
value = "" value = ""
print(value)
def to_shell_friendly_representation(value: Any) -> str:
friendly_representation: str
if isinstance(value, list) and len(value) == 1:
value = value[0]
if isinstance(value, Path):
friendly_representation = value.as_posix()
else:
friendly_representation = str(value)
return friendly_representation
print(to_shell_friendly_representation(value))
else: else:
# Serialize the entire config including default values for # Serialize the entire config including default values for
# the user. Even though the defaults aren't actually written # the user. Even though the defaults aren't actually written