Line 0
Link Here
|
0 |
- |
1 |
# Copyright 1999-2022 Gentoo Authors |
|
|
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
|
4 |
EAPI=7 |
5 |
|
6 |
inherit desktop flag-o-matic toolchain-funcs |
7 |
|
8 |
DESCRIPTION="The ultimate old-school single player dungeon exploration game" |
9 |
HOMEPAGE="https://www.nethack.org/" |
10 |
SRC_URI="https://nethack.org/download/${PV}/nethack-${PV//.}-src.tgz -> ${P}.tar.gz" |
11 |
S="${WORKDIR}/NetHack-${PV}" |
12 |
|
13 |
LICENSE="nethack" |
14 |
SLOT="0" |
15 |
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~x86" |
16 |
IUSE="X" |
17 |
|
18 |
RDEPEND=" |
19 |
acct-group/gamestat |
20 |
sys-libs/ncurses:0= |
21 |
X? ( |
22 |
x11-libs/libX11 |
23 |
x11-libs/libXaw |
24 |
x11-libs/libXpm |
25 |
x11-libs/libXt |
26 |
) |
27 |
" |
28 |
DEPEND=" |
29 |
${RDEPEND} |
30 |
X? ( x11-base/xorg-proto ) |
31 |
" |
32 |
BDEPEND=" |
33 |
virtual/pkgconfig |
34 |
app-alternatives/yacc |
35 |
X? ( |
36 |
x11-apps/bdftopcf |
37 |
x11-apps/mkfontscale |
38 |
) |
39 |
" |
40 |
|
41 |
PATCHES=( |
42 |
"${FILESDIR}/${PN}-3.6.6-clang16.patch" |
43 |
) |
44 |
|
45 |
src_prepare() { |
46 |
default |
47 |
|
48 |
cp "${FILESDIR}/${PN}-3.6.3-hint-$(usex X x11 tty)" hint || die "Failed to copy hint file" |
49 |
sys/unix/setup.sh hint || die "Failed to run setup.sh" |
50 |
} |
51 |
|
52 |
src_compile() { |
53 |
append-cflags -std=gnu89 # old codebase, incompatible with c2x |
54 |
append-cflags -I../include -DDLB -DSECURE -DTIMED_DELAY -DVISION_TABLES -DDUMPLOG -DSCORE_ON_BOTL |
55 |
append-cflags '-DCOMPRESS=\"${EPREFIX}/bin/gzip\"' '-DCOMPRESS_EXTENSION=\".gz\"' |
56 |
append-cflags "-DHACKDIR=\\\"${EPREFIX}/usr/$(get_libdir)/nethack\\\"" "-DVAR_PLAYGROUND=\\\"${EPREFIX}/var/games/nethack\\\"" |
57 |
append-cflags "-DDEF_PAGER=\\\"${PAGER}\\\"" |
58 |
append-cflags -DSYSCF "-DSYSCF_FILE=\\\"${EPREFIX}/etc/nethack.sysconf\\\"" |
59 |
|
60 |
if use X; then |
61 |
append-cflags -DX11_GRAPHICS -DUSE_XPM |
62 |
|
63 |
# XtErrorHandler usage seems right, but headers "may" add ((noreturn)) |
64 |
# giving an incompatible type error with clang-16 (could alternatively |
65 |
# use private _X_NORETURN but this may be fragile) |
66 |
append-cflags -Wno-error=incompatible-pointer-types #874462 |
67 |
fi |
68 |
|
69 |
LOCAL_MAKEOPTS=( |
70 |
CC="$(tc-getCC)" CFLAGS="${CFLAGS}" LFLAGS="${LDFLAGS}" |
71 |
WINTTYLIB="$($(tc-getPKG_CONFIG) --libs ncurses)" |
72 |
HACKDIR="${EPREFIX}/usr/$(get_libdir)/nethack" INSTDIR="${ED}/usr/$(get_libdir)/nethack" |
73 |
SHELLDIR="${ED}/usr/bin" VARDIR="${ED}/var/games/nethack" |
74 |
) |
75 |
|
76 |
emake "${LOCAL_MAKEOPTS[@]}" nethack recover Guidebook spec_levs |
77 |
|
78 |
# Upstream still has some parallel compilation bugs |
79 |
emake -j1 "${LOCAL_MAKEOPTS[@]}" all |
80 |
} |
81 |
|
82 |
src_install() { |
83 |
emake "${LOCAL_MAKEOPTS[@]}" install |
84 |
|
85 |
mv "${ED}/usr/$(get_libdir)/nethack/recover" "${ED}/usr/bin/recover-nethack" || die "Failed to move recover-nethack" |
86 |
|
87 |
doman doc/nethack.6 |
88 |
newman doc/recover.6 recover-nethack.6 |
89 |
dodoc doc/Guidebook.txt |
90 |
|
91 |
insinto /etc |
92 |
newins sys/unix/sysconf nethack.sysconf |
93 |
|
94 |
insinto /etc/skel |
95 |
newins "${FILESDIR}/${PN}-3.6.0-nethackrc" .nethackrc |
96 |
|
97 |
if use X ; then |
98 |
cd "${S}/win/X11" || die "Failed to enter win/X11 directory" |
99 |
|
100 |
mkdir -p "${ED}/etc/X11/app-defaults/" || die "Failed to make app-defaults directory" |
101 |
mv "${ED}/usr/$(get_libdir)/nethack/NetHack.ad" "${ED}/etc/X11/app-defaults/" || die "Failed to move NetHack.ad" |
102 |
|
103 |
newicon nh_icon.xpm nethack.xpm |
104 |
make_desktop_entry ${PN} Nethack |
105 |
|
106 |
# install nethack fonts |
107 |
bdftopcf -o nh10.pcf nh10.bdf || die "Converting fonts failed" |
108 |
bdftopcf -o ibm.pcf ibm.bdf || die "Converting fonts failed" |
109 |
insinto "/usr/$(get_libdir)/nethack/fonts" |
110 |
doins *.pcf |
111 |
mkfontdir "${ED}/usr/$(get_libdir)/nethack/fonts" || die "mkfontdir failed" |
112 |
fi |
113 |
|
114 |
rm -r "${ED}/var/games/nethack" || die "Failed to clean var/games/nethack" |
115 |
keepdir /var/games/nethack/save |
116 |
} |
117 |
|
118 |
pkg_preinst() { |
119 |
fowners root:gamestat /var/games/nethack /var/games/nethack/save |
120 |
fperms 2770 /var/games/nethack /var/games/nethack/save |
121 |
|
122 |
fowners root:gamestat "/usr/$(get_libdir)/nethack/nethack" |
123 |
fperms g+s "/usr/$(get_libdir)/nethack/nethack" |
124 |
} |
125 |
|
126 |
pkg_postinst() { |
127 |
cd "${EROOT}/var/games/nethack" || die "Failed to enter ${EROOT}/var/games/nethack directory" |
128 |
|
129 |
# Transition mechanism for <nethack-3.6.1 ebuilds. It's perfectly safe, so we'll just run it unconditionally. |
130 |
chmod 2770 . save || die "Failed to chmod statedir" |
131 |
|
132 |
# Those files can't be created earlier because we don't want portage to wipe them during upgrades |
133 |
( umask 007 && touch logfile perm record xlogfile ) || die "Failed to create log files" |
134 |
|
135 |
# Instead of using a proper version header in its save files, nethack checks for incompatibilities |
136 |
# by comparing the mtimes of save files and its own binary. This would require admin interaction even |
137 |
# during upgrades which don't change the file format, so we'll just touch the files and warn the admin |
138 |
# manually in case of compatibility issues. |
139 |
( |
140 |
shopt -s nullglob |
141 |
local saves=( bones* save/* ) |
142 |
[[ -n "${saves[*]}" ]] && touch -c "${saves[@]}" |
143 |
) # non-fatal |
144 |
|
145 |
elog "A minimal default .nethackrc has been placed in /etc/skel/" |
146 |
elog "The sysconf file is at /etc/nethack.sysconf" |
147 |
} |