games-roguelike/nethack: add 5.0.0

Signed-off-by: Stefan Strogin <steils@gentoo.org>
This commit is contained in:
Stefan Strogin
2026-05-05 07:36:52 +03:00
parent 9a4e3cfb6f
commit dfaa7bd5f7
9 changed files with 501 additions and 0 deletions
+1
View File
@@ -1 +1,2 @@
DIST nethack-3.6.7.tar.gz 5577415 BLAKE2B a03cfe973b0470efe052eee49c312818755e33cf5148a2c39beecf052e44dfe951c6c63a3ff58ce826fa656647ad5bbe558b4854a50fcf987d80014ef4707505 SHA512 7890d17e087f4344d30e9a908fa1f24d7c72bc714c4a6415ed59800902cc0aa6b3ce94c5d73857b0222349b96b1fdc8bf3f93b3ac1153477ad1419af7b0d3fb5 DIST nethack-3.6.7.tar.gz 5577415 BLAKE2B a03cfe973b0470efe052eee49c312818755e33cf5148a2c39beecf052e44dfe951c6c63a3ff58ce826fa656647ad5bbe558b4854a50fcf987d80014ef4707505 SHA512 7890d17e087f4344d30e9a908fa1f24d7c72bc714c4a6415ed59800902cc0aa6b3ce94c5d73857b0222349b96b1fdc8bf3f93b3ac1153477ad1419af7b0d3fb5
DIST nethack-5.0.0.tar.gz 10793920 BLAKE2B c964b030c0b9a94696f1eaaaf7ff4f1d4b76ba76b327eaef69665ebfe1d5d3d43fe9510ffe9bc0ad3f30869deb386beea6e05d52e36f11fb2476801331a99b95 SHA512 a668525d9030055a4b7a504ff6a6b028d4a6d6db5b79a1f1e716d60d40346c0e6d4ac281f393a6ae8aa0453103850bafc67882a75f0518fecc6225af5efda1db
@@ -0,0 +1,22 @@
#-PRE
LINK=$(CXX)
QTn_H =
VARDATND = nhtiles.bmp rip.xpm nhsplash.xpm
WINSRC = $(WINTTYSRC) $(WINQTSRC)
WINOBJ = $(WINTTYOBJ) $(WINQTOBJ) $(TARGETPFX)tile.o
WINLIB = $(WINTTYLIB) $(QTLIBS)
GAMEPERM = 02755
VARDIRPERM = 0770
VARFILEPERM = 0660
CHOWN = true
CHGRP = true
#-POST
# needed for external pager, bug #57410
DATNODLB = $(VARDATND) license symbols $(DATHELP)
@@ -0,0 +1,24 @@
#-PRE
LINK=$(CXX)
QTn_H =
VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm nhtiles.bmp rip.xpm nhsplash.xpm
WINSRC = $(WINTTYSRC) $(WINX11SRC) $(WINQTSRC)
WINOBJ = $(WINTTYOBJ) $(WINX11OBJ) $(WINQTOBJ) $(TARGETPFX)tile.o
WINLIB = $(WINTTYLIB) $(WINX11LIB) $(QTLIBS)
GAMEPERM = 02755
VARDIRPERM = 0770
VARFILEPERM = 0660
CHOWN = true
CHGRP = true
#-POST
# needed for external pager, bug #57410
DATNODLB = $(VARDATND) license symbols $(DATHELP)
WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11 -lXpm
@@ -0,0 +1,23 @@
#-PRE
LINK=$(CC)
VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm rip.xpm
WINSRC = $(WINTTYSRC) $(WINX11SRC)
WINOBJ = $(WINTTYOBJ) $(WINX11OBJ) $(TARGETPFX)tile.o
WINLIB = $(WINTTYLIB) $(WINX11LIB)
GAMEPERM = 02755
VARDIRPERM = 0770
VARFILEPERM = 0660
CHOWN = true
CHGRP = true
#-POST
# needed for external pager, bug #57410
DATNODLB = $(VARDATND) license symbols $(DATHELP)
WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11 -lXpm
@@ -0,0 +1,13 @@
diff --git a/win/tty/termcap.c b/win/tty/termcap.c
index b5ffcef4e..9adbacdb4 100644
--- a/win/tty/termcap.c
+++ b/win/tty/termcap.c
@@ -890,7 +890,7 @@ cl_eos(void) /* free after Robert Viduya */
#include <curses.h>
-#if !defined(LINUX) && !defined(__FreeBSD__) && !defined(NOTPARMDECL)
+#if !defined(__gnu_hurd__) && !defined(LINUX) && !defined(__FreeBSD__) && !defined(NOTPARMDECL)
extern char *tparm();
#endif
@@ -0,0 +1,13 @@
diff --git a/include/tradstdc.h b/include/tradstdc.h
index a202c0c7b..d4b3f9b3f 100644
--- a/include/tradstdc.h
+++ b/include/tradstdc.h
@@ -441,7 +441,7 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
/* #pragma message is available */
#define NH_PRAGMA_MESSAGE 1
#endif /* __GNUC__ greater than or equal to 5 */
-#if (!defined(__linux__) && !defined(MACOS)) || defined(GCC_URWARN)
+#if 0
/* disable gcc's __attribute__((__warn_unused_result__)) since explicitly
discarding the result by casting to (void) is not accepted as a 'use' */
#define __warn_unused_result__ /*empty*/
@@ -0,0 +1,122 @@
From 34f3ec2ba49f33c03471ab99376d40ef65ab4ed8 Mon Sep 17 00:00:00 2001
From: Stefan Strogin <stefan@steils.org>
Date: Tue, 5 May 2026 01:20:01 +0000
Subject: [PATCH] Rename manpage from recover to recover-nethack
---
doc/nethack.6 | 2 +-
doc/recover.6 | 26 +++++++++++++-------------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/doc/nethack.6 b/doc/nethack.6
index 85b99c389..fe15be123 100644
--- a/doc/nethack.6
+++ b/doc/nethack.6
@@ -575,7 +575,7 @@ SHOPTYPE and SPLEVTYPE can be used in debugging (wizard) mode.
DEBUGFILES can be used if the program was built with 'DEBUG' enabled.
.SH "SEE ALSO"
.PP
-recover(6)
+recover-nethack(6)
.SH BUGS
.PP
Probably infinite.
diff --git a/doc/recover.6 b/doc/recover.6
index 90d56c8c9..83f1eb157 100644
--- a/doc/recover.6
+++ b/doc/recover.6
@@ -17,9 +17,9 @@
.el .hy 14
.ds Na Kenneth Lorber
.SH NAME
-recover \- recover a NetHack game interrupted by disaster
+recover-nethack \- recover a NetHack game interrupted by disaster
.SH SYNOPSIS
-.B recover
+.B recover-nethack
[
.B \-d
.I directory
@@ -37,7 +37,7 @@ so such games can be recovered at the point of the last level change.
The
.I base
options tell
-.I recover
+.I recover-nethack
which files to process.
Each base option specifies recovery of a separate game.
.PP
@@ -89,24 +89,24 @@ by a user number to avoid conflicts,
or "xlock" if the number of concurrent players is being limited.
It may be necessary to look in the playground to find the correct
base name of the interrupted game.
-.I recover
+.I recover-nethack
will transform these level files into a save file of the same name as
.I nethack
would have used.
.PP
Since
-.I recover
+.I recover-nethack
must be able to read and delete files from the playground
and create files in the save directory,
it has interesting interactions with game security.
Giving ordinary players access to
-.I recover
+.I recover-nethack
through setuid or setgid is tantamount to leaving the playground
world-writable,
with respect to both cheating and messing up other players.
For a single-user system, this of course does not change anything,
so some of the microcomputer ports install
-.I recover
+.I recover-nethack
by default.
.PP
For a multi-user system,
@@ -114,22 +114,22 @@ the game administrator may want to arrange for all .0 files in the
playground to be fed to recover when the host machine boots,
and handle game crashes individually.
If the user population is sufficiently trustworthy,
-.I recover
+.I recover-nethack
can be installed with the same permissions the
.I nethack
executable has.
In either case,
-.I recover
+.I recover-nethack
is easily compiled from the distribution utility directory.
.SH NOTES
.PP
Like
.I nethack
itself,
-.I recover
+.I recover-nethack
will overwrite existing savefiles of the same name.
Savefiles created by
-.I recover
+.I recover-nethack
are uncompressed;
they may be compressed afterwards if desired,
but even a compression-using
@@ -139,12 +139,12 @@ will find them in the uncompressed form.
nethack(6)
.SH BUGS
.PP
-.I recover
+.I recover-nethack
makes no attempt to find out if a base name specifies a game in progress.
If multiple machines share a playground, this would be impossible to
determine.
.PP
-.I recover
+.I recover-nethack
should be taught to use the nethack playground locking mechanism to
avoid conflicts.
.SH COPYRIGHT
--
2.54.0
@@ -0,0 +1,82 @@
From 82f26ab102f327c021d89d4917e60d13063dcd23 Mon Sep 17 00:00:00 2001
From: Stefan Strogin <stefan@steils.org>
Date: Tue, 5 May 2026 04:53:20 +0000
Subject: [PATCH] Allow building against system Lua
---
sys/unix/Makefile.src | 6 ++++++
sys/unix/Makefile.top | 17 +++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src
index 863fa096c..c5004de5a 100644
--- a/sys/unix/Makefile.src
+++ b/sys/unix/Makefile.src
@@ -503,10 +503,16 @@ MAKEDEFS = ../util/makedefs
# -lm required by lua
LUA_VERSION ?=5.4.8
+SYSTEM_LUA ?=0
+LUA_LIBS ?=
LUABASE = liblua-$(LUA_VERSION).a
LUALIB = ../lib/lua/$(LUABASE)
LUALIBS = $(LUALIB) -lm $(DLLIB)
LUAHEADERS = lib/lua-$(LUA_VERSION)/src
+ifeq ($(SYSTEM_LUA),1)
+LUALIB =
+LUALIBS = $(LUA_LIBS)
+endif
# timestamp files to reduce `make' overhead and shorten .o dependency lists
CONFIG_H = ../src/config.h-t
diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top
index 5ecca3232..47e455a3e 100644
--- a/sys/unix/Makefile.top
+++ b/sys/unix/Makefile.top
@@ -122,12 +122,17 @@ RECOVERBIN = recover
# Lua
LUAHEADERS = lib/lua-$(LUA_VERSION)/src
+SYSTEM_LUA ?=0
+LUA_HEADER_DIR ?=/usr/include
LUATESTTARGET = $(LUAHEADERS)/lua.h
LUATOP = $(LUAHEADERS)
LUAMAKEFLAGS = CC='$(CC)' SYSCFLAGS='$(SYSCFLAGS)'
LUA2NHTOP = ../../..
LUABASELIB = liblua-$(LUA_VERSION).a
TOPLUALIB = lib/lua/$(LUABASELIB)
+ifeq ($(SYSTEM_LUA),1)
+TOPLUALIB =
+endif
ALLDEP = $(PRECHECK) $(GAME) recover Guidebook $(VARDAT) spec_levs check-dlb
@@ -141,6 +146,17 @@ $(GAME): lua_support
lua_support: include/nhlua.h
@true
+ifeq ($(SYSTEM_LUA),1)
+include/nhlua.h:
+ echo '/* nhlua.h - generated by top Makefile */' > $@
+ @echo '#include <lua.h>' >> $@
+ @sed -e '/(lua_error)/!d' \
+ -e '/(lua_error)/s/LUA_API/ATTRNORETURN LUA_API/1' \
+ -e '/(lua_error)/s/;/ NORETURN;/1' < $(LUA_HEADER_DIR)/lua.h >> $@
+ @echo '#include <lualib.h>' >> $@
+ @echo '#include <lauxlib.h>' >> $@
+ @echo '/*nhlua.h*/' >> $@
+else
$(LUATOP)/liblua.a: $(LUAHEADERS)/lua.h
( cd $(LUATOP) && make $(LUAMAKEFLAGS) a )
$(TOPLUALIB): $(LUATOP)/liblua.a
@@ -160,6 +176,7 @@ include/nhlua.h: $(TOPLUALIB)
lib/lua-$(LUA_VERSION)/src/lua.h:
@echo "Please do 'make fetch-lua' in the top directory to obtain lua-$(LUA_VERSION)"
@false
+endif
luabin:
( cd $(LUATOP) \
&& make $(LUAMAKEFILES) all && cd $(LUA2NHTOP) )
--
2.54.0
@@ -0,0 +1,201 @@
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
LUA_COMPAT=( lua5-4 )
inherit desktop flag-o-matic lua-single toolchain-funcs
DESCRIPTION="The ultimate old-school single player dungeon exploration game"
HOMEPAGE="https://www.nethack.org/"
SRC_URI="https://nethack.org/download/${PV}/nethack-${PV//.}-src.tgz -> ${P}.tar.gz"
S="${WORKDIR}/NetHack-${PV}"
LICENSE="nethack"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~x86"
IUSE="X qt6"
REQUIRED_USE="
${LUA_REQUIRED_USE}
"
RDEPEND="
${LUA_DEPS}
acct-group/gamestat
sys-libs/ncurses:0=
X? (
x11-libs/libX11
x11-libs/libXaw
x11-libs/libXpm
x11-libs/libXt
)
qt6? (
dev-qt/qtbase:6[gui,widgets]
dev-qt/qtmultimedia:6
)
"
DEPEND="
${RDEPEND}
X? ( x11-base/xorg-proto )
"
BDEPEND="
virtual/pkgconfig
app-alternatives/lex
app-alternatives/yacc
X? (
x11-apps/bdftopcf
x11-apps/mkfontscale
)
qt6? ( dev-qt/qtbase:6 )
"
PATCHES=(
"${FILESDIR}/${PN}-5.0.0-system-lua.patch"
"${FILESDIR}/${PN}-5.0.0-recover.patch"
"${FILESDIR}/${PN}-3.6.6-clang16.patch"
"${FILESDIR}/${PN}-5.0.0-no-define-warn-unused-result.patch"
"${FILESDIR}/${PN}-3.6.7-path-max.patch"
"${FILESDIR}/${PN}-5.0.0-hurd-tparm.patch"
)
pkg_setup() {
lua-single_pkg_setup
}
src_prepare() {
default
local hint="${FILESDIR}/${PN}-3.6.3-hint-tty"
use X && hint="${FILESDIR}/${PN}-5.0.0-hint-x11"
use qt6 && hint="${FILESDIR}/${PN}-5.0.0-hint-qt6"
use X && use qt6 && hint="${FILESDIR}/${PN}-5.0.0-hint-qt6-x11"
cp "${hint}" hint || die "Failed to copy hint file"
sys/unix/setup.sh hint || die "Failed to run setup.sh"
}
src_compile() {
local qt_cflags qt_libs
append-cflags -std=gnu99 # NetHack 5.0 contains C99 code, but still incompatible with c2x
append-cflags -I../include -DDLB -DSECURE -DTIMED_DELAY -DVISION_TABLES -DDUMPLOG -DSCORE_ON_BOTL
append-cflags '-DCOMPRESS=\"${EPREFIX}/bin/gzip\"' '-DCOMPRESS_EXTENSION=\".gz\"'
append-cflags "-DHACKDIR=\\\"${EPREFIX}/usr/$(get_libdir)/nethack\\\""
append-cflags "-DVAR_PLAYGROUND=\\\"${EPREFIX}/var/games/nethack\\\""
append-cflags "-DDEF_PAGER=\\\"${PAGER}\\\""
append-cflags -DSYSCF "-DSYSCF_FILE=\\\"${EPREFIX}/etc/nethack.sysconf\\\""
append-cflags "$(lua_get_CFLAGS)"
if use X; then
append-cflags -DX11_GRAPHICS -DUSE_XPM
# XtErrorHandler usage seems right, but headers "may" add ((noreturn))
# giving an incompatible type error with clang-16 (could alternatively
# use private _X_NORETURN but this may be fragile)
append-cflags -Wno-error=incompatible-pointer-types #874462
fi
use qt6 && append-cflags -DQT_GRAPHICS -DUSE_XPM -DSND_LIB_QTSOUND -DUSER_SOUNDS
if use qt6; then
qt_cflags="$($(tc-getPKG_CONFIG) --cflags Qt6Gui Qt6Widgets Qt6Multimedia)"
qt_libs="$($(tc-getPKG_CONFIG) --libs Qt6Gui Qt6Widgets Qt6Multimedia)"
append-cxxflags -std=gnu++20 -I. -I../include $(lua_get_CFLAGS)
append-cxxflags -DQT_GRAPHICS -DUSE_XPM -DSND_LIB_QTSOUND -DUSER_SOUNDS ${qt_cflags} -fPIC
append-cxxflags "-DHACKDIR=\\\"${EPREFIX}/usr/$(get_libdir)/nethack\\\""
use X && append-cxxflags -DX11_GRAPHICS
fi
LOCAL_MAKEOPTS=(
CC="$(tc-getCC)" CXX="$(tc-getCXX)" CFLAGS="${CFLAGS}" LFLAGS="${LDFLAGS}"
SYSTEM_LUA=1
LUA_VERSION="$(lua_get_version)"
LUA_HEADER_DIR="$(lua_get_include_dir)"
LUA_LIBS="$(lua_get_LIBS)"
WINTTYLIB="$($(tc-getPKG_CONFIG) --libs ncurses)"
HACKDIR="${EPREFIX}/usr/$(get_libdir)/nethack"
)
if use qt6; then
LOCAL_MAKEOPTS+=(
CXXFLAGS="${CXXFLAGS}"
QTLIBS="${qt_libs}"
MOCPATH="$($(tc-getPKG_CONFIG) Qt6Gui --variable=libexecdir)/moc"
QTDIR="${EPREFIX}/usr"
)
fi
# Upstream still has some parallel compilation bugs.
emake -j1 "${LOCAL_MAKEOPTS[@]}" nethack recover spec_levs
# XXX: Lots of troff errors on Hurd, so don't build the Guidebook there for now.
! use kernel_Hurd && emake -j1 "${LOCAL_MAKEOPTS[@]}" Guidebook
emake -j1 "${LOCAL_MAKEOPTS[@]}" all
}
src_install() {
emake \
"${LOCAL_MAKEOPTS[@]}" \
INSTDIR="${ED}/usr/$(get_libdir)/nethack" \
SHELLDIR="${ED}/usr/bin" \
VARDIR="${ED}/var/games/nethack" \
install
mv "${ED}/usr/$(get_libdir)/nethack/recover" "${ED}/usr/bin/recover-nethack" || die "Failed to move recover-nethack"
doman doc/nethack.6
newman doc/recover.6 recover-nethack.6
dodoc doc/Guidebook.txt
insinto /etc
newins sys/unix/sysconf nethack.sysconf
if use X ; then
cd "${S}/win/X11" || die "Failed to enter win/X11 directory"
mkdir -p "${ED}/etc/X11/app-defaults/" || die "Failed to make app-defaults directory"
mv "${ED}/usr/$(get_libdir)/nethack/NetHack.ad" "${ED}/etc/X11/app-defaults/" || die "Failed to move NetHack.ad"
newicon nh_icon.xpm nethack.xpm
make_desktop_entry ${PN} Nethack
# install nethack fonts
bdftopcf -o nh10.pcf nh10.bdf || die "Converting fonts failed"
bdftopcf -o ibm.pcf ibm.bdf || die "Converting fonts failed"
insinto "/usr/$(get_libdir)/nethack/fonts"
doins *.pcf
mkfontdir "${ED}/usr/$(get_libdir)/nethack/fonts" || die "mkfontdir failed"
fi
rm -r "${ED}/var/games/nethack" || die "Failed to clean var/games/nethack"
keepdir /var/games/nethack/save
}
pkg_preinst() {
fowners root:gamestat /var/games/nethack /var/games/nethack/save
fperms 2770 /var/games/nethack /var/games/nethack/save
fowners root:gamestat "/usr/$(get_libdir)/nethack/nethack"
fperms g+s "/usr/$(get_libdir)/nethack/nethack"
}
pkg_postinst() {
cd "${EROOT}/var/games/nethack" || die "Failed to enter ${EROOT}/var/games/nethack directory"
# Transition mechanism for <nethack-3.6.1 ebuilds. It's perfectly safe, so we'll just run it unconditionally.
chmod 2770 . save || die "Failed to chmod statedir"
# Those files can't be created earlier because we don't want portage to wipe them during upgrades
( umask 007 && touch logfile perm record xlogfile ) || die "Failed to create log files"
# Instead of using a proper version header in its save files, nethack checks for incompatibilities
# by comparing the mtimes of save files and its own binary. This would require admin interaction even
# during upgrades which don't change the file format, so we'll just touch the files and warn the admin
# manually in case of compatibility issues.
(
shopt -s nullglob
local saves=( bones* save/* )
[[ -n "${saves[*]}" ]] && touch -c "${saves[@]}"
) # non-fatal
}