Bug 279251 - games/minetest: Fix rc(8) script when using minetest_flags
Summary: games/minetest: Fix rc(8) script when using minetest_flags
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dmitry Marakasov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-23 13:34 UTC by Jesús Daniel Colmenares Oviedo
Modified: 2024-05-27 16:41 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (amdmi3)


Attachments
minetest.in.patch (1.71 KB, patch)
2024-05-23 13:34 UTC, Jesús Daniel Colmenares Oviedo
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesús Daniel Colmenares Oviedo 2024-05-23 13:34:22 UTC
Created attachment 250900 [details]
minetest.in.patch

Description:

After installing `games/minetest_game` and enabling the `rc(8)` script, it fails because I need to set the `--gameid` parameter. I set `minetest_flags`, which is theoretically the parameter that fixes the problem, but of course since `command` is set to `/usr/sbin/daemon`, those arguments are passed to `daemon(8)` instead of `minetest(6)`.

To fix this problem we need to change minetest_flags to minetest_cli_args after applying this patch.

Steps to reproduce this issue:

```
# service minetest oneenable
minetest enabled in /etc/rc.conf
# service minetest start
Starting minetest.
# service minetest status
minetest is not running.
# tail /var/log/minetest/debug.log
  
  
-------------
  Separator
-------------

2024-05-23 09:20:05: ERROR[Main]: To run a Minetest server, you need to select a game using the '--gameid' argument.
2024-05-23 09:20:05: ERROR[Main]: Check out https://content.minetest.net for a selection of games to pick from and download.
2024-05-23 09:20:05: ERROR[Main]: ServerError: Supplied invalid gamespec
# sysrc minetest_flags="--gameid minetest_game"
minetest_flags:  -> --gameid minetest_game
# service minetest start
Starting minetest.
daemon: unrecognized option `--gameid'
usage: daemon [-cfHrS] [-p child_pidfile] [-P supervisor_pidfile]
              [-u user] [-o output_file] [-t title]
              [-l syslog_facility] [-s syslog_priority]
              [-T syslog_tag] [-m output_mask] [-R restart_delay_secs]
command arguments ...
  --change-dir         -c         Change the current working directory to root
  --close-fds          -f         Set stdin, stdout, stderr to /dev/null
  --sighup             -H         Close and re-open output file on SIGHUP
  --syslog             -S         Send output to syslog
  --output-file        -o <file>  Append output of the child process to file
  --output-mask        -m <mask>  What to send to syslog/file
                                  1=stdout, 2=stderr, 3=both
  --child-pidfile      -p <file>  Write PID of the child process to file
  --supervisor-pidfile -P <file>  Write PID of the supervisor process to file
  --restart            -r         Restart child if it terminates (1 sec delay)
  --restart-delay      -R <N>     Restart child if it terminates after N sec
  --title              -t <title> Set the title of the supervisor process
  --user               -u <user>  Drop privileges, run as given user
  --syslog-priority    -s <prio>  Set syslog priority
  --syslog-facility    -l <flty>  Set syslog facility
  --syslog-tag         -T <tag>   Set syslog tag
  --help               -h         Show this help
/usr/local/etc/rc.d/minetest: WARNING: failed to start minetest
```

After applying this patch:

```
# service minetest oneenable
minetest enabled in /etc/rc.conf
# sysrc minetest_cli_args="--gameid minetest_game"
minetest_cli_args:  -> --gameid minetest_game
# service minetest start
Starting minetest.
# service minetest status
minetest is running as pid 57541.
# tail /var/log/minetest/debug.log 


-------------
  Separator
-------------

2024-05-23 09:31:43: [Main]: Using game specified by --gameid on the command line
2024-05-23 09:31:43: ACTION[Main]: World at [/var/db/minetest/world]
2024-05-23 09:31:43: ACTION[Main]: Server for gameid="minetest_game" listening on 0.0.0.0:30000.
```
Comment 1 Jesús Daniel Colmenares Oviedo 2024-05-23 13:37:09 UTC
Also, I see that `minetest_conffile` is not actually used but `minetest_config` is, so I made the changes accordingly.
Comment 2 Dmitry Marakasov freebsd_committer freebsd_triage 2024-05-24 20:09:41 UTC
What do you think of instead:
- Introducing `minetest_gameid` variable set to `minetest_game` by default, to make it work sort of out of box without rc.conf tuning, and more easily configurable if one only needs to change gameid.
- Moving all arguments (`--config`, `--logfile`, `--world`, `--gameid`) to `command_args`, making them unconditionally specified. This leaves `minetest_args` empty by default and simplifies adding extra args if needed, without need to duplicate bits from default args. It's still also possible to override any of default args through `minetest_args`.
Comment 3 Dmitry Marakasov freebsd_committer freebsd_triage 2024-05-24 20:53:13 UTC
See my patch: https://github.com/AMDmi3/freebsd-ports/compare/master...minetest

This also fixes minetest_game when minetest is built without client.
Comment 4 Jesús Daniel Colmenares Oviedo 2024-05-25 05:18:44 UTC
LGTM

Just a small change:

```
# minetest_args (str):     Additional argiments to minetestserver
#                          (default: "")
```

`argiments` should be `arguments`.

Thanks!
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-05-27 16:37:31 UTC
A commit in branch main references this bug:

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

commit f5c99763242c21f3ce4072ba5518d66b5174e84a
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2024-05-24 20:42:37 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2024-05-27 16:25:24 +0000

    games/minetest: fix rc.d script

    - Introduce `minetest_gameid` rc.d variable (set to minetest_game
      by default), which passes required --gameid to minetestserver.
    - Rework minetestserver arguments handling, simplify specifying extra
      arguments with `minetest_args`.
    - Add check for empty list of games, suggesting to install minetest_game
      port or other mods.
    - Fix `minetest_config` variable spelling

    PR:             279251
    Submitted by:   DtxdF@disroot.org

 games/minetest/Makefile          |  1 +
 games/minetest/files/minetest.in | 28 ++++++++++++----------------
 2 files changed, 13 insertions(+), 16 deletions(-)