mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-27 19:54:38 +00:00
fix(nix): address review feedback on setup and runtime safety
This commit is contained in:
1 parent
573f290552
commit
33581fb216
6 files changed
+26
-10
No files matched your search
@@ -8,7 +8,8 @@ if [ -n "${DARLING_WORKSPACE:-}" ] && ! python3 scripts/nix-state.py check; then
|
||||
fi
|
||||
export PATH="${DARLING_RUNNER_DIR:+$DARLING_RUNNER_DIR:}$repo/usr-local/bin:/usr/local/bin:$PATH"
|
||||
region=${1:-euw}
|
||||
case "$region" in euw|eune|na|br|kr|jp|lan|las|oce|ru|tr) ;; *) echo 'Use a Riot installer region code' >&2; exit 1;; esac
|
||||
case "$region" in lan) region=la1;; las) region=la2;; oce) region=oc1;; esac
|
||||
case "$region" in euw|eune|na|br|kr|jp|la1|la2|oc1|ru|tr) ;; *) echo 'Use a Riot installer region code' >&2; exit 1;; esac
|
||||
python3 scripts/configure.py >/dev/null
|
||||
bash build/runtime/tools/fetch-installer.sh "$region" build/installer
|
||||
unzip -q -o "build/installer/live.$region.zip" -d build/installer
|
||||
|
||||
@@ -13,6 +13,14 @@ import sys
|
||||
import time
|
||||
|
||||
|
||||
def warn(message):
|
||||
"""Diagnostics must not discard the namespace after a terminal hangup."""
|
||||
try:
|
||||
print(message, file=sys.stderr, flush=True)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
scripts = Path(__file__).resolve().parent
|
||||
spec = importlib.util.spec_from_file_location('nix_idle', scripts / 'nix-idle.py')
|
||||
@@ -42,7 +50,7 @@ def main():
|
||||
if result < 0:
|
||||
result = 128 - result
|
||||
except OSError as error:
|
||||
print(f'Cannot start client: {error}', file=sys.stderr)
|
||||
warn(f'Cannot start client: {error}')
|
||||
finally:
|
||||
# A launcher can return while guest clients remain. Do not tear down
|
||||
# their server, or discard the only namespace capable of shutting it down.
|
||||
@@ -54,21 +62,21 @@ def main():
|
||||
last_error = None
|
||||
except (OSError, RuntimeError) as error:
|
||||
if str(error) != last_error:
|
||||
print(f'{error}; retaining original namespace and retrying. '
|
||||
'Exit clients to allow safe shutdown.', file=sys.stderr)
|
||||
warn(f'{error}; retaining original namespace and retrying. '
|
||||
'Exit clients to allow safe shutdown.')
|
||||
last_error = str(error)
|
||||
time.sleep(1)
|
||||
while True:
|
||||
try:
|
||||
shutdown = subprocess.run(['bash', str(scripts / 'darling-rootless.sh'), 'shutdown']).returncode
|
||||
except OSError as error:
|
||||
print(f'Cannot run namespace-local shutdown: {error}', file=sys.stderr)
|
||||
warn(f'Cannot run namespace-local shutdown: {error}')
|
||||
shutdown = 1
|
||||
if not shutdown:
|
||||
break
|
||||
print(f'Darling namespace-local shutdown failed (status {shutdown}); '
|
||||
'retaining the original namespace and retrying in 5 seconds. '
|
||||
'Keep this terminal open.', file=sys.stderr)
|
||||
warn(f'Darling namespace-local shutdown failed (status {shutdown}); '
|
||||
'retaining the original namespace and retrying in 5 seconds. '
|
||||
'Keep this terminal open.')
|
||||
time.sleep(5)
|
||||
result = interrupted or result
|
||||
return result
|
||||
|
||||
@@ -71,10 +71,12 @@ def inventory(root):
|
||||
|
||||
for directory, dirs, files in os.walk(root, followlinks=False,
|
||||
onerror=enumeration_error):
|
||||
excluded = ('.before-', '.rt-', '.llvm')
|
||||
dirs[:] = sorted(name for name in dirs if not any(token in name for token in excluded))
|
||||
for name in sorted(dirs + files):
|
||||
path = Path(directory) / name
|
||||
if any(token in path.name for token in ('.before-', '.rt-', '.llvm')):
|
||||
if any(token in name for token in excluded):
|
||||
continue
|
||||
path = Path(directory) / name
|
||||
info = path.lstat()
|
||||
target_str = ''
|
||||
if path.is_symlink():
|
||||
|
||||
Reference in new issue
Block a user