git: ce4c8c49210b - main - sysutils/py-salt: fix commands like "service salt_minion status"

From: Alan Somers <asomers_at_FreeBSD.org>
Date: Thu, 27 Feb 2025 21:14:36 UTC
The branch main has been updated by asomers:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ce4c8c49210b7a646d63b3956ee5e71b74dbf902

commit ce4c8c49210b7a646d63b3956ee5e71b74dbf902
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2025-02-27 17:40:20 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2025-02-27 21:04:59 +0000

    sysutils/py-salt: fix commands like "service salt_minion status"
    
    When py-processtitle is installed, the master and minion daemons will
    change their process titles in a way that breaks commands like "service
    salt_minion status".  status, stop, restart, etc are all broken.  Fix
    this bug by:
    
    * Always installing py-processtitle unconditionally,
    * Fixing utils/process.py to not insert an extra space in the title
    * Adjusting the RC scripts accordingly
    
    A downside is that many service subcommands will now print this harmless
    warning message:
    ```
    /usr/local/etc/rc.d/salt_minion: WARNING: cannot read shebang line from
    MultiMinionProcessManager
    ```
    
    Approved by:    krion (maintainer)
    Sponsored by:   ConnectWise
    PR:             285053
---
 sysutils/py-salt/Makefile                          |  2 +-
 sysutils/py-salt/files/patch-salt_utils_process.py | 14 ++++++++++++++
 sysutils/py-salt/files/salt_master.in              |  1 +
 sysutils/py-salt/files/salt_minion.in              |  1 +
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/sysutils/py-salt/Makefile b/sysutils/py-salt/Makefile
index 16c3913c606b..4dc82ac149a1 100644
--- a/sysutils/py-salt/Makefile
+++ b/sysutils/py-salt/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	salt
 PORTVERSION=	3006.9
-PORTREVISION=	3
+PORTREVISION=	4
 PORTEPOCH=	1
 CATEGORIES=	sysutils python
 MASTER_SITES=	PYPI
diff --git a/sysutils/py-salt/files/patch-salt_utils_process.py b/sysutils/py-salt/files/patch-salt_utils_process.py
new file mode 100644
index 000000000000..b12e5996c9a3
--- /dev/null
+++ b/sysutils/py-salt/files/patch-salt_utils_process.py
@@ -0,0 +1,14 @@
+--- salt/utils/process.py.orig	2024-07-29 07:51:58 UTC
++++ salt/utils/process.py
+@@ -59,7 +59,10 @@ def appendproctitle(name):
+         current = setproctitle.getproctitle()
+         if current.strip().endswith("MainProcess"):
+             current, _ = current.rsplit("MainProcess", 1)
+-        setproctitle.setproctitle(f"{current.rstrip()} {name}")
++        if len(current) > 0:
++            setproctitle.setproctitle(f"{current.rstrip()} {name}")
++        else:
++            setproctitle.setproctitle(name)
+
+
+ def daemonize(redirect_out=True):
diff --git a/sysutils/py-salt/files/salt_master.in b/sysutils/py-salt/files/salt_master.in
index 249c1d735e41..d8691747e322 100644
--- a/sysutils/py-salt/files/salt_master.in
+++ b/sysutils/py-salt/files/salt_master.in
@@ -34,6 +34,7 @@ command_interpreter="%%PYTHON_CMD%%"
 required_files=${salt_master_configdir}
 pidfile=${salt_master_pidfile}
 command_args="-c ${required_files} --pid-file=${pidfile} -d"
+procname="MainProcess"
 
 export PATH="${salt_master_paths}"
 export PYTHON_EGG_CACHE="${salt_master_eggcache}"
diff --git a/sysutils/py-salt/files/salt_minion.in b/sysutils/py-salt/files/salt_minion.in
index ff0a70f4c812..d7a125daad9d 100644
--- a/sysutils/py-salt/files/salt_minion.in
+++ b/sysutils/py-salt/files/salt_minion.in
@@ -34,6 +34,7 @@ command_interpreter="%%PYTHON_CMD%%"
 required_files=${salt_minion_configdir}
 pidfile=${salt_minion_pidfile}
 command_args="-c ${required_files} --pid-file=${pidfile} -d"
+procname="MultiMinionProcessManager"
 
 export PATH="${salt_minion_paths}"
 export PYTHON_EGG_CACHE="${salt_minion_eggcache}"