Subject: [PATCH v2 3/3] gnu: Add sgt-puzzles.

From: Sergey Trofimov <[email-masked]>
Date: Fri, 17 Mar 2023 09:29:10 +0100

* gnu/packages/games.scm (sgt-puzzles): New variable.
* gnu/packages/patches/sgt-puzzles-install-two-icon-sizes.patch: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/games.scm                        | 73 +++++++++++++++++++
 .../sgt-puzzles-install-two-icon-sizes.patch  | 35 +++++++++
 3 files changed, 109 insertions(+)
 create mode 100644 gnu/packages/patches/sgt-puzzles-install-two-icon-sizes.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f8061e4a34..c8ebf35158 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1842,6 +1842,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/scons-test-environment.patch		\
   %D%/packages/patches/screen-hurd-path-max.patch		\
   %D%/packages/patches/scsh-nonstring-search-path.patch	\
+  %D%/packages/patches/sgt-puzzles-install-two-icon-sizes.patch	\
   %D%/packages/patches/sdl-libx11-1.6.patch			\
   %D%/packages/patches/seed-webkit.patch			\
   %D%/packages/patches/sendgmail-accept-ignored-gsuite-flag.patch	\
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 31523777bd..ddc16b47da 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -873,6 +873,79 @@ (define-public bsd-games
               ;; phantasia (all but phantasia/pathnames.h.in, which is bsd-3)
               (license:fsf-free "file:///phantasia/COPYRIGHT")))))
 
+(define-public sgt-puzzles
+  (package
+    (name "sgt-puzzles")
+    (version "20230313.adf2a09")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://www.chiark.greenend.org.uk/~sgtatham/puzzles/puzzles-"
+                    version ".tar.gz"))
+              (sha256
+               (base32
+                "0205wrshf2y27fzaqxv4gfpgmnlj4klwjcadwjrzjx7fkkzlr51j"))
+              (patches (search-patches
+                        "sgt-puzzles-install-two-icon-sizes.patch"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list #:tests? #f ;No tests.
+           #:configure-flags #~(list "-DNAME_PREFIX=sgt-")
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'set-xdg-open-path
+                          (lambda _
+                            (substitute* "gtk.c"
+                              (("(#define HELP_BROWSER_PATH ).+" all define)
+                               (string-append define "\""
+                                              #$(this-package-input
+                                                 "xdg-utils")
+                                              "/bin/xdg-open\"\n"))))))))
+    (inputs (list gtk+ xdg-utils))
+    (native-inputs (list pkg-config perl imagemagick halibut))
+    (home-page "https://www.chiark.greenend.org.uk/~sgtatham/puzzles/")
+    (synopsis "Simon Tatham's portable puzzle collection")
+    (description
+     "Simon Tatham's Portable Puzzle Collection contains a number of
+popular puzzle games for one player.  It currently consists of these games:
+@itemize
+@item Black Box, ball-finding puzzle
+@item Bridges, bridge-placing puzzle
+@item Cube, rolling cube puzzle
+@item Dominosa, domino tiling puzzle
+@item Fifteen, sliding block puzzle
+@item Filling, polyomino puzzle
+@item Flip, tile inversion puzzle
+@item Galaxies, symmetric polyomino puzzle
+@item Guess, combination-guessing puzzle
+@item Inertia, gem-collecting puzzle
+@item Keen, arithmetic Latin square puzzle
+@item Light Up, light-bulb placing puzzle
+@item Loopy, loop-drawing puzzle
+@item Magnets, magnet-placing puzzle
+@item Map, map-colouring puzzle
+@item Mines, mine-finding puzzle
+@item Net, network jigsaw puzzle
+@item Netslide, toroidal sliding network puzzle
+@item Pattern
+@item Pearl, loop-drawing puzzle
+@item Pegs, peg solitaire puzzle
+@item Range, visible-distance puzzle
+@item Rectangles
+@item Same Game, block-clearing puzzle
+@item Signpost, square-connecting puzzle
+@item Singles, number-removing puzzle
+@item Sixteen, toroidal sliding block puzzle
+@item Slant, maze-drawing puzzle
+@item Solo, number placement puzzle
+@item Tents, tent-placing puzzle
+@item Towers, tower-placing Latin square puzzle
+@item Twiddle, rotational sliding block puzzle
+@item Undead, monster-placing puzzle
+@item Unequal, Latin square puzzle
+@item Unruly, black and white grid puzzle
+@item Untangle, planar graph layout puzzle
+@end itemize")
+    (license license:expat)))
 
 (define-public bzflag
   (package
diff --git a/gnu/packages/patches/sgt-puzzles-install-two-icon-sizes.patch b/gnu/packages/patches/sgt-puzzles-install-two-icon-sizes.patch
new file mode 100644
index 0000000000..3bacd2120c
--- /dev/null
+++ b/gnu/packages/patches/sgt-puzzles-install-two-icon-sizes.patch
@@ -0,0 +1,35 @@
+From: Ben Hutchings <[email-masked]>
+Date: Sun, 22 Jan 2023 22:58:43 +0100
+Subject: Install both 48x48 and 96x96 icons
+Bug-Debian: https://bugs.debian.org/887982
+
+gnome-shell prefers to use 96x96 icons, so install them as well as the
+48x48 icons.  Install them in size-specific directories instead of
+using suffixes to the filename, and change the desktop files
+accordingly.
+
+---
+--- a/cmake/platforms/unix.cmake
++++ b/cmake/platforms/unix.cmake
+@@ -107,7 +107,9 @@ function(set_platform_puzzle_target_prop
+     endif()
+     configure_file(${CMAKE_SOURCE_DIR}/puzzle.desktop.in ${binary_name}.desktop)
+     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/icons/${NAME}-48d24.png
+-      DESTINATION share/pixmaps OPTIONAL RENAME ${binary_name}-48d24.png)
++      DESTINATION share/icons/hicolor/48x48/apps OPTIONAL RENAME ${binary_name}.png)
++    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/icons/${NAME}-96d24.png
++      DESTINATION share/icons/hicolor/96x96/apps OPTIONAL RENAME ${binary_name}.png)
+     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${binary_name}.desktop
+       DESTINATION share/applications)
+   endif()
+--- a/puzzle.desktop.in
++++ b/puzzle.desktop.in
+@@ -4,7 +4,7 @@ Type=Application
+ Name=${displayname}
+ Comment=${description}
+ Exec=${binary_name}
+-Icon=${binary_name}-48d24
++Icon=${binary_name}
+ StartupNotify=false
+ Categories=Game;LogicGame;
+ Terminal=false
-- 
2.39.2