projects/guix·blob javascript-team · refs

251 lines · 10.5 KiB

1As we cannot install outside the Store, and those games do not create the
2needed writable files on their own, we need a wrapper script.
3
4diff -Naur bsd-games-2.17/atc/Makefrag bsd-games-patch/atc/Makefrag
5--- bsd-games-2.17/atc/Makefrag 1970-01-01 07:00:00.000000000 +0700
6+++ bsd-games-patch/atc/Makefrag 2020-04-23 20:24:04.446176222 +0700
7@@ -47,7 +47,8 @@
8 mv atc/lex.yy.c $@
9
10 atc_install: atc_all
11- $(INSTALL_SCORE_GAME) atc/atc $(INSTALL_PREFIX)$(GAMESDIR)/atc
12+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/atc
13+ $(INSTALL_SCORE_GAME) atc/atc $(INSTALL_PREFIX)$(GAMESDIR)/.atc-real
14 $(HIDE_GAME) atc
15 $(INSTALL_SCORE_FILE) $(ATC_SCOREFILE)
16 $(INSTALL_MANUAL) atc/atc.6
17diff -Naur bsd-games-2.17/battlestar/Makefrag bsd-games-patch/battlestar/Makefrag
18--- bsd-games-2.17/battlestar/Makefrag 1970-01-01 07:00:00.000000000 +0700
19+++ bsd-games-patch/battlestar/Makefrag 2020-04-23 20:24:04.482175771 +0700
20@@ -32,7 +32,8 @@
21 battlestar_all: battlestar/battlestar battlestar/battlestar.6
22
23 battlestar_install: battlestar_all
24- $(INSTALL_SCORE_GAME) battlestar/battlestar $(INSTALL_PREFIX)$(GAMESDIR)/battlestar
25+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/battlestar
26+ $(INSTALL_SCORE_GAME) battlestar/battlestar $(INSTALL_PREFIX)$(GAMESDIR)/.battlestar-real
27 $(HIDE_GAME) battlestar
28 $(INSTALL_MANUAL) battlestar/battlestar.6
29 $(INSTALL_SCORE_FILE) $(BATTLESTAR_SCOREFILE)
30diff -Naur bsd-games-2.17/canfield/canfield/Makefrag bsd-games-patch/canfield/canfield/Makefrag
31--- bsd-games-2.17/canfield/canfield/Makefrag 1970-01-01 07:00:00.000000000 +0700
32+++ bsd-games-patch/canfield/canfield/Makefrag 2020-04-23 20:24:04.522175270 +0700
33@@ -31,7 +31,8 @@
34 canfield_canfield_all: canfield/canfield/canfield canfield/canfield/canfield.6
35
36 canfield_canfield_install: canfield_canfield_all
37- $(INSTALL_SCORE_GAME) canfield/canfield/canfield $(INSTALL_PREFIX)$(GAMESDIR)/canfield
38+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/canfield
39+ $(INSTALL_SCORE_GAME) canfield/canfield/canfield $(INSTALL_PREFIX)$(GAMESDIR)/.canfield-real
40 $(HIDE_GAME) canfield
41 $(INSTALL_MANUAL) canfield/canfield/canfield.6
42 $(INSTALL_SCORE_FILE) $(CANFIELD_SCOREFILE)
43diff -ur bsd-games-2.17.orig/canfield/cfscores/Makefrag bsd-games-2.17/canfield/cfscores/Makefrag
44--- bsd-games-2.17.orig/canfield/cfscores/Makefrag 1970-01-01 07:00:01.000000000 +0700
45+++ bsd-games-2.17/canfield/cfscores/Makefrag 2020-08-06 12:20:10.592076477 +0700
46@@ -32,6 +32,7 @@
47 canfield_cfscores_all: canfield/cfscores/cfscores
48
49 canfield_cfscores_install: canfield_cfscores_all
50- $(INSTALL_BINARY) canfield/cfscores/cfscores $(INSTALL_PREFIX)$(GAMESDIR)/cfscores
51+ $(INSTALL_BINARY) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/cfscores
52+ $(INSTALL_BINARY) canfield/cfscores/cfscores $(INSTALL_PREFIX)$(GAMESDIR)/.cfscores-real
53 $(HIDE_GAME) cfscores
54 $(INSTALL_MANUAL) canfield.6 cfscores.6
55diff -Naur bsd-games-2.17/cribbage/Makefrag bsd-games-patch/cribbage/Makefrag
56--- bsd-games-2.17/cribbage/Makefrag 1970-01-01 07:00:00.000000000 +0700
57+++ bsd-games-patch/cribbage/Makefrag 2020-04-23 20:24:04.534175120 +0700
58@@ -31,7 +31,8 @@
59 cribbage_all: cribbage/cribbage cribbage/cribbage.n cribbage/cribbage.6
60
61 cribbage_install: cribbage_all
62- $(INSTALL_SCORE_GAME) cribbage/cribbage $(INSTALL_PREFIX)$(GAMESDIR)/cribbage
63+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/cribbage
64+ $(INSTALL_SCORE_GAME) cribbage/cribbage $(INSTALL_PREFIX)$(GAMESDIR)/.cribbage-real
65 $(HIDE_GAME) cribbage
66 $(INSTALL_DATA) cribbage/cribbage.n $(INSTALL_PREFIX)$(CRIBBAGE_INSTRFILE)
67 $(INSTALL_SCORE_FILE) $(CRIBBAGE_SCOREFILE)
68diff -Naur bsd-games-2.17/hack/Makefrag bsd-games-patch/hack/Makefrag
69--- bsd-games-2.17/hack/Makefrag 1970-01-01 07:00:00.000000000 +0700
70+++ bsd-games-patch/hack/Makefrag 2020-04-23 20:24:04.590174419 +0700
71@@ -53,7 +53,8 @@
72 hack/hack.zap.d hack/rnd.d: hack/hack.onames.h
73
74 hack_install: hack_all
75- $(INSTALL_SCORE_GAME) hack/hack $(INSTALL_PREFIX)$(GAMESDIR)/hack
76+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/hack
77+ $(INSTALL_SCORE_GAME) hack/hack $(INSTALL_PREFIX)$(GAMESDIR)/.hack-real
78 $(HIDE_GAME) hack
79 $(INSTALL_HACK_DIR) $(INSTALL_PREFIX)$(HACK_DIR)
80 set -e; for f in data help hh rumors; do $(INSTALL_DATA) hack/$$f $(INSTALL_PREFIX)$(HACK_DIR)/$$f; done
81diff -Naur bsd-games-2.17/phantasia/Makefrag bsd-games-patch/phantasia/Makefrag
82--- bsd-games-2.17/phantasia/Makefrag 1970-01-01 07:00:00.000000000 +0700
83+++ bsd-games-patch/phantasia/Makefrag 2020-04-23 20:24:04.650173667 +0700
84@@ -38,7 +38,8 @@
85 touch phantasia/scorefiles.stamp
86
87 phantasia_install: phantasia_all
88- $(INSTALL_SCORE_GAME) phantasia/phantasia $(INSTALL_PREFIX)$(GAMESDIR)/phantasia
89+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/phantasia
90+ $(INSTALL_SCORE_GAME) phantasia/phantasia $(INSTALL_PREFIX)$(GAMESDIR)/.phantasia-real
91 $(HIDE_GAME) phantasia
92 (set -e; for f in $(phantasia_VFILES1); do \
93 cp phantasia/$$f $(INSTALL_PREFIX)$(PHANTASIA_DIR)/$$f; \
94diff -Naur bsd-games-2.17/robots/Makefrag bsd-games-patch/robots/Makefrag
95--- bsd-games-2.17/robots/Makefrag 1970-01-01 07:00:00.000000000 +0700
96+++ bsd-games-patch/robots/Makefrag 2020-04-23 20:24:04.702173016 +0700
97@@ -32,7 +32,8 @@
98 robots_all: robots/robots robots/robots.6
99
100 robots_install: robots_all
101- $(INSTALL_SCORE_GAME) robots/robots $(INSTALL_PREFIX)$(GAMESDIR)/robots
102+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/robots
103+ $(INSTALL_SCORE_GAME) robots/robots $(INSTALL_PREFIX)$(GAMESDIR)/.robots-real
104 $(HIDE_GAME) robots
105 $(INSTALL_SCORE_FILE) $(ROBOTS_SCOREFILE)
106 $(INSTALL_MANUAL) robots/robots.6
107diff -Naur bsd-games-2.17/sail/Makefrag bsd-games-patch/sail/Makefrag
108--- bsd-games-2.17/sail/Makefrag 1970-01-01 07:00:00.000000000 +0700
109+++ bsd-games-patch/sail/Makefrag 2020-04-23 20:24:04.710172917 +0700
110@@ -31,7 +31,8 @@
111 sail_all: sail/sail sail/sail.6
112
113 sail_install: sail_all
114- $(INSTALL_SCORE_GAME) sail/sail $(INSTALL_PREFIX)$(GAMESDIR)/sail
115+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/sail
116+ $(INSTALL_SCORE_GAME) sail/sail $(INSTALL_PREFIX)$(GAMESDIR)/.sail-real
117 $(HIDE_GAME) sail
118 $(INSTALL_SCORE_FILE) $(SAIL_SCOREFILE)
119 $(INSTALL_SAIL_DIR) $(INSTALL_PREFIX)$(SAIL_DIR)
120diff -Naur bsd-games-2.17/snake/snake/Makefrag bsd-games-patch/snake/snake/Makefrag
121--- bsd-games-2.17/snake/snake/Makefrag 1970-01-01 07:00:00.000000000 +0700
122+++ bsd-games-patch/snake/snake/Makefrag 2020-04-23 20:24:04.722172766 +0700
123@@ -31,7 +31,8 @@
124 snake_snake_all: snake/snake/snake snake/snake/snake.6
125
126 snake_snake_install: snake_snake_all
127- $(INSTALL_SCORE_GAME) snake/snake/snake $(INSTALL_PREFIX)$(GAMESDIR)/snake
128+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/snake
129+ $(INSTALL_SCORE_GAME) snake/snake/snake $(INSTALL_PREFIX)$(GAMESDIR)/.snake-real
130 $(HIDE_GAME) snake
131 $(INSTALL_SCORE_FILE) $(SNAKE_SCOREFILE)
132 $(INSTALL_SCORE_FILE) $(SNAKE_RAWSCOREFILE)
133--- bsd-games-2.17.orig/snake/snscore/Makefrag 1970-01-01 07:00:01.000000000 +0700
134+++ bsd-games-2.17/snake/snscore/Makefrag 2020-08-06 12:33:09.636089394 +0700
135@@ -32,6 +32,7 @@
136 snake_snscore_all: snake/snscore/snscore
137
138 snake_snscore_install: snake_snscore_all
139- $(INSTALL_BINARY) snake/snscore/snscore $(INSTALL_PREFIX)$(GAMESDIR)/snscore
140+ $(INSTALL_BINARY) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/snscore
141+ $(INSTALL_BINARY) snake/snscore/snscore $(INSTALL_PREFIX)$(GAMESDIR)/.snscore-real
142 $(HIDE_GAME) snscore
143 $(INSTALL_MANUAL) snake.6 snscore.6
144diff -Naur bsd-games-2.17/tetris/Makefrag bsd-games-patch/tetris/Makefrag
145--- bsd-games-2.17/tetris/Makefrag 1970-01-01 07:00:00.000000000 +0700
146+++ bsd-games-patch/tetris/Makefrag 2020-04-23 20:24:04.734172616 +0700
147@@ -32,7 +32,8 @@
148 tetris_all: tetris/tetris tetris/tetris.6
149
150 tetris_install: tetris_all
151- $(INSTALL_SCORE_GAME) tetris/tetris $(INSTALL_PREFIX)$(GAMESDIR)/tetris-bsd
152+ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/tetris-bsd
153+ $(INSTALL_SCORE_GAME) tetris/tetris $(INSTALL_PREFIX)$(GAMESDIR)/.tetris-bsd-real
154 $(HIDE_GAME) tetris-bsd
155 $(INSTALL_SCORE_FILE) $(TETRIS_SCOREFILE)
156 ln -f tetris/tetris.6 tetris/tetris-bsd.6
157diff -Naur bsd-games-2.17/wrapper bsd-games-patch/wrapper
158--- bsd-games-2.17/wrapper 1970-01-01 07:00:00.000000000 +0700
159+++ bsd-games-patch/wrapper 2020-04-23 20:24:37.153766719 +0700
160@@ -0,0 +1,91 @@
161+#!/bin/sh
162+# This file works around limitations of our read-only Store.
163+
164+set -e
165+
166+check_empty_files () {
167+ # those start empty
168+ for f in ${@}
169+ do
170+ if [[ ! -f ${f} ]]
171+ then
172+ touch ${f}
173+ echo "$(pwd)/${f} RESTORED"
174+ fi
175+ done
176+}
177+check_data_files () {
178+ # those start with some initial data
179+ for f in ${@}
180+ do
181+ if [[ ! -f ${f} ]]
182+ then
183+ cp STATIC_DATA/${game}/${f} ${f}
184+ chmod u+w ${f}
185+ echo "$(pwd)/${f} RESTORED"
186+ fi
187+ done
188+}
189+visit_dir () {
190+ mkdir -p ${1}
191+ cd ${1}
192+}
193+exit_with_variable_error () {
194+ variables="${1}${2:+ or ${2}}"
195+ echo "Guix: Please set up the ${variables} variable."
196+ echo "Examples:"
197+ echo " export ${1}=/var/multiplayer"
198+ echo " export ${2:-${1}}=~/.local/share/bsd-games"
199+ echo "You can place this in ~/.bashrc or a similar file for Your shell."
200+ echo "For multiplayer this directory should be writable for all players."
201+ exit 1
202+}
203+
204+game=$(basename $0)
205+if [[ ${game} == "hack" ]]
206+then
207+ if [[ -n ${HACKDIR} ]]; then visit_dir "${HACKDIR}"
208+ elif [[ -n ${BSD_GAMES_DIR} ]]; then visit_dir "${BSD_GAMES_DIR}/hack"
209+ else exit_with_variable_error "HACKDIR" "BSD_GAMES_DIR"
210+ fi
211+else
212+ if [[ -n ${BSD_GAMES_DIR} ]]; then visit_dir "${BSD_GAMES_DIR}"
213+ else exit_with_variable_error "BSD_GAMES_DIR"
214+ fi
215+fi
216+
217+case ${game} in
218+ ### Games with score-files
219+ atc)
220+ check_empty_files "atc_score";;
221+ battlestar)
222+ check_empty_files "battlestar.log";;
223+ canfield)
224+ check_empty_files "cfscores";;
225+ cribbage)
226+ check_empty_files "criblog";;
227+ robots)
228+ check_empty_files "robots_roll";;
229+ snake)
230+ check_empty_files "snakerawscores" "snake.log";;
231+ tetris)
232+ check_empty_files "tetris-bsd.scores";;
233+ ### Games with saved state
234+ hack)
235+ check_empty_files "record" "perm"
236+ check_data_files "data" "help" "hh" "rumors"
237+ visit_dir "save"
238+ cd ../../;;
239+ phantasia)
240+ visit_dir "phantasia"
241+ check_empty_files "characs" "gold" "lastdead"\
242+ "mess" "motd" "scoreboard" "void"
243+ check_data_files "monsters"
244+ cd ../;;
245+ sail)
246+ visit_dir "sail"
247+ check_empty_files "log" "syncfile"
248+ cd ../;;
249+esac
250+
251+exec .${game}-real ${@}