summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/bsd-games-add-wrapper.patch
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/patches/bsd-games-add-wrapper.patch')
-rw-r--r--gnu/packages/patches/bsd-games-add-wrapper.patch217
1 files changed, 217 insertions, 0 deletions
diff --git a/gnu/packages/patches/bsd-games-add-wrapper.patch b/gnu/packages/patches/bsd-games-add-wrapper.patch
new file mode 100644
index 0000000000..78f78deb43
--- /dev/null
+++ b/gnu/packages/patches/bsd-games-add-wrapper.patch
@@ -0,0 +1,217 @@
+As we cannot install outside the Store, and those games do not create the
+needed files on their own, we need a wrapper script. This script also do
+`chmod ug+w`, to allow users in default setup (all users belong to group
+'users') to use this games. Enhancing security for those old games is left to
+local administrator, for now.
+
+diff -Naur bsd-games-2.17/atc/Makefrag bsd-games-patch/atc/Makefrag
+--- bsd-games-2.17/atc/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/atc/Makefrag 2020-04-23 20:24:04.446176222 +0700
+@@ -47,7 +47,8 @@
+ mv atc/lex.yy.c $@
+
+ atc_install: atc_all
+- $(INSTALL_SCORE_GAME) atc/atc $(INSTALL_PREFIX)$(GAMESDIR)/atc
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/atc
++ $(INSTALL_SCORE_GAME) atc/atc $(INSTALL_PREFIX)$(GAMESDIR)/.atc-real
+ $(HIDE_GAME) atc
+ $(INSTALL_SCORE_FILE) $(ATC_SCOREFILE)
+ $(INSTALL_MANUAL) atc/atc.6
+diff -Naur bsd-games-2.17/battlestar/Makefrag bsd-games-patch/battlestar/Makefrag
+--- bsd-games-2.17/battlestar/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/battlestar/Makefrag 2020-04-23 20:24:04.482175771 +0700
+@@ -32,7 +32,8 @@
+ battlestar_all: battlestar/battlestar battlestar/battlestar.6
+
+ battlestar_install: battlestar_all
+- $(INSTALL_SCORE_GAME) battlestar/battlestar $(INSTALL_PREFIX)$(GAMESDIR)/battlestar
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/battlestar
++ $(INSTALL_SCORE_GAME) battlestar/battlestar $(INSTALL_PREFIX)$(GAMESDIR)/.battlestar-real
+ $(HIDE_GAME) battlestar
+ $(INSTALL_MANUAL) battlestar/battlestar.6
+ $(INSTALL_SCORE_FILE) $(BATTLESTAR_SCOREFILE)
+diff -Naur bsd-games-2.17/canfield/canfield/Makefrag bsd-games-patch/canfield/canfield/Makefrag
+--- bsd-games-2.17/canfield/canfield/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/canfield/canfield/Makefrag 2020-04-23 20:24:04.522175270 +0700
+@@ -31,7 +31,8 @@
+ canfield_canfield_all: canfield/canfield/canfield canfield/canfield/canfield.6
+
+ canfield_canfield_install: canfield_canfield_all
+- $(INSTALL_SCORE_GAME) canfield/canfield/canfield $(INSTALL_PREFIX)$(GAMESDIR)/canfield
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/canfield
++ $(INSTALL_SCORE_GAME) canfield/canfield/canfield $(INSTALL_PREFIX)$(GAMESDIR)/.canfield-real
+ $(HIDE_GAME) canfield
+ $(INSTALL_MANUAL) canfield/canfield/canfield.6
+ $(INSTALL_SCORE_FILE) $(CANFIELD_SCOREFILE)
+diff -Naur bsd-games-2.17/cribbage/Makefrag bsd-games-patch/cribbage/Makefrag
+--- bsd-games-2.17/cribbage/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/cribbage/Makefrag 2020-04-23 20:24:04.534175120 +0700
+@@ -31,7 +31,8 @@
+ cribbage_all: cribbage/cribbage cribbage/cribbage.n cribbage/cribbage.6
+
+ cribbage_install: cribbage_all
+- $(INSTALL_SCORE_GAME) cribbage/cribbage $(INSTALL_PREFIX)$(GAMESDIR)/cribbage
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/cribbage
++ $(INSTALL_SCORE_GAME) cribbage/cribbage $(INSTALL_PREFIX)$(GAMESDIR)/.cribbage-real
+ $(HIDE_GAME) cribbage
+ $(INSTALL_DATA) cribbage/cribbage.n $(INSTALL_PREFIX)$(CRIBBAGE_INSTRFILE)
+ $(INSTALL_SCORE_FILE) $(CRIBBAGE_SCOREFILE)
+diff -Naur bsd-games-2.17/hack/Makefrag bsd-games-patch/hack/Makefrag
+--- bsd-games-2.17/hack/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/hack/Makefrag 2020-04-23 20:24:04.590174419 +0700
+@@ -53,7 +53,8 @@
+ hack/hack.zap.d hack/rnd.d: hack/hack.onames.h
+
+ hack_install: hack_all
+- $(INSTALL_SCORE_GAME) hack/hack $(INSTALL_PREFIX)$(GAMESDIR)/hack
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/hack
++ $(INSTALL_SCORE_GAME) hack/hack $(INSTALL_PREFIX)$(GAMESDIR)/.hack-real
+ $(HIDE_GAME) hack
+ $(INSTALL_HACK_DIR) $(INSTALL_PREFIX)$(HACK_DIR)
+ set -e; for f in data help hh rumors; do $(INSTALL_DATA) hack/$$f $(INSTALL_PREFIX)$(HACK_DIR)/$$f; done
+diff -Naur bsd-games-2.17/phantasia/Makefrag bsd-games-patch/phantasia/Makefrag
+--- bsd-games-2.17/phantasia/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/phantasia/Makefrag 2020-04-23 20:24:04.650173667 +0700
+@@ -38,7 +38,8 @@
+ touch phantasia/scorefiles.stamp
+
+ phantasia_install: phantasia_all
+- $(INSTALL_SCORE_GAME) phantasia/phantasia $(INSTALL_PREFIX)$(GAMESDIR)/phantasia
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/phantasia
++ $(INSTALL_SCORE_GAME) phantasia/phantasia $(INSTALL_PREFIX)$(GAMESDIR)/.phantasia-real
+ $(HIDE_GAME) phantasia
+ (set -e; for f in $(phantasia_VFILES1); do \
+ cp phantasia/$$f $(INSTALL_PREFIX)$(PHANTASIA_DIR)/$$f; \
+diff -Naur bsd-games-2.17/robots/Makefrag bsd-games-patch/robots/Makefrag
+--- bsd-games-2.17/robots/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/robots/Makefrag 2020-04-23 20:24:04.702173016 +0700
+@@ -32,7 +32,8 @@
+ robots_all: robots/robots robots/robots.6
+
+ robots_install: robots_all
+- $(INSTALL_SCORE_GAME) robots/robots $(INSTALL_PREFIX)$(GAMESDIR)/robots
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/robots
++ $(INSTALL_SCORE_GAME) robots/robots $(INSTALL_PREFIX)$(GAMESDIR)/.robots-real
+ $(HIDE_GAME) robots
+ $(INSTALL_SCORE_FILE) $(ROBOTS_SCOREFILE)
+ $(INSTALL_MANUAL) robots/robots.6
+diff -Naur bsd-games-2.17/sail/Makefrag bsd-games-patch/sail/Makefrag
+--- bsd-games-2.17/sail/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/sail/Makefrag 2020-04-23 20:24:04.710172917 +0700
+@@ -31,7 +31,8 @@
+ sail_all: sail/sail sail/sail.6
+
+ sail_install: sail_all
+- $(INSTALL_SCORE_GAME) sail/sail $(INSTALL_PREFIX)$(GAMESDIR)/sail
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/sail
++ $(INSTALL_SCORE_GAME) sail/sail $(INSTALL_PREFIX)$(GAMESDIR)/.sail-real
+ $(HIDE_GAME) sail
+ $(INSTALL_SCORE_FILE) $(SAIL_SCOREFILE)
+ $(INSTALL_SAIL_DIR) $(INSTALL_PREFIX)$(SAIL_DIR)
+diff -Naur bsd-games-2.17/snake/snake/Makefrag bsd-games-patch/snake/snake/Makefrag
+--- bsd-games-2.17/snake/snake/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/snake/snake/Makefrag 2020-04-23 20:24:04.722172766 +0700
+@@ -31,7 +31,8 @@
+ snake_snake_all: snake/snake/snake snake/snake/snake.6
+
+ snake_snake_install: snake_snake_all
+- $(INSTALL_SCORE_GAME) snake/snake/snake $(INSTALL_PREFIX)$(GAMESDIR)/snake
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/snake
++ $(INSTALL_SCORE_GAME) snake/snake/snake $(INSTALL_PREFIX)$(GAMESDIR)/.snake-real
+ $(HIDE_GAME) snake
+ $(INSTALL_SCORE_FILE) $(SNAKE_SCOREFILE)
+ $(INSTALL_SCORE_FILE) $(SNAKE_RAWSCOREFILE)
+diff -Naur bsd-games-2.17/tetris/Makefrag bsd-games-patch/tetris/Makefrag
+--- bsd-games-2.17/tetris/Makefrag 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/tetris/Makefrag 2020-04-23 20:24:04.734172616 +0700
+@@ -32,7 +32,8 @@
+ tetris_all: tetris/tetris tetris/tetris.6
+
+ tetris_install: tetris_all
+- $(INSTALL_SCORE_GAME) tetris/tetris $(INSTALL_PREFIX)$(GAMESDIR)/tetris-bsd
++ $(INSTALL_SCORE_GAME) wrapper $(INSTALL_PREFIX)$(GAMESDIR)/tetris-bsd
++ $(INSTALL_SCORE_GAME) tetris/tetris $(INSTALL_PREFIX)$(GAMESDIR)/.tetris-bsd-real
+ $(HIDE_GAME) tetris-bsd
+ $(INSTALL_SCORE_FILE) $(TETRIS_SCOREFILE)
+ ln -f tetris/tetris.6 tetris/tetris-bsd.6
+diff -Naur bsd-games-2.17/wrapper bsd-games-patch/wrapper
+--- bsd-games-2.17/wrapper 1970-01-01 07:00:00.000000000 +0700
++++ bsd-games-patch/wrapper 2020-04-23 20:24:37.153766719 +0700
+@@ -0,0 +1,77 @@
++#!/bin/sh
++# this file works around limitations of read-only Store
++
++set -e
++
++check_empty_files () {
++ # those start empty
++ for f in ${@}
++ do
++ if [[ ! -f ${f} ]]
++ then
++ touch ${f}
++ chmod ug+w ${f}
++ echo "$(pwd)/${f} RESTORED"
++ fi
++ done
++}
++# about chmod ug+w: lets imagine that the first player is a Wizard of the game
++# which is responsible for setting a proper groups and permissions by hand, if
++# those aren't OK.
++check_data_files () {
++ # those start with some initial data
++ for f in ${@}
++ do
++ if [[ ! -f ${f} ]]
++ then
++ cp STATIC_DATA/$(basename $(pwd))/${f} ${f}
++ chmod ug+w ${f} # should be writable too
++ echo "$(pwd)/${f} RESTORED"
++ fi
++ done
++}
++visit_state_dir () {
++ state_dir=SAVE_FILES/${1}
++ if [[ ! -d ${state_dir} ]]
++ then
++ mkdir -p ${state_dir}
++ fi
++ cd ${state_dir}
++}
++
++game=$(basename $0)
++
++visit_state_dir
++case ${game} in
++ ### Games with score-files
++ *atc)
++ check_empty_files "atc_score";;
++ *battlestar)
++ check_empty_files "battlestar.log";;
++ *canfield)
++ check_empty_files "cfscores";;
++ *cribbage)
++ check_empty_files "criblog";;
++ *robots)
++ check_empty_files "robots_roll";;
++ *snake)
++ check_empty_files "snakerawscores" "snake.log";;
++ *tetris)
++ check_empty_files "tetris-bsd.scores";;
++ *sail)
++ visit_state_dir "sail"
++ check_empty_files "log";;
++ ### Games with saved state
++ *phantasia)
++ visit_state_dir "phantasia"
++ check_empty_files "characs" "gold" "lastdead"\
++ "mess" "motd" "scoreboard" "void"
++ check_data_files "monsters";;
++ *hack)
++ visit_state_dir "hack"
++ check_empty_files "record" "perm"
++ check_data_files "data" "help" "hh" "rumors"
++ visit_state_dir "hack/save";;
++esac
++
++exec .${game}-real ${@}