File 1031-LOGDIR-is-either-var-log-or-XDG_STATE_HOME-erlang.patch of Package erlang
From d0167de322cb016aabeae9f8bcd6138181f78f25 Mon Sep 17 00:00:00 2001
From: Vance Shipley <vances@sigscale.org>
Date: Wed, 5 Nov 2025 18:21:26 +0800
Subject: [PATCH] LOGDIR is either /var/log or XDG_STATE_HOME/erlang
---
erts/etc/unix/start.src | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/erts/etc/unix/start.src b/erts/etc/unix/start.src
index 8f468f2740..050b1c2f2c 100644
--- a/erts/etc/unix/start.src
+++ b/erts/etc/unix/start.src
@@ -44,6 +44,19 @@ else
dyn_rootdir=""
fi
+if touch /var/log 2>/dev/null;
+then
+ LOGDIR="/var/log"
+else
+ if [ -z "$XDG_STATE_HOME" ];
+ then
+ LOGDIR="$HOME/.local/state/erlang"
+ else
+ LOGDIR="$XDG_STATE_HOME/erlang"
+ fi
+ mkdir -p $LOGDIR
+fi
+
if [ -z "$ERL_ROOTDIR" ]
then
ROOTDIR="%FINAL_ROOTDIR%"
@@ -63,4 +76,4 @@ fi
START_ERL_DATA=${1:-$RELDIR/start_erl.data}
-$ROOTDIR/bin/run_erl -daemon /tmp/ $ROOTDIR/log "exec $ROOTDIR/bin/start_erl $ROOTDIR $RELDIR $START_ERL_DATA"
+$ROOTDIR/bin/run_erl -daemon /tmp/ $LOGDIR "exec $ROOTDIR/bin/start_erl $ROOTDIR $RELDIR $START_ERL_DATA"
--
2.51.0