/[gentoo-x86]/games-roguelike/nethack/nethack-3.4.3-r4.ebuild
Gentoo

Contents of /games-roguelike/nethack/nethack-3.4.3-r4.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Tue Jun 9 08:34:25 2015 UTC (5 years, 1 month ago) by swift
Branch: MAIN
CVS Tags: HEAD
Move executable from /usr/share/games to /usr/games/bin and fix bug #551176

(Portage version: 2.2.18/cvs/Linux x86_64, signed Manifest commit with key 0x2EDD52403B68AF47)

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/games-roguelike/nethack/nethack-3.4.3-r3.ebuild,v 1.1 2015/02/20 16:24:58 swift Exp $
4
5 EAPI=5
6 inherit eutils toolchain-funcs flag-o-matic user
7
8 MY_PV=${PV//.}
9 DESCRIPTION="The ultimate old-school single player dungeon exploration game"
10 HOMEPAGE="http://www.nethack.org/"
11 SRC_URI="mirror://sourceforge/nethack/${PN}-${MY_PV}-src.tgz"
12
13 LICENSE="nethack"
14 SLOT="0"
15 KEYWORDS="~amd64 ~hppa ~ppc ~sparc ~x86 ~x86-fbsd"
16 IUSE="X"
17
18 RDEPEND=">=sys-libs/ncurses-5.2-r5
19 X? (
20 x11-libs/libXaw
21 x11-libs/libXpm
22 x11-libs/libXt
23 )"
24 DEPEND="${RDEPEND}
25 virtual/pkgconfig
26 X? (
27 x11-proto/xproto
28 x11-apps/bdftopcf
29 x11-apps/mkfontdir
30 )"
31
32 BINDIR="/usr/games/bin"
33 HACKDIR="/usr/share/games/${PN}"
34 STATEDIR="/var/games/${PN}"
35
36 NETHACK_GROUP="gamestat"
37
38 pkg_setup() {
39 enewgroup gamestat 36
40 }
41
42 src_prepare() {
43 # This copies the /sys/unix Makefile.*s to their correct places for
44 # seding and compiling.
45 cd "sys/unix" || die "Could not go into sys/unix directory"
46 source setup.sh || die
47
48 cd ../.. || die "Failed to get back to main directory"
49 epatch \
50 "${FILESDIR}"/${PV}-gentoo-paths.patch \
51 "${FILESDIR}"/${PV}-default-options.patch \
52 "${FILESDIR}"/${PV}-bison.patch \
53 "${FILESDIR}"/${PV}-macos.patch \
54 "${FILESDIR}"/${P}-gibc210.patch \
55 "${FILESDIR}"/${P}-recover.patch
56
57 epatch_user
58
59 mv doc/recover.6 doc/nethack-recover.6 || die "Could not rename recover.6 to nethack-recover.6"
60
61 sed -i \
62 -e "s:GENTOO_STATEDIR:${STATEDIR}:" include/unixconf.h \
63 || die "setting statedir"
64 sed -i \
65 -e "s:GENTOO_HACKDIR:${HACKDIR}:" include/config.h \
66 || die "setting hackdir"
67 # set the default pager from the environment bug #52122
68 if [[ -n "${PAGER}" ]] ; then
69 sed -i \
70 -e "115c\#define DEF_PAGER \"${PAGER}\"" \
71 include/unixconf.h \
72 || die "setting statedir"
73 # bug #57410
74 sed -i \
75 -e "s/^DATNODLB =/DATNODLB = \$(DATHELP)/" Makefile \
76 || die "sed Makefile failed"
77 fi
78
79 # sys-libs/ncurses[tinfo]
80 sed -i \
81 -e '/^WINTTYLIB/s| = .*| = '"$(
82 $(tc-getPKG_CONFIG) --libs ncurses
83 )"'|g' \
84 src/Makefile || die
85
86 if use X ; then
87 epatch "${FILESDIR}/${PV}-X-support.patch"
88 fi
89 }
90
91 src_compile() {
92 local lflags="${LDFLAGS}"
93
94 cd "${S}"/src || die "Failed to enter src directory"
95 append-flags -I../include
96
97 emake \
98 CC="$(tc-getCC)" \
99 CFLAGS="${CFLAGS}" \
100 LFLAGS="${lflags}" \
101 ../util/makedefs
102 emake \
103 CC="$(tc-getCC)" \
104 CFLAGS="${CFLAGS}" \
105 LFLAGS="${lflags}"
106 cd "${S}"/util || die "Failed to enter util directory"
107 emake \
108 CC="$(tc-getCC)" \
109 CFLAGS="${CFLAGS}" \
110 LFLAGS="${lflags}" \
111 recover
112 }
113
114 src_install() {
115 emake \
116 CC="$(tc-getCC)" \
117 CFLAGS="${CFLAGS}" \
118 LFLAGS="-L/usr/X11R6/lib" \
119 GAMEPERM=02755 \
120 GAMEUID="root" GAMEGRP="${NETHACK_GROUP}" \
121 PREFIX="${D}/usr" \
122 GAMEDIR="${D}/${HACKDIR}" \
123 SHELLDIR="${D}/${BINDIR}" \
124 install
125
126 # We keep this stuff in STATEDIR instead so tidy up.
127 rm -rf "${D}/${HACKDIR}/"{nethack,recover,save}
128
129 exeinto "${BINDIR}"
130 newexe src/nethack nethack-bin
131 newexe util/recover recover-nethack
132
133 # The final nethack is a sh script. This fixes the hard-coded
134 # HACKDIR directory so it doesn't point to ${D}/usr/share/nethackdir
135 # and points HACK to BINDIR/nethack-bin (see above)
136 sed -i \
137 -e "s:^\(HACKDIR=\).*$:\1${HACKDIR}:;
138 s:^\(HACK=\).*$:\1${BINDIR}/nethack-bin:" \
139 "${D}/${BINDIR}/nethack" \
140 || die "sed /${BINDIR}/nethack failed"
141
142 doman doc/*.6
143 dodoc doc/*.txt
144
145 # Can be copied to ~/.nethackrc to set options
146 # Add this to /etc/.skel as well, thats the place for default configs
147 insinto "${HACKDIR}"
148 doins "${FILESDIR}/dot.nethackrc"
149
150 local windowtypes="tty"
151 use X && windowtypes="${windowtypes} x11"
152 set -- ${windowtypes}
153 sed -i \
154 -e "s:GENTOO_WINDOWTYPES:${windowtypes}:" \
155 -e "s:GENTOO_DEFWINDOWTYPE:$1:" \
156 "${D}${HACKDIR}/dot.nethackrc" \
157 || die "sed ${HACKDIR}/dot.nethackrc failed"
158 insinto /etc/skel
159 newins "${D}/${HACKDIR}/dot.nethackrc" .nethackrc
160
161 if use X ; then
162 # install nethack fonts
163 cd "${S}/win/X11" || die "Failed to enter win/X11 directory"
164 bdftopcf -o nh10.pcf nh10.bdf || die "Converting fonts failed"
165 bdftopcf -o ibm.pcf ibm.bdf || die "Converting fonts failed"
166 insinto "${HACKDIR}/fonts"
167 doins *.pcf
168 cd "${D}/${HACKDIR}/fonts" || die "Failed to enter fonts directory"
169 mkfontdir || die "The action mkfontdir ${HACKDIR}/fonts failed"
170
171 # copy nethack x application defaults
172 cd "${S}/win/X11" || die "Failed to enter win/X11 directory again"
173 insinto /etc/X11/app-defaults
174 newins NetHack.ad NetHack
175 sed -i \
176 -e 's:^!\(NetHack.tile_file.*\):\1:' \
177 "${D}/etc/X11/app-defaults/NetHack" \
178 || die "sed /etc/X11/app-defaults/NetHack failed"
179 fi
180
181 keepdir "${STATEDIR}/save"
182 rm "${D}/${HACKDIR}/"{logfile,perm,record}
183 make_desktop_entry nethack "Nethack"
184
185 fowners -R "root:${NETHACK_GROUP}" "${STATEDIR}"
186 fperms -R 660 "${STATEDIR}"
187 fperms 770 "${STATEDIR}" "${STATEDIR}/save"
188
189 fowners "root:${NETHACK_GROUP}" ${BINDIR}/nethack-bin
190 fperms g+s ${BINDIR}/nethack-bin
191 }
192
193 pkg_preinst() {
194 if has_version "<${CATEGORY}/${PN}-3.4.3-r3" ; then
195 migration=true
196
197 # preserve STATEDIR/{logfile,record}
198 # (previous ebuild rev mistakenly removes it)
199 for f in "${ROOT}/${STATEDIR}/"{logfile,record} ; do
200 if [[ -e "$f" ]] ; then
201 cp "$f" "$T" || die "Failed to preserve ${ROOT}/${STATEDIR} files"
202 else
203 touch "$T/$f" || die "Failed to preserve ${ROOT}/${STATEDIR} files"
204 fi
205 done
206 fi
207 }
208
209 pkg_postinst() {
210 cd "${ROOT}/${STATEDIR}" || die "Failed to enter ${STATEDIR} directory"
211
212 if [[ -v migration ]] ; then
213 cp "$T/"{logfile,record} . || \
214 die "Failed to preserve ${ROOT}/${STATEDIR} files"
215
216 chown -R root:"${NETHACK_GROUP}" . && \
217 chmod -R 660 . && \
218 chmod 770 . save || \
219 die "Adjustment of file permissions in ${ROOT}/${STATEDIR} failed"
220 fi
221
222 # we don't want to overwrite existing files, as they contain user data
223 local files="logfile perm record"
224
225 touch $files && \
226 chmod 660 $files && \
227 chown root:"${NETHACK_GROUP}" $files || \
228 die "Adjustment of file permissions in "${ROOT}/${STATEDIR}" failed"
229
230 elog "You may want to look at /etc/skel/.nethackrc for interesting options"
231 }

  ViewVC Help
Powered by ViewVC 1.1.20