Subject: [PATCH] gnu: Add bastet.

From: Tobias Geerinckx-Rice <[email-masked]>
Date: Thu, 4 Oct 2018 04:53:19 +0200

* gnu/packages/games.scm (bastet): New public variable.
* gnu/packages/patches/bastet-change-source-of-unordered_set.patch:
New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---

The Chromium of tetroids.

 gnu/local.mk                                  |  1 +
 gnu/packages/games.scm                        | 64 +++++++++++++++++++
 ...astet-change-source-of-unordered_set.patch | 40 ++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 gnu/packages/patches/bastet-change-source-of-unordered_set.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 4152696a7..101399d9b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -591,6 +591,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/awesome-reproducible-png.patch		\
   %D%/packages/patches/azr3.patch				\
   %D%/packages/patches/bash-completion-directories.patch	\
+  %D%/packages/patches/bastet-change-source-of-unordered_set.patch	\
   %D%/packages/patches/bazaar-CVE-2017-14176.patch		\
   %D%/packages/patches/beignet-correct-file-names.patch		\
   %D%/packages/patches/binutils-aarch64-symbol-relocation.patch	\
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index ec92f508b..9ee22191a 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -181,6 +181,70 @@ more advanced player there are new game modes and a wide variety of physics
 settings to tweak as well.")
     (license license:gpl2+)))
 
+(define-public bastet
+  (package
+    (name "bastet")
+    (version "0.43.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/fph/bastet.git")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "09kamxapm9jw9przpsgjfg33n9k94bccv65w95dakj0br33a75wn"))
+       (patches
+        (search-patches "bastet-change-source-of-unordered_set.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags
+       (list (string-append "CXXFLAGS=-I"
+                            (assoc-ref %build-inputs "boost") "/include"))
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)            ; no configure script
+         (replace 'check
+           ;; The 'Test' target builds the test, but doesn't actually run it.
+           (lambda* (#:key make-flags #:allow-other-keys)
+             (apply invoke "make" "Test" make-flags)
+             (setenv "HOME" ".")
+             (invoke "./Test")))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out     (assoc-ref outputs "out"))
+                    (share   (string-append out "/share"))
+                    (hicolor (string-append share "/icons/hicolor")))
+               (install-file "bastet"
+                             (string-append out "/bin"))
+
+               (install-file "bastet.desktop"
+                             (string-append share "/applications"))
+               (install-file "bastet.svg"
+                             (string-append hicolor "/scalable/apps"))
+
+               (install-file "bastet.appdata.xml"
+                             (string-append share "/appdata"))
+
+               (install-file "bastet.6"
+                             (string-append out "/share/man/man6"))
+               #t))))))
+    (native-inputs
+     `(("hicolor-icon-theme" ,hicolor-icon-theme)))
+    (inputs
+     `(("boost" ,boost)
+       ("ncurses" ,ncurses)))
+    (home-page "http://fph.altervista.org/prog/bastet.html")
+    (synopsis "Antagonistic Tetris-style falling brick game for text terminals")
+    (description
+     "Bastet (short for Bastard Tetris) is a simple ncurses-based falling brick
+game.  Unlike normal Tetris, Bastet does not choose the next brick at random.
+Instead, it uses a special algorithm to choose the worst brick possible.
+
+Playing bastet can be a painful experience, especially if you usually make
+canyons and wait for the long I-shaped block to clear four rows at a time.")
+    (license license:gpl3+)))
+
 (define-public cataclysm-dda
   (let ((commit "ad3b0c3d521292d119f97a83390e7acfe9e9e7f7")
         (revision "1"))
diff --git a/gnu/packages/patches/bastet-change-source-of-unordered_set.patch b/gnu/packages/patches/bastet-change-source-of-unordered_set.patch
new file mode 100644
index 000000000..ef3970a3e
--- /dev/null
+++ b/gnu/packages/patches/bastet-change-source-of-unordered_set.patch
@@ -0,0 +1,40 @@
+From: Tobias Geerinckx-Rice <[email-masked]>
+Date: Wed, 3 Oct 2018 23:30:42 +0200
+Subject: [PATCH] bastet: Change source of unordered_set.
+
+This allows building bastet 0.43.2 with boost >=1.66.
+It was backported verbatim from the upstream master branch.
+
+From 0e03f8d4d6bc6949cf1c447e632ce0d1b98c4be1 Mon Sep 17 00:00:00 2001
+From: Federico Poloni <[email-masked]>
+Date: Wed, 4 Oct 2017 19:35:01 +0200
+Subject: [PATCH] Changed source of unordered_set (should hopefully fix #6
+ without reopening #1)
+
+---
+ BastetBlockChooser.hpp | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/BastetBlockChooser.hpp b/BastetBlockChooser.hpp
+index 992e556..7ee3b7c 100644
+--- a/BastetBlockChooser.hpp
++++ b/BastetBlockChooser.hpp
+@@ -23,8 +23,7 @@
+ 
+ #include "Well.hpp"
+ 
+-#include <boost/tr1/tr1/unordered_set>
+-#include <set>
++#include <boost/unordered_set.hpp>
+ #include <boost/functional/hash.hpp>
+ 
+ namespace Bastet{
+@@ -75,7 +74,7 @@ namespace Bastet{
+   public:
+     Searcher(BlockType b, const Well *well, Vertex v, WellVisitor *visitor);
+   private:
+-    std::tr1::unordered_set<Vertex> _visited;
++    boost::unordered_set<Vertex> _visited;
+     //std::set<Vertex> _visited; ^^ the above is more efficient, we need to do many inserts
+     BlockType _block;
+     const Well *_well;
-- 
2.18.0