Subject: [PATCH] Add frozen-bubble

From: Nicolas Goaziou <[email-masked]>
Date: Sun, 14 Jun 2020 14:26:41 +0200

Hello,

These three patches add perl-alien-sdl, perl-sdl, and, ultimately,
frozen-bubble.

Feedback welcome,

Regards,
-- 
Nicolas Goaziou
>From 2586c90f5a25985bd02b0ea5bc65c5fc982b50d8 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <[email-masked]>
Date: Sun, 14 Jun 2020 11:50:43 +0200
Subject: [PATCH 1/3] gnu: Add perl-alien-sdl.

* gnu/packages/perl.scm (perl-alien-sdl): New variable.
---
 gnu/packages/perl.scm | 60 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index 42839f4409..3e3188ae53 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -57,8 +57,10 @@
   #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gd)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages hurd)
   #:use-module (gnu packages less)
   #:use-module (gnu packages ncurses)
@@ -67,6 +69,7 @@
   #:use-module (gnu packages perl-web)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages sdl)
   #:use-module (gnu packages textutils)
   #:use-module (gnu packages web))
 
@@ -321,6 +324,63 @@ explicitly alias the class to another name or, if you prefer, you can do so
 implicitly.")
     (license (package-license perl))))
 
+(define-public perl-alien-sdl
+  (package
+    (name "perl-alien-sdl")
+    (version "1.446")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://cpan/authors/id/F/FR/FROGGS/"
+                           "Alien-SDL-" version ".tar.gz"))
+       (sha256
+        (base32 "0ajipk43syhlmw0zinbj1i6r46vdlkr06wkx7ivqjgf6qffjran9"))))
+    (build-system perl-build-system)
+    (arguments
+     `(#:module-build-flags
+       ;; XXX: For some reason, `sdl-config' reports stand-alone SDL
+       ;; directory, not SDL-union provided as an input to the
+       ;; package.  We force the latter with "--prefix=" option.
+       (list (let ((sdl (assoc-ref %build-inputs "sdl")))
+               (string-append "--with-sdl-config=" sdl "/bin/sdl-config"
+                              " --prefix=" sdl)))
+       #:phases
+       (modify-phases %standard-phases
+         ;; Fix "unrecognized option: --with-sdl-config" during build.
+         ;; Reported upstream as
+         ;; <https://github.com/PerlGameDev/SDL/issues/261>.  See also
+         ;; <https://github.com/PerlGameDev/SDL/issues/272>.
+         (add-after 'unpack 'fix-build.pl
+           (lambda _
+             (substitute* "Build.PL"
+               (("use Getopt::Long;") "")
+               (("GetOptions\\( \"travis\" => \\\\\\$travis \\);") ""))
+             #t)))))
+    (native-inputs
+     `(("perl-archive-extract" ,perl-archive-extract)
+       ("perl-archive-zip" ,perl-archive-zip)
+       ("perl-capture-tiny" ,perl-capture-tiny)
+       ("perl-file-sharedir" ,perl-file-sharedir)
+       ("perl-file-which" ,perl-file-which)
+       ("perl-module-build" ,perl-module-build)
+       ("perl-text-patch" ,perl-text-patch)))
+    (inputs
+     `(("freetype" ,freetype)
+       ("fontconfig" ,fontconfig)
+       ("pango" ,pango)
+       ("sdl" ,(sdl-union
+                (list sdl sdl-gfx sdl-image sdl-mixer sdl-net sdl-ttf
+                      sdl-pango)))
+       ("zlib" ,zlib)))
+    (home-page "https://metacpan.org/release/Alien-SDL")
+    (synopsis "Get, build and use SDL libraries")
+    (description
+     "Alien::SDL can be used to detect and get configuration settings from an
+installed SDL and related libraries.  Based on your platform it offers the
+possibility to download and install prebuilt binaries or to build SDL & co.@:
+from source codes.")
+    (license license:perl-license)))
+
 (define-public perl-any-moose
   (package
     (name "perl-any-moose")
-- 
2.26.2

>From 64744949f1d80b40317d942807b871f3c3f0f490 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <[email-masked]>
Date: Sun, 14 Jun 2020 12:44:28 +0200
Subject: [PATCH 2/3] gnu: Add perl-sdl.

* gnu/packages/perl.scm (perl-sdl): New variable.
---
 gnu/packages/perl.scm | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index 3e3188ae53..4ca1b5afd4 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -60,8 +60,10 @@
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gd)
+  #:use-module (gnu packages gl)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages hurd)
+  #:use-module (gnu packages image)
   #:use-module (gnu packages less)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl-check)
@@ -71,6 +73,7 @@
   #:use-module (gnu packages readline)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages textutils)
+  #:use-module (gnu packages video)
   #:use-module (gnu packages web))
 
 ;;;
@@ -11016,6 +11019,46 @@ really be high enough to warrant the use of a keyword, and the size so small
 such that being individual extensions would be wasteful.")
     (license (package-license perl))))
 
+(define-public perl-sdl
+  (package
+    (name "perl-sdl")
+    (version "2.548")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://cpan/authors/id/F/FR/FROGGS/"
+                           "SDL-" version ".tar.gz"))
+       (sha256
+        (base32 "1dagpmcpjnwvd4g6mmnc312rqpd4qcwx21rpi2j7084wz8mijai5"))))
+    (build-system perl-build-system)
+    (native-inputs
+     `(("perl-alien-sdl" ,perl-alien-sdl)
+       ("perl-capture-tiny" ,perl-capture-tiny)
+       ("perl-file-sharedir" ,perl-file-sharedir)
+       ("perl-module-build" ,perl-module-build)
+       ("perl-test-most" ,perl-test-most)
+       ("perl-tie-simple" ,perl-tie-simple)))
+    (inputs
+     `(("freeglut" ,freeglut)
+       ("libjpeg" ,libjpeg-turbo)
+       ("libpng" ,libpng)
+       ("libsmpeg" ,libsmpeg)
+       ("libtiff" ,libtiff)
+       ("mesa" ,mesa)
+       ("sdl" ,(sdl-union
+                (list sdl sdl-gfx sdl-image sdl-mixer sdl-pango sdl-ttf)))))
+    (propagated-inputs
+     `(("perl-file-sharedir" ,perl-file-sharedir)
+       ("perl-tie-simple" ,perl-tie-simple)))
+    (home-page "https://metacpan.org/release/SDL")
+    (synopsis "SDL bindings to Perl")
+    (description
+     "SDL Perl is a package of Perl modules that provide both functional and
+object oriented interfaces to the Simple DirectMedia Layer for Perl5.  This
+package takes some liberties with the SDL API, and attempts to adhere to the
+spirit of both the SDL and Perl.")
+    (license license:lgpl2.1)))
+
 (define-public perl-shell-command
   (package
     (name "perl-shell-command")
-- 
2.26.2

>From 6ff230c8ec69cdc21d6b8148b54f170b3fd859e9 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <[email-masked]>
Date: Sun, 14 Jun 2020 12:50:34 +0200
Subject: [PATCH 3/3] gnu: Add frozen-bubble.

* gnu/packages/games.scm (frozen-bubble): New variable.
---
 gnu/packages/games.scm | 102 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 100 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 32d7d8d478..1bd2032d57 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -146,6 +146,7 @@
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages perl-check)
+  #:use-module (gnu packages perl-compression)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
@@ -176,14 +177,15 @@
   #:use-module (gnu packages messaging)
   #:use-module (gnu packages networking)
   #:use-module (guix build-system copy)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system glib-or-gtk)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system meson)
-  #:use-module (guix build-system scons)
+  #:use-module (guix build-system perl)
   #:use-module (guix build-system python)
-  #:use-module (guix build-system cmake)
   #:use-module (guix build-system qt)
+  #:use-module (guix build-system scons)
   #:use-module (guix build-system trivial)
   #:use-module ((srfi srfi-1) #:hide (zip))
   #:use-module (srfi srfi-26))
@@ -6842,6 +6844,102 @@ when packaged in Blorb container files or optionally from individual files.")
       (home-page "http://frotz.sourceforge.net")
       (license license:gpl2+))))
 
+(define-public frozen-bubble
+  (let ((commit "d6a029110ad6ab9e4960052e175addc98807fb7e")
+        (revision "1"))
+    (package
+      (name "frozen-bubble")
+      (version (git-version "2.2.1" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/kthakore/frozen-bubble.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1rfrcym5lf4qac2qdklikb1ywijyxypq298azzxahy461dadl6cx"))))
+      (build-system perl-build-system)
+      (arguments
+       `(#:module-build-flags '("installdir=vendors")
+         #:phases
+         (modify-phases %standard-phases
+           ;; Build process needs to create files in the "server"
+           ;; directory.
+           (add-after 'unpack 'fix-permissions
+             (lambda _ (invoke "chmod" "-R" "+w" "server")))
+           ;; By default, build stops at warnings.
+           (add-after 'unpack 'prevent-build-error
+             (lambda _
+               (substitute* "inc/My/Builder.pm"
+                 (("-Werror") ""))
+               #t))
+           (add-after 'install 'install-desktop-file-and-icons
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((share (string-append (assoc-ref outputs "out") "/share"))
+                      (hicolor (string-append share "/icons/hicolor")))
+                 ;; Create desktop entry.
+                 (make-desktop-entry-file
+                  (string-append share "/applications/" ,name ".desktop")
+                  #:name "Frozen Bubble"
+                  #:comment "Frozen Bubble arcade game"
+                  #:exec ,name
+                  #:icon ,name
+                  #:categories '("Game" "ArcadeGame"))
+                 ;; Add icons.
+                 (with-directory-excursion "share/icons"
+                   (for-each
+                    (lambda (size)
+                      (let* ((dim (string-append size "x" size))
+                             (dir (string-append hicolor "/" dim "/apps")))
+                        (mkdir-p dir)
+                        (copy-file
+                         (string-append "frozen-bubble-icon-" dim ".png")
+                         (string-append dir "/frozen-bubble.png"))))
+                    '("16" "32" "48" "64"))))
+               #t))
+           (add-after 'install 'wrap-perl-libs
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out"))
+                     (perl5lib (getenv "PERL5LIB")))
+                 (for-each (lambda (prog)
+                             (wrap-program (string-append out "/" prog)
+                               `("PERL5LIB" ":" prefix
+                                 (,(string-append perl5lib ":" out
+                                                  "/lib/perl5/site_perl")))))
+                           (find-files "bin" ".")))
+               #t)))))
+      (native-inputs
+       `(("perl-alien-sdl" ,perl-alien-sdl)
+         ("perl-capture-tiny" ,perl-capture-tiny)
+         ("perl-locale-maketext-lexicon" ,perl-locale-maketext-lexicon)
+         ("perl-module-build" ,perl-module-build)
+         ("pkg-config" ,pkg-config)))
+      (inputs
+       `(("glib" ,glib)
+         ("perl-compress-bzip2" ,perl-compress-bzip2)
+         ("perl-file-sharedir" ,perl-file-sharedir)
+         ("perl-file-slurp" ,perl-file-slurp)
+         ("perl-file-which" ,perl-file-which)
+         ("perl-ipc-system-simple" ,perl-ipc-system-simple)
+         ("perl-sdl" ,perl-sdl)
+         ("sdl" ,(sdl-union (list sdl sdl-image sdl-mixer sdl-pango sdl-ttf)))))
+      (home-page "http://frozen-bubble.org/")
+      (synopsis "Puzzle with Bubbles")
+      (description
+       "Frozen-Bubble is a clone of the popular Puzzle Bobble game, in which
+you attempt to shoot bubbles into groups of the same color to cause them to
+pop.
+
+Players compete as penguins and must use the arrow keys to aim a colored
+bubble at groups of bubbles.  The objective is to clear all the bubbles off
+the screen before a bubble passes below a line at the bottom.
+
+It features 100 single-player levels, a two-player mode, music and striking
+graphics.  A level editor is also included to allow players to create and play
+their own levels.")
+      (license license:gpl2))))
+
 (define-public libmanette
   (package
     (name "libmanette")
-- 
2.26.2